John Epperson
Ruby Developer since 2007
The Good, The Bad, The Ugly
John Epperson
Opinions Ahead
base: &base
build:
context: .
args:
- APP_NAME=${APP_NAME}
- GITHUB_TOKEN=${GITHUB_TOKEN}
- RAILS_MASTER_KEY=${RAILS_MASTER_KEY}
tty: true
stdin_open: true
env_file: .env
depends_on:
- db
- redis
volumes:
- ./:/var/www/example
- /var/www/example/tmp/
- bundle:/usr/local/bundle
app:
<<: *base
container_name: 'example-app'
image: example_base:latest
command: dockerize -wait http://bundler:23480 -wait http://yarn:23480 -timeout ${DEPENDENCY_TIMEOUT} bin/start_development_web_server
ports:
- '${HOST_PORT}:3000'
# workers:
# webpacker:
# test:
# bundler:
yarn:
<<: *baseExtract Reusable portions into anchors
Extract any commonly changed files into volumes
services:
base: &base
..
volumes:
- ./:/var/www/example
- /var/www/example/tmp/
- bundle:/usr/local/bundle
app:
<<: *base
..
# workers:
# webpacker:
# test:
# bundler:
# yarn:
db:
image: postgres:11.3
volumes:
- postgresdata:/var/lib/postgresql/data
- postgresconfig:/etc/postgresql
- postgreslog:/var/log/postgresql
- ./:/var/www/example
volumes:
bundle:
postgresdata:
postgresconfig:
postgreslog:Use some version of wait_for for any services that you need to wait on (e.g. any package manager)
app:
<<: *base
command: >
dockerize -wait http://bundler:23480 -wait http://yarn:23480
-timeout ${DEPENDENCY_TIMEOUT} bin/start_development_web_server
workers:
<<: *base
command: dockerize -wait http://bundler:23480 -timeout ${DEPENDENCY_TIMEOUT} bin/start_sidekiq
webpacker:
<<: *base
command: dockerize -wait http://bundler:23480 -wait http://yarn:23480 -timeout ${DEPENDENCY_TIMEOUT} bin/start_docker_webpacker_server
test:
<<: *base
command: dockerize -wait http://bundler:23480 -wait http://yarn:23480 -timeout ${DEPENDENCY_TIMEOUT} bin/setup_test_env
environment:
- NODE_ENV=test
- RAILS_ENV=test
bundler:
<<: *base
command: bin/update_bundle
yarn:
<<: *base
command: bin/update_yarnservices:
app:
tty: true
stdin_open: trueservices:
db:
environment:
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
- POSTGRES_USER=${DATABASE_USERNAME}
ports:
- '${HOST_POSTGRES_PORT}:5432'
webpacker:
ports:
- '${HOST_WEBPACKER_PORT}:3035'
app:
ports:
- '${HOST_PORT}:3000'Github:
Shiplane:
Twitter:
Email:
Charlotte Devs Slack:
(With cute kid pics!)
By John Epperson