Skip to content

Commit 18db20f

Browse files
Merge pull request #405 from hotosm/feature/offline-prediction
Feature : Docker optimization and offline prediction
2 parents 97db033 + a56c30c commit 18db20f

File tree

600 files changed

+4711
-37137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

600 files changed

+4711
-37137
lines changed

.dockerignore

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Ignore Python cache and virtualenv files
2+
__pycache__/
3+
*.py[cod]
4+
*.pyo
5+
*.pyd
6+
*.pyc
7+
*.pyo
8+
.Python
9+
env/
10+
venv/
11+
ENV/
12+
VENV/
13+
*.env
14+
*.venv
15+
16+
backend/env/
17+
backend/venv/
18+
backend/ENV/
19+
backend/VENV/
20+
backend/*.env
21+
backend/*.venv
22+
23+
24+
# Ignore pip and poetry files/directories
25+
pip-log.txt
26+
pip-delete-this-directory.txt
27+
poetry.lock
28+
29+
# Ignore Django static/media output (customize as needed)
30+
static/
31+
media/
32+
33+
# Ignore test and coverage artifacts
34+
.coverage
35+
.tox/
36+
.nox/
37+
.pytest_cache/
38+
htmlcov/
39+
.coverage.*
40+
.cache
41+
.mypy_cache/
42+
.dmypy.json
43+
.pyre/
44+
.pytype/
45+
46+
# Ignore log files
47+
*.log
48+
49+
# Ignore IDE/editor files
50+
.vscode/
51+
.idea/
52+
*.sublime-workspace
53+
*.sublime-project
54+
*.swp
55+
*.swo
56+
57+
# Ignore OS files
58+
.DS_Store
59+
Thumbs.db
60+
61+
# Ignore frontend build and dependency directories
62+
frontend/node_modules/
63+
frontend/build/
64+
frontend/dist/
65+
frontend/.env
66+
frontend/.next/
67+
frontend/.cache/
68+
frontend/.turbo/
69+
70+
# Ignore backend specific (if any)
71+
backend/node_modules/
72+
backend/staticfiles/
73+
backend/.env
74+
backend/.venv
75+
backend/.pytest_cache/
76+
backend/migrations/
77+
backend/db.sqlite3
78+
79+
# Ignore git
80+
.git/
81+
.gitignore
82+
83+
# Ignore Docker files themselves (don't copy into image)
84+
Dockerfile
85+
backend/Dockerfile.*
86+
frontend/Dockerfile.*
87+
.dockerignore
88+
89+
# Ignore miscellaneous
90+
*.sqlite3
91+
*.db
92+
*.bak
93+
*.orig
94+
*.tmp
95+
tmp/
96+
*.pem
97+
*.crt
98+
*.key
99+
*.lock

.github/workflows/backend_build.yml

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

.github/workflows/docker_build.yml

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Docker Images for backend
1+
name: Build Docker Images
22

33
on:
44
push:
@@ -23,11 +23,12 @@ env:
2323
IMAGE_NAME: ${{ github.repository }}
2424

2525
jobs:
26-
build-and-push-api-image:
26+
build-api-image:
2727
runs-on: ubuntu-latest
2828
permissions:
2929
contents: read
3030
packages: write
31+
actions: write
3132
steps:
3233
- name: Remove unnecessary files
3334
run: |
@@ -56,20 +57,24 @@ jobs:
5657
uses: docker/build-push-action@v6
5758
with:
5859
context: backend/
59-
file: backend/Dockerfile_CPU
60+
file: backend/Dockerfile.API
6061
push: false
6162
tags: ${{ steps.meta_api.outputs.tags }}
6263
labels: ${{ steps.meta_api.outputs.labels }}
6364
cache-from: type=gha,scope=api,timeout=20m
6465
cache-to: type=gha,mode=max,scope=api,timeout=20m,ignore-error=true
6566
github-token: ${{ secrets.GITHUB_TOKEN }}
6667

67-
build-and-push-worker-image:
68-
needs: build-and-push-api-image
68+
build-worker-image:
69+
needs: build-api-image
6970
runs-on: ubuntu-latest
71+
strategy:
72+
matrix:
73+
build_type: [cpu, gpu]
7074
permissions:
7175
contents: read
7276
packages: write
77+
actions: write
7378
steps:
7479
- name: Remove unnecessary files
7580
run: |
@@ -89,19 +94,69 @@ jobs:
8994
id: meta_worker
9095
uses: docker/metadata-action@v5
9196
with:
92-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_worker
97+
images: |
98+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_worker
99+
tags: |
100+
type=raw,value=latest-${{ matrix.build_type }}
93101
94102
- name: Set up Docker Buildx
95103
uses: docker/setup-buildx-action@v3
96104

97-
- name: Build and push Worker Docker image
105+
- name: Build and push Worker Docker image (${{ matrix.build_type }})
98106
uses: docker/build-push-action@v6
99107
with:
100108
context: backend/
101-
file: backend/Dockerfile
109+
file: backend/Dockerfile.workers
102110
push: false
111+
build-args: |
112+
BUILD_TYPE=${{ matrix.build_type }}
103113
tags: ${{ steps.meta_worker.outputs.tags }}
104114
labels: ${{ steps.meta_worker.outputs.labels }}
105-
cache-from: type=gha,scope=docker-worker,timeout=20m
106-
cache-to: type=gha,mode=min,scope=docker-worker,timeout=20m,ignore-error=true
115+
cache-from: type=gha,scope=docker-worker-${{ matrix.build_type }},timeout=20m
116+
cache-to: type=gha,mode=min,scope=docker-worker-${{ matrix.build_type }},timeout=20m,ignore-error=true
117+
github-token: ${{ secrets.GITHUB_TOKEN }}
118+
119+
build-offline-predictor-image:
120+
runs-on: ubuntu-24.04
121+
needs: build-api-image
122+
permissions:
123+
contents: read
124+
packages: write
125+
actions: write
126+
steps:
127+
- name: Remove unnecessary files
128+
run: |
129+
sudo rm -rf /usr/share/dotnet
130+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
131+
132+
- uses: actions/checkout@v4
133+
134+
- name: Log in to the Container registry
135+
uses: docker/login-action@v3
136+
with:
137+
registry: ${{ env.REGISTRY }}
138+
username: ${{ github.actor }}
139+
password: ${{ secrets.GITHUB_TOKEN }}
140+
141+
- name: Extract metadata (tags, labels) for Offline Predictor Docker
142+
id: meta_offline_predictor
143+
uses: docker/metadata-action@v5
144+
with:
145+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_offline_predictor
146+
147+
- name: Set up Docker Buildx
148+
uses: docker/setup-buildx-action@v2
149+
150+
- name: Build and push Offline Predictor Docker image
151+
uses: docker/build-push-action@v6
152+
with:
153+
context: backend/
154+
file: backend/Dockerfile.API
155+
push: false
156+
build-args: |
157+
BUILD_TARGET=predictor
158+
tags: ${{ steps.meta_offline_predictor.outputs.tags }}
159+
labels: ${{ steps.meta_offline_predictor.outputs.labels }}
160+
cache-from: type=gha,scope=offline-predictor,timeout=20m
161+
cache-to: type=gha,mode=max,scope=offline-predictor,timeout=20m,ignore-error=true
107162
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)