docbrown/docker-compose.yml
Daniel Uber b35c1a575f
Add a minimal test database setup to the docker-compose file (#16305)
This provides a test environment database for anyone using a docker
based development environment.

Expose, rather than bind, the db port (you won't be able to connect to
the db externally, only from the container).

Add tmpfs storage (this alleviates an issue seen with carrierwave
attachments when trying to write to the tmp directory in the image).

Upgrade db versions from 11 to 13 (this is a breaking change for
anyone using this who had already provisioned the db, since no attempt
to upgrade has been provided, users may either downgrade to the
11-alpine image or recreate their storage volume). This is
separable (the `db` container was preexisting so is the only upgrade
conflict for users, the `testdb` container is newly created in a newly
added volume, and should not rely on persistence).

It's possible no volume is needed for the test db (only the schema
would normally be persisted, since data is truncated after normal test completion).
2022-01-31 09:22:38 -06:00

150 lines
4.7 KiB
YAML

version: "3"
services:
rails:
image: quay.io/forem/forem:development
container_name: forem_rails
user: root
ports:
- "3000:3000"
depends_on:
- bundle
- db
- redis
- yarn
- testdb
environment:
RAILS_ENV: development
DATABASE_URL: postgresql://forem:forem@db:5432/PracticalDeveloper_development
DATABASE_URL_TEST: postgresql://forem:forem@testdb:5432/Forem_test
REDIS_SESSIONS_URL: redis://redis:6379
REDIS_SIDEKIQ_URL: redis://redis:6379
REDIS_URL: redis://redis:6379
RACK_TIMEOUT_WAIT_TIMEOUT: 10000
RACK_TIMEOUT_SERVICE_TIMEOUT: 10000
STATEMENT_TIMEOUT: 10000
APP_DOMAIN: localhost:3000
tmpfs:
- /tmp
volumes:
- .:/opt/apps/forem:delegated
entrypoint: ["dockerize", "-wait", "tcp://db:5432", "-wait", "tcp://redis:6379", "-wait", "file:///opt/apps/forem/vendor/bundle/.bundle_finished", "-timeout", "2700s", "-wait-retry-interval", "10s"]
command: [ "bash", "-c", "./scripts/entrypoint.sh bootstrap && bundle exec rails server -b 0.0.0.0 -p 3000"]
bundle:
image: quay.io/forem/forem:development
container_name: forem_bundle
user: root
environment:
RAILS_ENV: development
REDIS_SESSIONS_URL: redis://redis:6379
REDIS_SIDEKIQ_URL: redis://redis:6379
REDIS_URL: redis://redis:6379
DATABASE_URL: postgresql://forem:forem@db:5432/PracticalDeveloper_development
volumes:
- .:/opt/apps/forem:delegated
command: ["./scripts/bundle.sh"]
yarn:
image: quay.io/forem/forem:development
container_name: forem_yarn
user: root
environment:
RAILS_ENV: development
REDIS_SESSIONS_URL: redis://redis:6379
REDIS_SIDEKIQ_URL: redis://redis:6379
REDIS_URL: redis://redis:6379
DATABASE_URL: postgresql://forem:forem@db:5432/PracticalDeveloper_development
volumes:
- .:/opt/apps/forem:delegated
command: yarn install --dev
webpacker:
image: quay.io/forem/forem:development
container_name: forem_webpacker
user: root
depends_on:
- bundle
- rails
- yarn
environment:
RAILS_ENV: development
REDIS_SESSIONS_URL: redis://redis:6379
REDIS_SIDEKIQ_URL: redis://redis:6379
REDIS_URL: redis://redis:6379
DATABASE_URL: postgresql://forem:forem@db:5432/PracticalDeveloper_development
volumes:
- .:/opt/apps/forem:delegated
entrypoint: ["dockerize", "-wait", "file:///opt/apps/forem/node_modules/.bin/webpack-dev-server", "-wait", "file:///opt/apps/forem/vendor/bundle/.bundle_finished", "-timeout", "2700s", "-wait-retry-interval", "10s"]
command: ["./bin/webpack-dev-server"]
seed:
image: quay.io/forem/forem:development
container_name: forem_seed
user: root
depends_on:
- rails
- redis
- db
environment:
RAILS_ENV: development
REDIS_SESSIONS_URL: redis://redis:6379
REDIS_SIDEKIQ_URL: redis://redis:6379
REDIS_URL: redis://redis:6379
DATABASE_URL: postgresql://forem:forem@db:5432/PracticalDeveloper_development
volumes:
- .:/opt/apps/forem:delegated
entrypoint: ["dockerize", "-wait", "tcp://db:5432", "-wait", "tcp://redis:6379", "-wait", "tcp://rails:3000", "-timeout", "2700s", "-wait-retry-interval", "20s"]
command: ["bundle", "exec", "rake","db:seed"]
sidekiq:
image: quay.io/forem/forem:development
container_name: forem_sidekiq
user: root
depends_on:
- rails
- redis
- db
environment:
RAILS_ENV: development
REDIS_SESSIONS_URL: redis://redis:6379
REDIS_SIDEKIQ_URL: redis://redis:6379
REDIS_URL: redis://redis:6379
DATABASE_URL: postgresql://forem:forem@db:5432/PracticalDeveloper_development
volumes:
- .:/opt/apps/forem:delegated
entrypoint: ["dockerize", "-wait", "tcp://db:5432", "-wait", "tcp://redis:6379", "-wait", "tcp://rails:3000", "-timeout", "2700s", "-wait-retry-interval", "20s"]
command: ["bundle", "exec", "sidekiq","-c","2"]
db:
image: postgres:13-alpine
container_name: forem_postgresql
environment:
POSTGRES_USER: forem
POSTGRES_PASSWORD: forem
POSTGRES_DB: PracticalDeveloper_development
ports:
- "5432:5432"
volumes:
- db_data:/var/lib/postgresql/data:delegated
testdb:
image: postgres:13-alpine
container_name: forem_postgresql_test
environment:
POSTGRES_USER: forem
POSTGRES_PASSWORD: forem
POSTGRES_DB: Forem_test
expose:
- "5432"
volumes:
- testdb_data:/var/lib/postgresql/data:delegated
redis:
image: redis:6.0.9-alpine
container_name: forem_redis
ports:
- "6379:6379"
volumes:
db_data:
testdb_data: