feat: update build and deploy workflow for controller and preview services
This commit is contained in:
+1
-1
@@ -5,5 +5,5 @@
|
|||||||
pycache
|
pycache
|
||||||
*.pyc
|
*.pyc
|
||||||
.venv
|
.venv
|
||||||
Dockerfile
|
Dockerfile.pi
|
||||||
Dockerfile.pillow-wheel
|
Dockerfile.pillow-wheel
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
name: Build Pillow and Docker Image
|
name: Build and Deploy Controller & Preview
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -9,10 +9,10 @@ on:
|
|||||||
env:
|
env:
|
||||||
PY_VER: "3.11"
|
PY_VER: "3.11"
|
||||||
PILLOW_VERSION: "10.3.0"
|
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:
|
jobs:
|
||||||
# Job 1: Pillow-Wheel ARMv6 bauen
|
|
||||||
build-pillow:
|
build-pillow:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -35,7 +35,6 @@ jobs:
|
|||||||
- name: Build Pillow wheel if not cached
|
- name: Build Pillow wheel if not cached
|
||||||
if: steps.cache-restore.outputs.cache-hit != 'true'
|
if: steps.cache-restore.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
echo "Cache miss. Building new Pillow wheel for ARMv6..."
|
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/arm/v6 \
|
--platform linux/arm/v6 \
|
||||||
-f Dockerfile.pillow-wheel \
|
-f Dockerfile.pillow-wheel \
|
||||||
@@ -54,29 +53,15 @@ jobs:
|
|||||||
path: wheels
|
path: wheels
|
||||||
key: ${{ env.CACHE_KEY }}
|
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
|
- name: Upload wheel artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: pillow-wheels
|
name: pillow-wheels
|
||||||
path: wheels/
|
path: wheels/
|
||||||
|
|
||||||
# Job 2: Multi-arch Docker bauen & pushen, nutzt das Wheel-Artifact
|
build-pi:
|
||||||
build-and-push:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build-pillow
|
needs: build-pillow
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -87,48 +72,44 @@ jobs:
|
|||||||
name: pillow-wheels
|
name: pillow-wheels
|
||||||
path: 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
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ env.PY_VER }}
|
python-version: ${{ env.PY_VER }}
|
||||||
|
|
||||||
- name: Install Poetry
|
- name: Install Poetry & Export Requirements
|
||||||
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
|
|
||||||
run: |
|
run: |
|
||||||
echo "Verifying that src/requirements.txt was created..."
|
pip install poetry poetry-plugin-export
|
||||||
ls -l src/requirements.txt
|
cd src
|
||||||
if [ ! -f src/requirements.txt ]; then
|
poetry export -f requirements.txt --output requirements.txt --without-hashes
|
||||||
echo "::error::src/requirements.txt was NOT created by poetry export!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Set repository owner to lowercase
|
- name: Set up QEMU & Buildx
|
||||||
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
|
|
||||||
uses: docker/setup-qemu-action@v3
|
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
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -136,17 +117,41 @@ jobs:
|
|||||||
- name: Log in to GHCR
|
- name: Log in to GHCR
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GHCR_PAT }}
|
password: ${{ secrets.GHCR_PAT }}
|
||||||
|
|
||||||
- name: Build and Push Docker image
|
- name: Build and Push PREVIEW Image
|
||||||
id: build-and-push
|
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm/v7,linux/arm/v6
|
file: Dockerfile.preview
|
||||||
|
platforms: linux/amd64
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/${{ steps.string-actions.outputs.OWNER_LC }}/led-matrix-application-websocket:latest
|
${{ env.REGISTRY }}/starappeal/ledmatrix-preview:latest
|
||||||
ghcr.io/${{ steps.string-actions.outputs.OWNER_LC }}/led-matrix-application-websocket:${{ steps.sanitize.outputs.TAG }}
|
${{ 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 }}
|
||||||
@@ -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"]
|
|
||||||
@@ -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"]
|
||||||
@@ -3,7 +3,6 @@ name = "led-matrix-application"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["tsomic <keller.nils99@gmail.com>"]
|
authors = ["tsomic <keller.nils99@gmail.com>"]
|
||||||
readme = "README.md"
|
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.11"
|
python = "^3.11"
|
||||||
|
|||||||
Reference in New Issue
Block a user