Skip to content

Commit 86662a3

Browse files
Merge pull request #67 from odissei-data/development
Development
2 parents c39f721 + 6544b2f commit 86662a3

37 files changed

+2823
-1699
lines changed

.github/workflows/docker-image.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,43 @@ on:
77

88
env:
99
TAG: $GITHUB_REF_NAME
10-
DOCKER_IMAGE_NAME: "dans-prefect"
1110
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
1211
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
13-
ORG: "dansknaw"
12+
ORG: "odissei"
1413

1514
jobs:
1615
build:
1716
runs-on: ubuntu-latest
1817

1918
steps:
20-
-
21-
name: Checkout
19+
- name: Checkout
2220
uses: actions/checkout@v4
2321
with:
2422
submodules: recursive
25-
-
26-
name: Login to Docker Hub
23+
24+
- name: Login to Docker Hub
2725
uses: docker/login-action@v3
2826
with:
2927
username: ${{ secrets.DOCKER_HUB_USERNAME }}
3028
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
31-
-
32-
name: Set up Docker Buildx
29+
30+
- name: Set up Docker Buildx
3331
uses: docker/setup-buildx-action@v3
34-
-
35-
name: Build and push
32+
33+
# Build and push the Prefect server image
34+
- name: Build and push Prefect Server Image
35+
uses: docker/build-push-action@v5
36+
with:
37+
context: .
38+
file: Dockerfile.server
39+
push: true
40+
tags: ${{ env.ORG }}/prefect:${{ github.ref_name }}
41+
42+
# Build and push the Prefect worker image
43+
- name: Build and push Prefect Worker Image
3644
uses: docker/build-push-action@v5
3745
with:
3846
context: .
39-
file: Dockerfile
47+
file: Dockerfile.worker
4048
push: true
41-
tags: dansknaw/dans-prefect:${{ github.ref_name }}
49+
tags: ${{ env.ORG }}/prefect-worker:${{ github.ref_name }}

Base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-slim
1+
FROM python:3.12-slim
22

33
ENV PYTHONPATH "${PYTHONPATH}:/app/scripts/"
44
ENV PYTHONDONTWRITEBYTECODE 1

Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

Dockerfile.server

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM python:3.11-slim
2+
3+
ENV PYTHONPATH="${PYTHONPATH}:/app/scripts/" \
4+
PYTHONDONTWRITEBYTECODE=1
5+
6+
EXPOSE 4200
7+
8+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
9+
10+
11+
RUN useradd -m -u 1000 -s /bin/bash prefect
12+
13+
WORKDIR /app
14+
15+
COPY pyproject.toml .
16+
RUN pip install poetry \
17+
&& poetry config virtualenvs.create false \
18+
&& poetry install --no-root
19+
20+
COPY entrypoint.sh /app/
21+
RUN chmod +x /app/entrypoint.sh
22+
23+
COPY scripts ./scripts
24+
COPY resources ./resources
25+
26+
RUN chown -R prefect:prefect /app
27+
28+
WORKDIR /app/scripts
29+
USER prefect
30+
31+
ENTRYPOINT ["/app/entrypoint.sh"]

Dockerfile.worker

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM python:3.11-slim
2+
3+
ENV PYTHONPATH="${PYTHONPATH}:/app/scripts/" \
4+
PYTHONDONTWRITEBYTECODE=1
5+
6+
EXPOSE 4200
7+
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
&& apt-get clean \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
RUN useradd -m -u 1000 -s /bin/bash prefect
13+
14+
WORKDIR /app
15+
16+
COPY pyproject.toml .
17+
RUN pip install poetry \
18+
&& poetry config virtualenvs.create false \
19+
&& poetry install --no-root
20+
21+
COPY entrypoint-worker.sh /app/
22+
RUN chmod +x /app/entrypoint-worker.sh
23+
24+
COPY scripts ./scripts
25+
COPY resources ./resources
26+
27+
RUN chown -R prefect:prefect /app
28+
29+
WORKDIR /app/scripts
30+
USER prefect
31+
32+
ENTRYPOINT ["/app/entrypoint-worker.sh"]

docker-compose.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
version: '3.7'
2-
31
services:
42
prefect:
53
build:
64
context: .
7-
dockerfile: Dockerfile
5+
dockerfile: Dockerfile.server
86
container_name: 'prefect'
97
volumes:
108
- "/tmp:/tmp"
@@ -16,12 +14,29 @@ services:
1614
- db
1715
networks:
1816
- prefect
17+
healthcheck:
18+
test: [ "CMD", "curl", "-f", "http://localhost:4200/api/health" ]
19+
interval: 15s
20+
timeout: 10s
21+
retries: 5
22+
23+
prefect-worker:
24+
container_name: 'prefect-worker'
25+
build:
26+
context: .
27+
dockerfile: Dockerfile.worker
28+
env_file: .env
29+
depends_on:
30+
prefect:
31+
condition: service_healthy
32+
networks:
33+
- prefect
1934

2035
db:
2136
image: postgres:latest
2237
container_name: db
2338
volumes:
24-
- ./db:/var/lib/postgresql/data
39+
- prefectdb:/var/lib/postgresql/data
2540
environment:
2641
- POSTGRES_USER=postgres
2742
- POSTGRES_PASSWORD=lolgres
@@ -31,3 +46,6 @@ services:
3146

3247
networks:
3348
prefect:
49+
50+
volumes:
51+
prefectdb:

dot_env_example

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
HOSTNAME="localhost"
22
PROJECT_CONTAINER_NAME="prefect"
33
# This python path is added to avoid having to do relative imports.
4-
PYTHONPATH="/scripts/"
4+
PYTHONPATH="/app/scripts/"
55
GITHUB_USERNAME="odissei-data"
66
DOCKERHUB_USERNAME="fjodorvr"
7-
VERSION="v2.4.3"
7+
VERSION="v3.0.1"
88
ENV_FOR_DYNACONF=development
99
PREFECT_SERVER_API_HOST='0.0.0.0'
1010
PREFECT_API_DATABASE_CONNECTION_URL="postgresql+asyncpg://username:password@db:5432/prefect"
11-
1211
POSTGRES_USER=postgres
1312
POSTGRES_PASSWORD=postgres
1413
POSTGRES_DB=prefect
1514
POSTGRES_PORT=5432
16-
POSTGRES_DB_URL=postgresql://postgres:postgres@database:5432/prefect
15+
API_URL=http://0.0.0.0:4200/api

entrypoint-worker.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
3+
prefect config set PREFECT_API_URL="http://prefect:4200/api"
4+
prefect worker start --pool default

entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
3+
prefect config set PREFECT_API_URL="${API_URL}"
4+
prefect config set PREFECT_UI_STATIC_DIRECTORY="/app/"
5+
prefect server start --host 0.0.0.0

0 commit comments

Comments
 (0)