Skip to content

Commit 1f7bfc6

Browse files
committed
feat: update the prefect stack
1 parent 7ba0f6f commit 1f7bfc6

1 file changed

Lines changed: 99 additions & 72 deletions

File tree

Lines changed: 99 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,108 @@
11
version: "3.9"
22

33
services:
4-
database:
5-
image: postgres:15-alpine
6-
environment:
7-
- POSTGRES_USER=prefect
8-
- POSTGRES_PASSWORD=${PREFECT_DB_PASSWORD}
9-
- POSTGRES_DB=prefect
10-
volumes:
11-
- db-data:/var/lib/postgresql/data
12-
networks:
13-
prefect-internal:
14-
aliases:
15-
- database
16-
healthcheck:
17-
test: ["CMD-SHELL", "pg_isready -d prefect -U prefect"]
18-
interval: 10s
19-
timeout: 5s
20-
retries: 5
21-
deploy:
22-
placement:
23-
constraints:
24-
- node.labels.database == true
25-
restart_policy:
26-
condition: any
4+
database:
5+
image: postgres:15-alpine
6+
environment:
7+
- POSTGRES_USER=prefect
8+
- POSTGRES_PASSWORD=${PREFECT_DB_PASSWORD}
9+
- POSTGRES_DB=prefect
10+
volumes:
11+
- db-data:/var/lib/postgresql/data
12+
networks:
13+
prefect-internal:
14+
aliases:
15+
- database
16+
healthcheck:
17+
test: ["CMD-SHELL", "pg_isready -d prefect -U prefect"]
18+
interval: 10s
19+
timeout: 5s
20+
retries: 5
21+
deploy:
22+
placement:
23+
constraints:
24+
- node.labels.database == true
25+
restart_policy:
26+
condition: any
2727

28-
server:
29-
image: prefecthq/prefect:2-python3.11
30-
command: prefect server start
31-
environment:
32-
- PREFECT_UI_API_URL=https://prefect.${BASE_DOMAIN}/api
33-
- PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://prefect:${PREFECT_DB_PASSWORD}@database:5432/prefect
34-
- PREFECT_SERVER_API_HOST=0.0.0.0
35-
# Allow ephemeral containers to be created on the host
36-
- PREFECT_DOCKER_MODE=true
37-
volumes:
38-
- prefect-config:/root/.prefect
39-
networks:
40-
- prefect-internal
41-
- traefik-public
42-
ports:
43-
- "4200:4200"
44-
depends_on:
45-
- database
46-
deploy:
47-
labels:
48-
- "traefik.enable=true"
49-
- "traefik.http.routers.prefect.rule=Host(`prefect.${BASE_DOMAIN}`)"
50-
- "traefik.http.routers.prefect.entrypoints=websecure"
51-
- "traefik.http.routers.prefect.tls.certresolver=dns"
52-
- "traefik.http.services.prefect.loadbalancer.server.port=4200"
53-
- "traefik.swarm.network=traefik-public"
28+
server:
29+
image: prefecthq/prefect:3-python3.11
30+
command: prefect server start
31+
environment:
32+
- PREFECT_UI_API_URL=https://prefect.${BASE_DOMAIN}/api
33+
- PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://prefect:${PREFECT_DB_PASSWORD}@database:5432/prefect
34+
- PREFECT_SERVER_API_HOST=0.0.0.0
35+
# Allow ephemeral containers to be created on the host
36+
- PREFECT_DOCKER_MODE=true
37+
volumes:
38+
- prefect-config:/root/.prefect
39+
networks:
40+
- prefect-internal
41+
- traefik-public
42+
ports:
43+
- "4200:4200"
44+
depends_on:
45+
- database
46+
deploy:
47+
labels:
48+
- "traefik.enable=true"
49+
- "traefik.http.routers.prefect.rule=Host(`prefect.${BASE_DOMAIN}`)"
50+
- "traefik.http.routers.prefect.entrypoints=websecure"
51+
- "traefik.http.routers.prefect.tls.certresolver=dns"
52+
- "traefik.http.services.prefect.loadbalancer.server.port=4200"
53+
- "traefik.swarm.network=traefik-public"
5454

55-
- "homepage.group=Development"
56-
- "homepage.name=Prefect"
57-
- "homepage.icon=prefect.png"
58-
- "homepage.href=https://prefect.${BASE_DOMAIN}/"
59-
- "homepage.description=Workflow Orchestration & ML Pipelines"
60-
restart_policy:
61-
condition: any
55+
- "homepage.group=Development"
56+
- "homepage.name=Prefect"
57+
- "homepage.icon=prefect.png"
58+
- "homepage.href=https://prefect.${BASE_DOMAIN}/"
59+
- "homepage.description=Workflow Orchestration & ML Pipelines"
60+
restart_policy:
61+
condition: any
62+
63+
worker:
64+
image: prefecthq/prefect:3-python3.11
65+
command: >
66+
sh -c "pip install prefect-docker --quiet &&
67+
prefect worker start --pool $${PREFECT_WORK_POOL}"
68+
environment:
69+
- PREFECT_API_URL=http://server:4200/api
70+
- PREFECT_WORK_POOL=${PREFECT_WORK_POOL:-crime-pipeline-docker}
71+
volumes:
72+
- type: bind
73+
source: /var/run/docker.sock
74+
target: /var/run/docker.sock
75+
- type: bind
76+
source: /home/chutchens/.docker/config.json
77+
target: /root/.docker/config.json
78+
read_only: true
79+
networks:
80+
- prefect-internal
81+
depends_on:
82+
- server
83+
deploy:
84+
restart_policy:
85+
condition: any
86+
placement:
87+
constraints:
88+
- node.labels.gpu == true # Hack to deploy the worker on one of my bigger machines
6289

6390
networks:
64-
prefect-internal:
65-
driver: overlay
66-
traefik-public:
67-
external: true
91+
prefect-internal:
92+
driver: overlay
93+
traefik-public:
94+
external: true
6895

6996
volumes:
70-
db-data:
71-
driver: local
72-
driver_opts:
73-
type: "none"
74-
o: "bind"
75-
device: "/mnt/iscsi/app-data/prefect/postgresql"
76-
prefect-config:
77-
driver: local
78-
driver_opts:
79-
type: "none"
80-
o: "bind"
81-
device: "/mnt/iscsi/app-data/prefect/config"
97+
db-data:
98+
driver: local
99+
driver_opts:
100+
type: "none"
101+
o: "bind"
102+
device: "/mnt/iscsi/app-data/prefect/postgresql"
103+
prefect-config:
104+
driver: local
105+
driver_opts:
106+
type: "none"
107+
o: "bind"
108+
device: "/mnt/iscsi/app-data/prefect/config"

0 commit comments

Comments
 (0)