Files
grecia/docker-compose.yml
Javi Martín a6cda37113 Use environment variable for password in Docker
We were getting an error since we started using the postgres 9.6 image:

```
Attaching to app_1, database_1
database_1  | Error: Database is uninitialized and superuser password is not specified.
database_1  |        You must specify POSTGRES_PASSWORD to a non-empty value for the
database_1  |        superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
database_1  |
database_1  |        You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
database_1  |        connections without a password. This is *not* recommended.
database_1  |
database_1  |        See PostgreSQL documentation about "trust":
database_1  |        https://www.postgresql.org/docs/current/auth-trust.html
```
2021-04-23 12:23:17 +02:00

46 lines
1.3 KiB
YAML

version: "3"
services:
# service configuration for our database
database:
# use the preferred version of the official Postgres image
# see https://hub.docker.com/_/postgres/
image: postgres:9.6.21
environment:
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD
# persist the database between containers by storing it in a volume
volumes:
- docker-example-postgres:/var/lib/postgresql/data
# service configuration for our dockerized Rails app
app:
# use the Dockerfile next to this file
build: .
entrypoint: /usr/local/bin/entrypoint.sh
command: bundle exec rails s -p 3000 -b "0.0.0.0"
working_dir: /var/www/consul
# rely on the RAILS_ENV value of the host machine
# environment:
#RAILS_ENV: $RAILS_ENV
# makes the app container aware of the DB container
depends_on:
- database
# expose the port we configured Unicorn to bind to
ports:
- "3000:3000"
# map our application source code, in full, to the application root of our container
volumes:
- .:/var/www/consul:delegated
- bundle:/usr/local/bundle:delegated
- "$SSH_AUTH_SOCK:/tmp/agent.sock"
environment:
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD
- SSH_AUTH_SOCK=/tmp/agent.sock
volumes:
docker-example-postgres: {}
bundle: {}