Search code examples
dockerconfigureprefect

How to configure Prefect backend server to point to Postgres


Having difficulties configuring Prefect to run locally. Installed via pip3, depends on docker(already installed) and docker-compose, installed, tested. works.
I already have a running Postgres server, I like to configure to use that one. But it seems like one is used in docker too ? Any help is appreciated.

When running:

prefect backend server 
prefect server start

nable to find image 'docker/compose:1.27.4' locally
1.27.4: Pulling from docker/compose (downloads en starts running docker)

Status: Downloaded newer image for docker/compose:1.27.4
WARNING: The PREFECT_SERVER_DB_CMD variable is not set. Defaulting to a blank string
WARNING: The DB_CONNECTION_URL variable is not set. Defaulting to a blank string
WARNING: The POSTGRES_DB variable is not set. Defaulting to a blank
WARNING: The POSTGRES_PASSWORD variable is not set. Defaulting to a blank string >
WARNING: The POSTGRES_USER variable is not set. Defaulting to a blank string.


Solution

  • The problem I encountered has to do with the way a subprocess is started in Python, Popen( docker-compose up, env=env ) The (current) environment variables are passed when running this command but in some way not available in the child task.

    docker-compose up
    

    I adjusted the server.py code and create an .env file on the fly. To test and docker-compose finds and uses it.

    The real problem lies within the bash/sh terminal environment and thats where I need to take a closer look.