The step rake assets:precompile tries to connect to database and, as on build the links wasn't set yet, the build fails with:
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
My docker-compose.yml looks like:
web:
build: .
command: 'bash -c ''bundle exec puma -C config/puma.rb'''
working_dir: /app/user
environment:
PORT: 8080
DATABASE_URL: 'postgres://postgres:@herokuPostgresql:5432/postgres'
REDIS_URL: 'redis://herokuRedis:6379'
ports:
- '8080:8080'
links:
- herokuPostgresql
- herokuRedis
worker:
build: .
command: 'bash -c ''bundle exec sidekiq -C config/sidekiq.yml'''
working_dir: /app/user
environment:
DATABASE_URL: 'postgres://postgres:@herokuPostgresql:5432/postgres'
REDIS_URL: 'redis://herokuRedis:6379'
links:
- herokuPostgresql
- herokuRedis
shell:
build: .
command: bash
working_dir: /app/user
environment:
PORT: 8080
DATABASE_URL: 'postgres://postgres:@herokuPostgresql:5432/postgres'
REDIS_URL: 'redis://herokuRedis:6379'
ports:
- '8080:8080'
links:
- herokuPostgresql
- herokuRedis
volumes:
- '.:/app/user'
herokuPostgresql:
image: postgres
herokuRedis:
image: redis
The step
rake assets:precompiletries to connect to database and, as on build the links wasn't set yet, the build fails with:My
docker-compose.ymllooks like: