Files
openfoodnetwork/docker-compose.yml
Pau Perez 5ddfc54b2b Install any missing gems when booting docker
This runs `bundle install` if there are any missing gems when booting
the containers. `bundle check` ensures we don't unnecessarily run
`bundle install`, which is rather slow.

This avoids having to build the entire image (painfully slow) or having
to bring up a container just to install the gems. I used to do this
with `docker-compose run --rm web bundle install`.
2020-11-10 18:08:34 +01:00

56 lines
1.3 KiB
YAML

version: '3'
services:
db:
image: postgres:9.5
restart: always
environment:
POSTGRES_PASSWORD: f00d
POSTGRES_USER: ofn
POSTGRES_DB: open_food_network_dev
ports:
- 5432:5432
volumes:
- 'postgres:/var/lib/postgresql/data'
web:
tty: true
stdin_open: true
build: .
ports:
- 3000:3000
volumes:
- .:/usr/src/app
- gems:/bundles
- ./config/database.yml:/usr/src/app/config/database.yml
- ./config/application.yml.example:/usr/src/app/config/application.yml
depends_on:
- db
environment:
OFN_DB_HOST: db
command: >
bash -c "wait-for-it -t 30 db:5432 &&
rm -f tmp/pids/server.pid &&
(bundle check || bundle install)
yarn install &&
bundle exec rails s -p 3000 -b '0.0.0.0'"
worker:
tty: true
stdin_open: true
build: .
volumes:
- .:/usr/src/app
- gems:/bundles
- ./config/database.yml:/usr/src/app/config/database.yml
- ./config/application.yml.example:/usr/src/app/config/application.yml
depends_on:
- db
environment:
OFN_DB_HOST: db
command: >
bash -c "wait-for-it -t 30 db:5432 &&
(bundle check || bundle install)
bundle exec rake jobs:work"
volumes:
gems:
postgres: