I am trying to run Telegram bot on Aiogram Python with PostgreSQL database on Ubuntu 20.04 server in Docker using docker-compose. The script runs, but I get
asyncpg.exceptions.InvalidPasswordError: password authentication failed for user "steamtrader_pguser"
Here is my docker-compose.yml file:
version: "3.1"
services:
steamtraderpurchases_db:
container_name: steamtraderpurchases_db
image: sameersbn/postgresql:10-2
environment:
PG_PASSWORD: $PGPASSWORD
restart: always
ports:
- 5432:5432
networks:
- steamtraderpurchases_botnet
volumes:
- ./pgdata:/var/lib/postgresql
steamtraderpurchases_bot:
container_name: steamtraderpurchases
build:
context: .
command: python app.py
restart: always
networks:
- steamtraderpurchases_botnet
env_file:
- ".env"
volumes:
- .:/src
depends_on:
- steamtraderpurchases_db
ports:
- 8443:3001
networks:
steamtraderpurchases_botnet:
driver: bridge
Here is the Dockerfile:
FROM python:3.9.5
WORKDIR /src
COPY requirements.txt /src
RUN pip install -r requirements.txt
COPY . /src
In the .env file I have specified:
DATABASE=steamtrader
PGUSER=steamtrader_pguser
PGPASSWORD=password
DB_HOST=steamtraderpurchases_db
IP=*ip of my server*
The rest of the code is a Telegram bot. Also, I create a database with the required fields using SQLAlchemy and Gino. This is my first time trying to run a bot on the server, so I will be very grateful for your help!
UPD: I found these lines in the logs when running docker-compose:
FATAL: password authentication failed for user "steamtrader_pguser"
DETAIL: Role "steamtrader_pguser" does not exist.
I tried to create a role but nothing worked