mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Created a bundler service that runs once removing responsibilities from any other services. The bundler service always runs install which should still be pretty fast if nothing or only a few gems have changed. A healthcheck won't work unless bundler runs continuously which is impractical. Instead, a checksum is generated on bundle install and sentinels in the other services have a definite confirmation that bundle is complete. The nice thing about this approach is that web, webpack, and sidekiq (which share the same bundles dependencies) will not concurrently run bundle install solving dep install redundancies.
This commit is contained in:
36
compose.yaml
36
compose.yaml
@@ -17,6 +17,18 @@ services:
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
|
||||
bundler:
|
||||
build: .
|
||||
# Runs once: installs gems into /bundles, writes a checksum sentinel, then exits
|
||||
command: >
|
||||
sh -lc 'bundle check || bundle install --jobs 4 --retry 3 --quiet;
|
||||
sha256sum Gemfile.lock > /bundles/.Gemfile.lock.sha'
|
||||
volumes:
|
||||
- .:/usr/src/app
|
||||
- gems:/bundles
|
||||
restart: "no"
|
||||
|
||||
web:
|
||||
tty: true
|
||||
stdin_open: true
|
||||
@@ -48,15 +60,17 @@ services:
|
||||
WEBPACKER_DEV_SERVER_PUBLIC: localhost:3035
|
||||
|
||||
command: >
|
||||
bash -c "rm -f tmp/pids/server.pid &&
|
||||
(bundle check || bundle install) &&
|
||||
bundle exec rails db:prepare &&
|
||||
yarn install &&
|
||||
bundle exec rails s -b 0.0.0.0 -p 3000"
|
||||
sh -lc 'rm -f tmp/pids/server.pid;
|
||||
until [ -f /bundles/.Gemfile.lock.sha ] && sha256sum -c /bundles/.Gemfile.lock.sha >/dev/null 2>&1; do sleep 0.5; done;
|
||||
bundle exec rails db:prepare &&
|
||||
yarn install &&
|
||||
exec bundle exec rails s -b 0.0.0.0 -p 3000'
|
||||
|
||||
sidekiq:
|
||||
build: .
|
||||
command: bundle exec sidekiq
|
||||
command: >
|
||||
sh -lc 'until [ -f /bundles/.Gemfile.lock.sha ] && sha256sum -c /bundles/.Gemfile.lock.sha >/dev/null 2>&1; do sleep 0.5; done;
|
||||
exec bundle exec sidekiq'
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
@@ -75,12 +89,20 @@ services:
|
||||
|
||||
webpack:
|
||||
build: .
|
||||
command: ./bin/webpack-dev-server
|
||||
command: >
|
||||
sh -lc 'until [ -f /bundles/.Gemfile.lock.sha ] && sha256sum -c /bundles/.Gemfile.lock.sha >/dev/null 2>&1; do sleep 0.5; done;
|
||||
exec ./bin/webpack-dev-server'
|
||||
ports:
|
||||
- "3035:3035"
|
||||
volumes:
|
||||
- .:/usr/src/app
|
||||
- gems:/bundles
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -qO- http://localhost:3035/webpack-dev-server >/dev/null || wget -qO- http://localhost:3035/sockjs-node/info >/dev/null"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 30
|
||||
|
||||
environment:
|
||||
WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
|
||||
volumes:
|
||||
|
||||
Reference in New Issue
Block a user