feat: update build and deploy workflow for controller and preview services

This commit is contained in:
2026-04-28 23:44:06 +02:00
parent 0199ec60c2
commit e347ab8b9e
6 changed files with 86 additions and 97 deletions
+1 -1
View File
@@ -5,5 +5,5 @@
pycache
*.pyc
.venv
Dockerfile
Dockerfile.pi
Dockerfile.pillow-wheel
+64 -59
View File
@@ -1,4 +1,4 @@
name: Build Pillow and Docker Image
name: Build and Deploy Controller & Preview
on:
push:
@@ -9,10 +9,10 @@ on:
env:
PY_VER: "3.11"
PILLOW_VERSION: "10.3.0"
CACHE_KEY: "pillow-10.3.0-py3.11-armv6-v1" # Sicherer Cache-Schlüssel
CACHE_KEY: "pillow-10.3.0-py3.11-armv6-v1"
REGISTRY: ghcr.io
jobs:
# Job 1: Pillow-Wheel ARMv6 bauen
build-pillow:
runs-on: ubuntu-latest
steps:
@@ -35,7 +35,6 @@ jobs:
- name: Build Pillow wheel if not cached
if: steps.cache-restore.outputs.cache-hit != 'true'
run: |
echo "Cache miss. Building new Pillow wheel for ARMv6..."
docker buildx build \
--platform linux/arm/v6 \
-f Dockerfile.pillow-wheel \
@@ -54,29 +53,15 @@ jobs:
path: wheels
key: ${{ env.CACHE_KEY }}
- name: Verify that wheel artifact exists
run: |
ls -lR wheels
if [ ! -f wheels/pillow-*.whl ]; then
echo "::error::Pillow wheel file not found in wheels/ directory!"
exit 1
fi
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: pillow-wheels
path: wheels/
# Job 2: Multi-arch Docker bauen & pushen, nutzt das Wheel-Artifact
build-and-push:
build-pi:
runs-on: ubuntu-latest
needs: build-pillow
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -87,48 +72,44 @@ jobs:
name: pillow-wheels
path: wheels/
- name: Verify wheel artifact was downloaded
run: |
echo "Verifying that wheels/ directory and its content exist..."
ls -lR wheels
if [ ! -f wheels/pillow-*.whl ]; then
echo "::error::Pillow wheel file not found in wheels/ after download! The artifact might be missing or empty."
exit 1
fi
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PY_VER }}
- name: Install Poetry
run: pip install poetry poetry-plugin-export
- name: Export requirements.txt from poetry
run: poetry export -f requirements.txt --output requirements.txt --without-hashes
working-directory: ./src
- name: Verify requirements.txt exists before build
- name: Install Poetry & Export Requirements
run: |
echo "Verifying that src/requirements.txt was created..."
ls -l src/requirements.txt
if [ ! -f src/requirements.txt ]; then
echo "::error::src/requirements.txt was NOT created by poetry export!"
exit 1
fi
pip install poetry poetry-plugin-export
cd src
poetry export -f requirements.txt --output requirements.txt --without-hashes
- name: Set repository owner to lowercase
id: string-actions
run: echo "OWNER_LC=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Sanitize Docker tag
id: sanitize
run: |
TAG=$(echo "${{ github.ref_name }}" | sed 's/\//-/g')
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
- name: Set up QEMU
- name: Set up QEMU & Buildx
uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Build and Push PI Image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.pi
platforms: linux/arm/v7,linux/arm/v6
push: true
tags: |
${{ env.REGISTRY }}/starappeal/led-matrix-pi:latest
${{ env.REGISTRY }}/starappeal/led-matrix-pi:${{ github.ref_name }}
build-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@@ -136,17 +117,41 @@ jobs:
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Build and Push Docker image
id: build-and-push
- name: Build and Push PREVIEW Image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm/v6
file: Dockerfile.preview
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ steps.string-actions.outputs.OWNER_LC }}/led-matrix-application-websocket:latest
ghcr.io/${{ steps.string-actions.outputs.OWNER_LC }}/led-matrix-application-websocket:${{ steps.sanitize.outputs.TAG }}
${{ env.REGISTRY }}/starappeal/ledmatrix-preview:latest
${{ env.REGISTRY }}/starappeal/ledmatrix-preview:${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy-preview:
runs-on: ubuntu-latest
needs: build-preview
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
envs: GHCR_PAT
script: |
cd /home/matrix/ledmatrix-deployment
docker compose -f docker-compose.yml -f docker-compose.prod.yml pull preview-service
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d preview-service
docker image prune -f
env:
GHCR_PAT: ${{ secrets.GHCR_PAT }}
-36
View File
@@ -1,36 +0,0 @@
FROM python:3.11-slim-bullseye
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libjpeg-dev zlib1g-dev \
curl \
libdbus-1-3 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
ARG WIFICONNECT_VERSION=4.11.84
RUN set -eux; \
ARCH=$(dpkg --print-architecture); \
if [ "$ARCH" = "amd64" ]; then \
WIFI_CONNECT_FILE="wifi-connect-x86_64-unknown-linux-gnu.tar.gz"; \
elif [ "$ARCH" = "armhf" ] || [ "$ARCH" = "armel" ]; then \
WIFI_CONNECT_FILE="wifi-connect-armv7-unknown-linux-gnueabihf.tar.gz"; \
else \
echo "Unsupported architecture: $ARCH"; exit 1; \
fi; \
curl -L -o /tmp/wifi-connect.tar.gz "https://github.com/balena-io/wifi-connect/releases/download/v${WIFICONNECT_VERSION}/${WIFI_CONNECT_FILE}"; \
tar -xzf /tmp/wifi-connect.tar.gz -C /usr/local/sbin; \
rm /tmp/wifi-connect.tar.gz
WORKDIR /app
RUN pip install poetry poetry-plugin-export
COPY src/pyproject.toml src/poetry.lock* ./
RUN poetry lock && poetry install --no-root
COPY src/ .
COPY entry.sh /usr/bin/entry.sh
RUN chmod +x /usr/bin/entry.sh
CMD ["/usr/bin/entry.sh"]
View File
+21
View File
@@ -0,0 +1,21 @@
FROM python:3.11-slim-bullseye
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libjpeg-dev \
zlib1g-dev \
python3-dev \
libffi-dev \
libssl-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN pip install poetry poetry-plugin-export
COPY src/pyproject.toml src/poetry.lock* ./
RUN poetry config virtualenvs.create false && poetry lock && poetry install --no-root
COPY src/ .
CMD ["python", "-m", "led_matrix_application.preview.preview_server"]
-1
View File
@@ -3,7 +3,6 @@ name = "led-matrix-application"
version = "0.1.0"
description = ""
authors = ["tsomic <keller.nils99@gmail.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"