Skip to content

Commit 43c348c

Browse files
committed
Add docker image
1 parent 1875844 commit 43c348c

6 files changed

Lines changed: 83 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ concurrency:
1313
group: ${{ github.workflow }}
1414
cancel-in-progress: true
1515

16+
env:
17+
REGISTRY: ghcr.io
18+
REGISTRY_USER: ${{ github.repository_owner }}
19+
REGISTRY_PASS: ${{ secrets.GITHUB_TOKEN }}
20+
IMAGE_NAME: ${{ github.repository }}
21+
1622
jobs:
1723
ci:
1824
runs-on: ubuntu-latest
@@ -27,7 +33,7 @@ jobs:
2733
# uses: callowayproject/bump-my-version@master
2834
# with:
2935
# args: patch --no-commit --verbose
30-
- uses: actions/setup-python@v5
36+
- uses: actions/setup-python@v6
3137
with:
3238
python-version: '3.12'
3339
- run: |
@@ -59,3 +65,37 @@ jobs:
5965
github_token: ${{ secrets.GITHUB_TOKEN }}
6066
publish_dir: ./frontend/dist
6167
destination_dir: dev
68+
69+
- name: Set up QEMU
70+
uses: docker/setup-qemu-action@v3
71+
72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v3
74+
75+
- name: Login to ${{ env.REGISTRY }} registry
76+
uses: docker/login-action@v3
77+
with:
78+
registry: ${{ env.REGISTRY }}
79+
username: ${{ env.REGISTRY_USER }}
80+
password: ${{ env.REGISTRY_PASS }}
81+
82+
- name: Extract metadata (tags, labels) for Docker
83+
id: meta
84+
uses: docker/metadata-action@v5
85+
with:
86+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
87+
tags: |
88+
type=ref,event=branch
89+
type=ref,event=pr
90+
type=semver,pattern={{version}}
91+
#type=semver,pattern={{major}}.{{minor}}
92+
#type=semver,pattern={{major}}
93+
94+
- name: Build and push
95+
uses: docker/build-push-action@v6
96+
with:
97+
context: .
98+
push: true
99+
platforms: linux/amd64,linux/arm64
100+
tags: ${{ steps.meta.outputs.tags }}
101+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
working-directory: frontend
4242
run: npm ci
4343

44+
- name: Env
45+
working-directory: frontend
46+
run: echo "VITE_BASE_PATH=/OpenNumismatWeb/" > .env.local
47+
4448
- name: Build
4549
working-directory: frontend
4650
run: npm run build

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Stage 1: Build Vue app
2+
FROM node:24-alpine as build-stage
3+
WORKDIR /app/frontend
4+
5+
COPY frontend/package*.json ./
6+
RUN npm install
7+
COPY frontend/ .
8+
RUN npm run build
9+
10+
11+
# Stage 2: Flask backend with Vue build files
12+
FROM python:3.12-slim
13+
WORKDIR /app
14+
15+
ENV PYTHONDONTWRITEBYTECODE=1
16+
ENV PYTHONUNBUFFERED=1
17+
18+
COPY backend/requirements.txt .
19+
RUN pip install --upgrade pip
20+
RUN pip install --no-cache-dir -r requirements.txt
21+
RUN pip install --no-cache-dir gunicorn==24.1.1
22+
COPY backend/ /app
23+
24+
COPY --from=build-stage /app/frontend/dist /app/static
25+
26+
EXPOSE 5000
27+
28+
RUN chmod +x /app/entrypoint.sh
29+
ENTRYPOINT ["/app/entrypoint.sh"]

backend/app.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
from flask import Flask
2-
1+
from flask import Flask, send_from_directory
32

43
# Initializing flask app
54
app = Flask(__name__, static_url_path='/')
65

76

7+
@app.route('/', defaults={'path': ''})
8+
def catch_all(path):
9+
return send_from_directory('static', 'index.html')
10+
11+
812
# Running app
913
if __name__ == '__main__':
1014
app.run(debug=True)

backend/entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/bash
2+
3+
gunicorn -b :5000 app:app

frontend/.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
VITE_BASE_PATH=/OpenNumismatWeb/
21
VITE_APP_VERSION=$npm_package_version

0 commit comments

Comments
 (0)