Hello. I have been fighting with this problem for 1 month, and cant find solution. I got docker app with django and postgres inside. Im working with this app localy with no problem, my connection with database is normal. When i try to run travis ci, script is falling with error:
warnings.warn(
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/usr/local/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/db/backends/[secure]ql/base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at "db" (172.18.0.2), port 5432 failed: fe_sendauth: no password supplied
I got hidden enviroment variables in travis config. Here you can find my docker and travis config. To be honest, i dont know what else i could show you, becouse my app is working fine, just falling on travis.
.travis.yml
python:
- "3.9"
services:
- docker
before_script: pip install docker-compose
script:
# - docker-compose pull && docker-compose build
- docker-compose run electronicshop sh -c "python manage.py wait_for_db && python manage.py test && flake8"
docker-compose.yml
services:
electronicshop:
image: electronicshop
build:
context: .
dockerfile: ./Dockerfile
ports:
- "8000:8000"
volumes:
- .:/electronic_shop
command: >
sh -c "while !</dev/tcp/db/5432; do sleep 1; done;
python manage.py wait_for_db &&
python manage.py migrate &&
python manage.py runserver 0.0.0.0:8000"
environment:
- DB_HOST=db
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASS=${DB_PASSWORD}
- SECRET_KEY=${SECRET_KEY}
# - DEBUG=1
depends_on:
- db
restart: always
db:
image: postgres:14.1-alpine
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
ports:
- 5454:5454/tcp
restart: always
# healthcheck:
# test: ["CMD-SHELL", "pg_isready -U postgres"]
# interval: 5s
# timeout: 5s
# retries: 5
Im so tired of travis problems. I hope someone will help me.
PS. here is my build: