Fix sidekiq init script (#13)

* Fix sidekiq init script

* Re-evaluate `git clone` if snpr's master changed

* Pass along SNPR_REV env var to docker

* Find out snpr commit hash if not passed in

* Only build "rails" image explicitly

* Make the sidekiq init script work

* Fix migrate init script

* Simplify Dockerfile
This commit is contained in:
Helge Rausch
2018-01-19 20:18:05 +01:00
committed by Bastian Greshake Tzovaras
parent dbca6b2595
commit c3eef3525d
6 changed files with 20 additions and 10 deletions

View File

@@ -24,6 +24,9 @@ RUN rm -f /etc/service/nginx/down
ADD db_migrate.sh /etc/my_init.d/90_db_migrate.sh
# If SNPR_REV changed, re-evaluate from here.
ARG SNPR_REV
RUN git clone --depth=1 https://github.com/openSNP/snpr.git /home/app/snpr
WORKDIR /home/app/snpr
RUN git rev-parse HEAD > REVISION

View File

@@ -1,4 +1,5 @@
#!/bin/bash
#!/bin/sh
cd /home/app/webapp
chpst -u app bundle exec rake db:migrate
exec 2>&1
exec bash -l -c 'chpst -u app bundle exec rake db:migrate'

View File

@@ -2,7 +2,10 @@ version: '3'
services:
rails:
build: '.'
build:
context: '.'
args:
- 'SNPR_REV'
image: 'opensnp/rails'
ports:
- '8080:80'

View File

@@ -3,12 +3,8 @@ FROM opensnp/rails
RUN mkdir /var/run/sidekiq
RUN chown app:app /var/run/sidekiq
RUN touch /etc/service/nginx/down
ADD sidekiq-run /etc/service/sidekiq/run
ADD sidekiq-run /etc/my_init.d/92_sidekiq.sh
USER app
RUN bash -l -c 'bundle exec whenever --update-crontab'
RUN bash -l -c 'cd $(bundle show recommendify); \
bundle install --path /tmp/recommendify-bundle; \
bundle exec rake build_native; \
rm -rf /tmp/recommendify-bundle'
RUN bash -l bin/build_native_recommendify
USER root

View File

@@ -2,4 +2,4 @@
cd /home/app/snpr
exec 2>&1
exec chpst -U app:app bundle exec sidekiq -e production -P /var/run/sidekiq/sidekiq.pid
exec bash -l -c 'chpst -u app bundle exec sidekiq -e production -P /var/run/sidekiq/sidekiq.pid'

View File

@@ -5,6 +5,13 @@ POSTGRES_DATA_DIR=test/postgres-data
set -x
mkdir $POSTGRES_DATA_DIR
snpr_rev="$SNPR_REV"
if [ -z "$snpr_rev" ]; then
snpr_rev=$(git ls-remote https://github.com/opensnp/snpr master | cut -f 1)
fi
docker-compose build --build-arg SNPR_REV=$snpr_rev rails
docker-compose up -d
i=10