Merge pull request #567 from okriuchykhin/ok_SCI_1199

Build bundle dependencies in separate docker volume [SCI-1199]
This commit is contained in:
okriuchykhin 2017-04-24 12:48:07 +02:00 committed by GitHub
commit e3f4d38424
5 changed files with 50 additions and 44 deletions

View file

@ -9,29 +9,17 @@ RUN apt-get update -qq && \
default-jre-headless \
unison \
sudo graphviz --no-install-recommends \
sudo libfile-mimeinfo-perl && \
libfile-mimeinfo-perl && \
rm -rf /var/lib/apt/lists/*
# heroku tools
RUN wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
# install gems
COPY Gemfile* /tmp/
COPY addons /tmp/addons
WORKDIR /tmp
RUN bundle install
RUN rm -rf addons
ENV BUNDLE_PATH /usr/local/bundle/
# create app directory
ENV APP_HOME /usr/src/app
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
RUN mkdir addons
RUN ln -s $(readlink -f addons) /tmp
# container user
RUN groupadd scinote
RUN useradd -ms /bin/bash -g scinote scinote
USER scinote
CMD rails s -b 0.0.0.0

View file

@ -9,12 +9,15 @@ RUN apt-get update -qq && \
netcat \
default-jre-headless \
sudo graphviz --no-install-recommends \
sudo libfile-mimeinfo-perl && \
libfile-mimeinfo-perl && \
rm -rf /var/lib/apt/lists/*
ENV RAILS_ENV production
# install gems
COPY Gemfile* /tmp/
WORKDIR /tmp
COPY Gemfile* /usr/src/bundle/
COPY addons /usr/src/bundle/addons
WORKDIR /usr/src/bundle
RUN bundle install
# create app directory
@ -24,12 +27,10 @@ WORKDIR $APP_HOME
COPY . .
RUN rm -f $APP_HOME/config/application.yml $APP_HOME/production.env
ENV RAILS_ENV=production \
DATABASE_URL=postgresql://postgres@db/scinote_production \
RUN DATABASE_URL=postgresql://postgres@db/scinote_production \
PAPERCLIP_HASH_SECRET=dummy \
SECRET_KEY_BASE=dummy \
DEFACE_ENABLED=true
RUN bash -c "rake assets:precompile && rake deface:precompile"
DEFACE_ENABLED=true \
bash -c "rake assets:precompile && rake deface:precompile"
CMD rails s -b 0.0.0.0

View file

@ -10,6 +10,7 @@ ENABLE_TUTORIAL=true
ENABLE_RECAPTCHA=false
ENABLE_USER_CONFIRMATION=false
ENABLE_USER_REGISTRATION=true
DEFACE_ENABLED=false
endef
export PRODUCTION_CONFIG_BODY
@ -44,6 +45,9 @@ database:
database-production:
@$(MAKE) rails-production cmd="bash -c 'while ! nc -z db 5432; do sleep 1; done; rake db:create && rake db:migrate && rake db:seed'"
deface:
@$(MAKE) rails cmd="rake deface:precompile"
rails:
@docker-compose run --rm web $(cmd)
@ -53,7 +57,7 @@ rails-production:
run:
rm tmp/pids/server.pid || true
@docker-compose up -d
@docker attach $(shell docker-compose ps web | grep "rails s" | awk '{ print $$1; }')
@docker attach scinote_web_development
start:
@docker-compose start

View file

@ -1,4 +1,4 @@
version: '2.1'
version: '2'
services:
db:
container_name: scinote_db_production

View file

@ -1,22 +1,35 @@
version: '2'
services:
db:
container_name: scinote_db_development
image: postgres:9.4
volumes:
- scinote_development_postgres:/var/lib/postgresql/data
dbdata:
image: busybox
volumes:
- /var/lib/postgresql
command: "true"
web:
build:
context: .
dockerfile: Dockerfile
image: scinote_web_development
container_name: scinote_web_development
stdin_open: true
tty: true
depends_on:
- db
ports:
- "3000:3000"
command: >
bash -c "rm -f /usr/src/app/tmp/pids/server.pid &&
(bundle check || bundle install) &&
bundle exec rails s -b 0.0.0.0"
environment:
- RAILS_ENV=development
volumes:
- .:/usr/src/app
- scinote_development_bundler:/usr/local/bundle/
- scinote_development_files:/usr/src/app/public/system
db:
image: postgres:9.4
volumes_from:
- dbdata
web:
build: .
stdin_open: true
tty: true
ports:
- "3000:3000"
volumes:
- .:/usr/src/app
links:
- db
volumes:
scinote_development_postgres:
scinote_development_bundler:
scinote_development_files: