Skip to content

Commit

Permalink
Introduce a base docker image for layer caching purposes
Browse files Browse the repository at this point in the history
This will drastically improve docker dev environment initial setup
speed. Rather than building locally, the local docker build (built from
Dockerfile.dev) is now based on the public, automated
exercism/exercism.io build (built from Dockerfile). With this as a
starting point, a developer's `docker-compose build` need only install
any new gems that are introduced in the feature branch. With no local
changes, a local docker build, excluding download time, now takes
approximately 6 seconds, vs. 50 minutes before.

Changes:

- .dockerignore vendor/

    Vendored gems make the docker context directory size large
    (+1.1 G in vendor/), causing longer build times. Additionally, as
    individual developers, rather than being able to inherit most or all
    gems from an application base image, we are forced to install the
    full set of gems when first setting up a development environment.

- Dockerfile is now used by the automated build to build the
  exercism/exercism.io base image. See
  https://hub.docker.com/r/exercism/exercism.io/

- docker-compose builds Dockerfile.dev, which is built FROM the public
  exercism/exercism.io docker image. This Dockerfile need only contain
  commands specific to the development environment and changes from the
  local git repository that need to be built. Presently, it checks for
  new gems to install.

- Dockerfile: Set WORKDIR before RUN bundle install to invalidate one
  fewer layer when the bundle is updated.
  • Loading branch information
nilbus committed Jul 20, 2017
1 parent 3e8fe7c commit ea35db4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.bundle
.env
.git
.gitignore
log
tmp
vendor
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ RUN curl -sL https://deb.nodesource.com/setup_4.x | bash - && \
apt-get install -y nodejs postgresql-client && \
npm install -g lineman

COPY Gemfile Gemfile.lock /exercism/

WORKDIR /exercism

COPY Gemfile Gemfile.lock /exercism/
RUN bundle install
4 changes: 4 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM exercism/exercism.io

COPY Gemfile Gemfile.lock /exercism/
RUN bundle check || bundle install
4 changes: 3 additions & 1 deletion docker/common.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: '2.1'
services:
app:
build: ..
build:
context: ..
dockerfile: Dockerfile.dev
env_file: ../.env
entrypoint: ruby /exercism/docker/entrypoint.rb
volumes:
Expand Down

0 comments on commit ea35db4

Please sign in to comment.