Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30db433c9a | ||
|
|
208aadc9bc |
@@ -2,7 +2,6 @@
|
||||
.gitea
|
||||
.venv
|
||||
data
|
||||
tests
|
||||
__pycache__
|
||||
*.pyc
|
||||
*.log
|
||||
|
||||
@@ -16,15 +16,13 @@ jobs:
|
||||
with:
|
||||
github-server-url: http://gitea:3000
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Abhaengigkeiten installieren
|
||||
run: pip install -r requirements-dev.txt
|
||||
|
||||
# Kein setup-python: die Action laedt ihre Runtime von GitHub-Releases
|
||||
# und scheitert auf dem Gitea-Runner. Stattdessen laufen die Tests in
|
||||
# einer eigenen Stufe des Dockerfiles - gegen dieselbe Python-Version
|
||||
# und dieselben Pakete wie die Produktion. Ein roter Lauf bricht hier
|
||||
# ab, bevor irgendetwas auf dem Server angefasst wird.
|
||||
- name: Tests
|
||||
run: pytest -q
|
||||
run: docker build --target test .
|
||||
|
||||
- name: Tag ermitteln
|
||||
run: echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||
|
||||
18
Dockerfile
18
Dockerfile
@@ -1,17 +1,31 @@
|
||||
# Abhaengigkeiten in ein venv bauen, damit der Compiler-Ballast nicht ins
|
||||
# fertige Image wandert.
|
||||
FROM python:3.12-slim AS build
|
||||
WORKDIR /app
|
||||
RUN python -m venv /opt/venv
|
||||
ENV PATH="/opt/venv/bin:$PATH"
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Testlauf gegen dieselbe Python-Version und dieselben Pakete wie die
|
||||
# Produktion. Die Stufe haengt nicht am finalen Image und wird bei einem
|
||||
# normalen Build uebersprungen; der Workflow ruft sie mit --target test auf.
|
||||
FROM build AS test
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends libglib2.0-0 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
COPY requirements-dev.txt .
|
||||
RUN pip install --no-cache-dir -r requirements-dev.txt
|
||||
COPY app ./app
|
||||
COPY static ./static
|
||||
COPY tests ./tests
|
||||
RUN pytest -q
|
||||
|
||||
FROM python:3.12-slim
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PATH="/opt/venv/bin:$PATH" \
|
||||
DATA_DIR=/data \
|
||||
PORT=8080
|
||||
DATA_DIR=/data
|
||||
|
||||
# libglib2.0-0 wird von opencv-python-headless gebraucht.
|
||||
RUN apt-get update \
|
||||
|
||||
Reference in New Issue
Block a user