-
Hello! Here is my picolo_conf.py:
My env file is standard:
I need help with correct syntax and methods to solve this error. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
In my apps I do something like this (reading the environment variables defined by Docker): import os
from piccolo.conf.apps import AppRegistry
from piccolo.engine.postgres import PostgresEngine
DB = PostgresEngine(
config={
"port": int(os.environ.get("DB_PORT", "5432")),
"user": os.environ.get("POSTGRES_USER", "postgres"),
"password": os.environ.get("POSTGRES_PASSWORD", ""),
"database": os.environ.get("DB_NAME", "my_app"),
"host": os.environ.get("DB_HOST", "localhost"),
}
) If using a .env file, I do the same, but I run import os
from dotenv import load_dotenv
from piccolo.conf.apps import AppRegistry
from piccolo.engine.postgres import PostgresEngine
load_dotenv()
DB = PostgresEngine(
config={
"port": int(os.environ.get("DB_PORT", "5432")),
"user": os.environ.get("POSTGRES_USER", "postgres"),
"password": os.environ.get("POSTGRES_PASSWORD", ""),
"database": os.environ.get("DB_NAME", "my_app"),
"host": os.environ.get("DB_HOST", "localhost"),
}
) If you're still getting that error, then |
Beta Was this translation helpful? Give feedback.
-
Still nothing.
.env:
piccolo_conf.py:
Here is my files. They are on the same level in a structure. Maybe I can't see some stupid mistake, but I suppose everything is correct here. BTW, when I changed piccolo_conf.py as in your example, I started getting only this error: backend_1 | Unable to connect to the database . Without [Errno 111] Connect call failed ('127.0.0.1', 5432). |
Beta Was this translation helpful? Give feedback.
-
Hello! Finally, I did it. I created a new file, docker-entrypoint.sh . At the same level as my Dockerfile and docker-compose.yml.
Changed my Dockerfile.
.env.
piccolo_conf.py
docker-compose.yml
Deleted all old containers and images. Then make docker-compose up --build . ( I made without -d key to see is there any errors). There were no errors, so I did |
Beta Was this translation helpful? Give feedback.
Hello! Finally, I did it.
I created a new file, docker-entrypoint.sh . At the same level as my Dockerfile and docker-compose.yml.
Changed my Dockerfile.