version: "3.7" services: web: build: context: . target: builder # Even though CMD is defined in the Dockerfile, we need to provide a CMD here # because we are using a compose entrypoint. See https://github.com/docker/compose/issues/3140 command: rails server -p 3000 -b 0.0.0.0 depends_on: - db environment: - DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@db:5432/pokemon_trade_dev ports: - ${WEB_HOST_PORT}:3000 volumes: - type: bind source: . target: /app working_dir: /app db: environment: - POSTGRES_PASSWORD image: postgres:11.2-alpine ports: - ${DB_HOST_PORT}:5432 volumes: - postgres-persisted-volume:/var/lib/postgresql/data volumes: postgres-persisted-volume: