Skip to content

Commit

Permalink
Merge pull request #27 from evanthegrayt/13-migrations-in-docker
Browse files Browse the repository at this point in the history
Adds support to run migrations in docker build/up
  • Loading branch information
evanthegrayt authored Jun 21, 2021
2 parents 1eab94d + b8b3bc3 commit d662866
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ RUN apt-get update && apt-get install -y \
ENV APP_HOME /srv/app

ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \
BUNDLE_JOBS=8 \
BUNDLE_PATH=/bundle_cache
BUNDLE_JOBS=8

WORKDIR $APP_HOME
ENV PATH=$APP_HOME/test/dummy/bin:$PATH

RUN gem install bundler

COPY . $APP_HOME/
RUN bundle check || bundle install

WORKDIR $APP_HOME/test/dummy
RUN rails db:create db:migrate
29 changes: 16 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
app:
container_name: planter_app
build: .
dockerfile: Dockerfile
volumes:
- .:/srv/app
volumes_from:
- bundle_cache
bundle_cache:
container_name: planter_bundle_cache
image: busybox
volumes:
- /bundle_cache
version: '3'

volumes:
bundle_cache:

services:
app:
container_name: planter_app
build:
context: .
command: >
bash -c "bin/rails db:create &&
bin/rails db:migrate"
volumes:
- .:/srv/app
- bundle_cache:/usr/local/lib

0 comments on commit d662866

Please sign in to comment.