docker-compose.yml
# docker-compose.yml
version: '3.8'
networks:
sapi:
driver: bridge
services:
db:
container_name: sapi-db
image: postgres:10
command: postgres -c max_wal_size=2GB
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
timeout: 45s
interval: 10s
retries: 10
volumes:
- 'pgdata:/var/lib/postgresql/data'
ports:
- "${SAPI_CONTAINER_DB_PORT:-5432}:5432"
networks:
- sapi
environment:
POSTGRES_HOST_AUTH_METHOD: "trust"
POSTGRES_DB: "sapi_development"
deploy:
container_name: sapi-cap-deploy
build:
context: ./
dockerfile: Dockerfile.cap-deploy
volumes:
- '.:/SAPI'
networks:
- sapi
stdin_open: true
tty: true
secrets:
- host_ssh_key
- host_ssh_config
rails:
container_name: sapi-rails
build:
context: ./
dockerfile: Dockerfile
command: /bin/bash -l -c "rm -f ./tmp/pids/server.pid && bundle install && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- '.:/SAPI'
- bundler_gems:/usr/local/bundle
ports:
- '${SAPI_CONTAINER_RAILS_PORT:-3000}:3000'
networks:
- sapi
stdin_open: true
tty: true
environment:
MAILER_ADDRESS: sapi-mailcatcher
MEMCACHE_SERVERS: sapi-memcached:11211
SAPI_DATABASE_HOST: sapi-db
SAPI_SIDEKIQ_REDIS_URL: redis://sapi-redis:6379/0
depends_on:
- redis
- db
- mailcatcher
- memcached
redis:
container_name: sapi-redis
image: redis:7.2.0
ports:
- "${SAPI_CONTAINER_REDIS_PORT:-6379}:6379"
networks:
- sapi
command: redis-server --save 20 1 --loglevel warning
volumes:
- redis_data:/data
sidekiq:
container_name: sapi-sidekiq
build:
context: .
dockerfile: Dockerfile
networks:
- sapi
depends_on:
- db
- redis
- mailcatcher
- memcached
command: /bin/bash -l -c "bundle install && bundle exec sidekiq -C config/sidekiq.yml"
volumes:
- '.:/SAPI'
- bundler_gems:/usr/local/bundle
environment:
MAILER_ADDRESS: sapi-mailcatcher
MEMCACHE_SERVERS: sapi-memcached:11211
SAPI_DATABASE_HOST: sapi-db
SAPI_SIDEKIQ_REDIS_URL: redis://sapi-redis:6379/0
mailcatcher:
container_name: sapi-mailcatcher
image: sj26/mailcatcher
ports:
- "${SAPI_CONTAINER_MAILCATCHER_PORT:-1080}:1080"
networks:
- sapi
memcached:
container_name: sapi-memcached
image: memcached:1.6
ports:
- "${SAPI_CONTAINER_MEMCACHE_PORT:-11211}:11211"
networks:
- sapi
volumes:
pgdata:
bundler_gems:
redis_data:
secrets:
host_ssh_key:
file: ~/.ssh/id_ed25519
host_ssh_config:
file: ~/.ssh/config