Skip to content

Adds support to run migrations in docker build/up #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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