Skip to content

Commit e704175

Browse files
committed
Add Docker image CI/CD
1 parent 30e2241 commit e704175

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

.github/workflows/docker-image.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Package publish
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
push:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
packages: write
13+
contents: read
14+
env:
15+
IMAGE_NAME: meffec-server
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Build image
20+
run: |
21+
docker build -f Server/Dockerfile Server --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
22+
23+
- name: Log in to GHCR
24+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
25+
26+
- name: Push image
27+
run: |
28+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
29+
IMAGE_ID=$(echo "$IMAGE_ID" | tr '[:upper:]' '[:lower:]')
30+
VERSION="${{ github.event.release.tag_name }}"
31+
VERSION="${VERSION#v}"
32+
echo IMAGE_ID=$IMAGE_ID
33+
echo VERSION=$VERSION
34+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
35+
docker tag $IMAGE_NAME $IMAGE_ID:latest
36+
docker push $IMAGE_ID:$VERSION
37+
docker push $IMAGE_ID:latest

Server/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3.12-slim
2+
3+
WORKDIR /meffec
4+
5+
ENV PYTHONDONTWRITEBYTECODE=1 \
6+
PYTHONUNBUFFERED=1
7+
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
COPY Server/requirements.txt .
12+
RUN python -m pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
13+
14+
COPY Server/ .
15+
16+
CMD ["python", "meffec_server.py"]

Server/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
websockets==12.0
2+
python-dotenv==1.0.1

0 commit comments

Comments
 (0)