version: '3.1' volumes: postgres-data: driver: local redis-data: driver: local gems: driver: local networks: front-tier: driver: bridge back-tier: driver: bridge services: rspec: image: ruby:2.4 working_dir: /usr/src/app stdin_open: true tty: true volumes: - .:/usr/src/app - gems:/usr/local/bundle entrypoint: /usr/src/app/dev-entrypoint.sh command: bundle exec rspec networks: - back-tier - front-tier depends_on: - postgres - redis environment: PATH: /usr/src/app/bin:/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin REDIS_URL: redis://redis:6379 DATABASE_URL: postgresql://postgres:3x4mpl3@postgres:5433/rails_example_test RAILS_ENV: test RACK_ENV: test redis: image: redis:latest ports: # We'll bind our host's port 6379 to redis's port 6379, so we can use # Redis Desktop Manager (or other tools) with it: - 6379:6379 volumes: # We'll store the redis data in the 'redis-data' volume we defined: - redis-data:/var/lib/redis command: redis-server --appendonly yes # Make the redis service available only on the "back-tier" network: # NOTE: See networks comment on the postgres service above. networks: [ "back-tier" ] postgres: image: postgres:latest ports: # We'll bind our host's port 5432 to postgres's port 5432, so we can use # our database IDEs with it: - 5433:5433 volumes: # We'll store the postgres data in the 'postgres-data' volume we defined: - postgres-data:/var/lib/postgresql/data networks: # Make the database service available only on the "back-tier" network: # NOTE: Although the service is available only on the "back-tier" network, # the host-to-container port binding we've defined for development # purposes will allow connection from the development host. - back-tier environment: POSTGRES_PASSWORD: 3x4mpl3