From f90e6b076d4147e303d6e6d6f980c37a261569c8 Mon Sep 17 00:00:00 2001 From: Adrian Perez Date: Fri, 1 Jan 2016 18:12:11 +0100 Subject: [PATCH 1/2] feat(docker): improve docker support This improves Docker support in the following ways: * Base image off `ruby:onbuild` to avoid unnecessary custom steps and ease derived images. * Adds `.dockerignore` to avoid sending large files to build. * Adds a `docker-compose.yml` so users can simply type `docker-compose up` to get it running. * Explicity sets the volume definition in the `Dockerfile`. * Volume is automatically mount by `docker-compose` (the `source` directory relative to the project's dir). * Workaround watcher failing to pick directory changes probably because of vboxsf and the `listen` gem failing to register filesystem changes. * Updates documentation. --- .dockerignore | 2 ++ Dockerfile | 7 +++---- README.md | 21 +++++++++++++-------- docker-compose.yml | 6 ++++++ 4 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6ef19c6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git +source diff --git a/Dockerfile b/Dockerfile index 6938dfd..5d1ea3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ -FROM ruby:2.2.3-onbuild - -RUN ln -s /usr/src/app /app # Deprecated - +FROM ruby:onbuild +MAINTAINER Adrian Perez +VOLUME /usr/src/app/source EXPOSE 4567 CMD ["bundle", "exec", "middleman", "server", "--force-polling"] diff --git a/README.md b/README.md index acb4a62..8d20a84 100644 --- a/README.md +++ b/README.md @@ -47,23 +47,28 @@ You're going to need: 2. Clone *your forked repository* (not our original one) to your hard drive with `git clone https://github.com/YOURUSERNAME/slate.git` 3. `cd slate` 4. Initialize and start (there are a few options for this): - + #### Manual/local ```shell bundle install bundle exec middleman server -``` -#### Via Docker (must install Docker first) +``` + +#### Via Docker (must install it first) ```shell -docker build -t slate . -docker run -d -p 4567:4567 --name slate -v $(pwd)/source:/app/source slate -``` +docker-compose up +``` -You can now see the docs at http://localhost:4567. Whoa! That was fast! +will spin an environment for you, with the `source` directory mapped to the +container, so you can see your edits instantly after refreshing your browser. -*Note: if you're using the Docker setup on OSX, the docs will be availalable at the output of `boot2docker ip` instead of `localhost:4567`.* +You can now see the docs at http://localhost:4567. Whoa! That was fast! + ++*Note: if you're not using Docker natively (i.e. on Linux), the docs will be ++available at the IP of your docker host. If you're using docker-machine you can ++retrieve it with `docker-machine ip `* #### Via Vagrant ```shell diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7eeae41 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +app: + build: . + ports: + - 4567:4567 + volumes: + - ./source:/usr/src/app/source From 75f61557a281db16dadb8f88c505f538d83ff04f Mon Sep 17 00:00:00 2001 From: Adrian Perez Date: Sat, 2 Jan 2016 01:51:06 +0100 Subject: [PATCH 2/2] fix(docker): new middleman requires JS runtime --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5d1ea3d..10150b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,4 +2,8 @@ FROM ruby:onbuild MAINTAINER Adrian Perez VOLUME /usr/src/app/source EXPOSE 4567 + +RUN apt-get update && apt-get install -y nodejs \ +&& apt-get clean && rm -rf /var/lib/apt/lists/* + CMD ["bundle", "exec", "middleman", "server", "--force-polling"]