Hi! I’m trying to deploy a flow to run on a self-h...
# prefect-docker
s
Hi! I’m trying to deploy a flow to run on a self-hosted Prefect server following this guide https://docs.prefect.io/latest/guides/docker/. I’ve been able to successfully build and run the image but I’m having trouble figuring out how to deploy the image to our remote server successfully and also how to trigger the flow from the remote server without it being dependent on my local machine. Any advice/documentation you could point me to?
m
Joined here to ask this. Did you ever figure it out?
s
@Miguel Martinez no I didn’t 😕
m
I was able to deploy the stack to the remote server by using this docker-compose.yml
Copy code
services:
  server:
    container_name: prefect-server
    image: prefecthq/prefect:2-python3.10
    restart: unless-stopped
    volumes:
      - ./server:/root/.prefect
      - /home/data/flows:/opt/prefect/flows
    entrypoint: ["prefect", "server", "start"]
    # command: bash -c "python /opt/prefect/flows/deployment-local.py"
    environment:
      - PREFECT_SERVER_API_HOST=0.0.0.0
      - PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://postgres:postgres@db:5432/prefect>
    #   - PREFECT_API_URL="<http://127.0.0.1:4210/api>"
    #   - PREFECT_UI_URL=<http://127.0.0.1:4200/api>
    ports:
      - 4200:4200
    depends_on:
      - db
      
  agent:
    container_name: prefect-agent
    image: prefecthq/prefect:2-python3.10
    restart: unless-stopped
    entrypoint: ["/opt/prefect/entrypoint.sh", "prefect", "agent", "start", "-q", "default"]
    environment:
      - PREFECT_API_URL=<http://server:4200/api>
#       Use PREFECT_API_KEY if connecting the agent to Prefect Cloud
#     - PREFECT_API_KEY=YOUR_API_KEY
    depends_on:
      - server
      
  db:
    container_name: prefect-database
    image: postgres:16-bookworm
    restart: unless-stopped
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=prefect
    expose:
      - 5432
    volumes: 
      - ./postgres:/var/lib/postgresql/data
then running
docker compose up -d
but not quite sure how to create deployment on the remote... 😕 +1
s
Yes this is where I am too 🙃. I have someone I can reach out to (work priorities shifted) but I’ll let you know if I hear anything good
👍 1
s
You should start client container to make deployment in docker network. https://github.com/rpeden/prefect-docker-compose/blob/main/README.md But! There are no any DBT libraries in images and packages for DBT too.
thank you 1