From e06269c7003e4ee497597a6df4c32a962887c539 Mon Sep 17 00:00:00 2001 From: Ketan Patel Date: Thu, 16 Apr 2026 18:55:26 -0400 Subject: [PATCH 1/6] Ading the configuration for the docker --- .github/workflows/docker-image.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 61dca92..d084a70 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,7 +2,6 @@ name: CI - Lint, Test, and Push Docker Image on: push: - branches: [ "main" ] pull_request: branches: [ "main" ] schedule: @@ -48,17 +47,17 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Setup melange + uses: chainguard-dev/actions/setup-melange@main + - name: Generate melange signing keypair - uses: chainguard-dev/actions/melange-keygen@main - with: - signing-key-path: melange.rsa + run: melange keygen melange.rsa - name: Build package with melange - uses: chainguard-dev/actions/melange-build@main - with: - config: melange.yaml - signing-key-path: melange.rsa - archs: x86_64,aarch64 + run: | + melange build melange.yaml \ + --signing-key melange.rsa \ + --arch x86_64,aarch64 - name: Log in to GHCR uses: docker/login-action@v3 From 96fd1bbb5fad6b2746599497cbb7215f00577b73 Mon Sep 17 00:00:00 2001 From: Ketan Patel Date: Thu, 16 Apr 2026 19:05:03 -0400 Subject: [PATCH 2/6] Adding the fixes --- .github/workflows/docker-image.yml | 25 ---------------------- apko.yaml | 15 ++++++++----- melange.yaml | 34 +++++++++++++++--------------- 3 files changed, 27 insertions(+), 47 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d084a70..d60ecf9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -74,28 +74,3 @@ jobs: tag: ghcr.io/k2patel/apcupsd-client:latest keyring-append: melange.rsa.pub - build-docker: - runs-on: ubuntu-latest - needs: lint-and-test - if: github.event_name != 'pull_request' - steps: - - name: Set Image name - run: | - echo "IMAGE_NAME=k2patel/apcupsd-client:latest" >> $GITHUB_ENV - - - name: Checkout code - uses: actions/checkout@v4 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} - - - name: Build the Docker image - id: build - run: | - docker build . -t ${{ env.IMAGE_NAME }} - - - name: Push the Docker image - run: docker push ${{ env.IMAGE_NAME }} diff --git a/apko.yaml b/apko.yaml index 3265158..62d19e6 100644 --- a/apko.yaml +++ b/apko.yaml @@ -1,11 +1,11 @@ contents: repositories: - - https://dl-cdn.alpinelinux.org/alpine/edge/main - - https://dl-cdn.alpinelinux.org/alpine/edge/community + - https://dl-cdn.alpinelinux.org/alpine/v3.21/main + - https://dl-cdn.alpinelinux.org/alpine/v3.21/community - '@local ./packages' packages: - - alpine-baselayout - - busybox + - alpine-baselayout-data + - ca-certificates-bundle - python3 - apcupsd - apcupsd-client@local @@ -26,6 +26,11 @@ environment: REDIS_URL: "redis://redis:6379/0" entrypoint: - command: /usr/bin/start-server + command: /app/.venv/bin/python + services: + uvicorn: + command: /app/.venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 + +cmd: "-m uvicorn app.main:app --host 0.0.0.0 --port 8000" work-dir: /app diff --git a/melange.yaml b/melange.yaml index 5a222d5..8ee1152 100644 --- a/melange.yaml +++ b/melange.yaml @@ -9,18 +9,14 @@ package: environment: contents: repositories: - - https://dl-cdn.alpinelinux.org/alpine/edge/main - - https://dl-cdn.alpinelinux.org/alpine/edge/community + - https://dl-cdn.alpinelinux.org/alpine/v3.21/main + - https://dl-cdn.alpinelinux.org/alpine/v3.21/community packages: - alpine-baselayout - busybox - python3 - - python3-dev - py3-pip - py3-virtualenv - - gcc - - musl-dev - - libffi-dev pipeline: - name: Create virtualenv and install dependencies @@ -30,6 +26,7 @@ pipeline: python3 -m virtualenv "${{targets.destdir}}/app/.venv" "${{targets.destdir}}/app/.venv/bin/pip" install \ --no-cache-dir \ + --only-binary :all: \ -r requirements.prod.txt - name: Copy application source @@ -37,23 +34,26 @@ pipeline: set -ex cp -r app/ "${{targets.destdir}}/app/app/" - - name: Create entrypoint script - runs: | - set -ex - mkdir -p "${{targets.destdir}}/usr/bin" - cat > "${{targets.destdir}}/usr/bin/start-server" <<'SCRIPT' - #!/bin/sh - exec /app/.venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 8000 - SCRIPT - chmod +x "${{targets.destdir}}/usr/bin/start-server" - - name: Fix virtualenv shebangs runs: | set -ex - # Rewrite shebangs so they reference the final installed path find "${{targets.destdir}}/app/.venv/bin" -type f -exec \ sed -i "s|${{targets.destdir}}||g" {} + + - name: Strip build artifacts from virtualenv + runs: | + set -ex + rm -rf "${{targets.destdir}}/app/.venv/bin/pip"* + rm -rf "${{targets.destdir}}/app/.venv/bin/wheel"* + rm -rf "${{targets.destdir}}/app/.venv/lib/python*/site-packages/pip" + rm -rf "${{targets.destdir}}/app/.venv/lib/python*/site-packages/pip-*" + rm -rf "${{targets.destdir}}/app/.venv/lib/python*/site-packages/setuptools" + rm -rf "${{targets.destdir}}/app/.venv/lib/python*/site-packages/setuptools-*" + rm -rf "${{targets.destdir}}/app/.venv/lib/python*/site-packages/wheel" + rm -rf "${{targets.destdir}}/app/.venv/lib/python*/site-packages/wheel-*" + find "${{targets.destdir}}/app/.venv" -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true + find "${{targets.destdir}}/app/.venv" -name "*.pyc" -delete 2>/dev/null || true + data: - name: runtime-deps items: From 5d0dffb48d62dd35ac889770dd0f76f30daf6f63 Mon Sep 17 00:00:00 2001 From: Ketan Patel Date: Thu, 16 Apr 2026 19:09:48 -0400 Subject: [PATCH 3/6] Adding the fixes --- apko.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/apko.yaml b/apko.yaml index 62d19e6..ccefa1c 100644 --- a/apko.yaml +++ b/apko.yaml @@ -26,11 +26,6 @@ environment: REDIS_URL: "redis://redis:6379/0" entrypoint: - command: /app/.venv/bin/python - services: - uvicorn: - command: /app/.venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 - -cmd: "-m uvicorn app.main:app --host 0.0.0.0 --port 8000" + command: /app/.venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 work-dir: /app From 9b2226e5793304f88794f0d0c6988dc64b96837c Mon Sep 17 00:00:00 2001 From: Ketan Patel Date: Thu, 16 Apr 2026 19:16:07 -0400 Subject: [PATCH 4/6] Adding the fixes --- melange.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/melange.yaml b/melange.yaml index 8ee1152..e6f42a3 100644 --- a/melange.yaml +++ b/melange.yaml @@ -5,6 +5,12 @@ package: description: FastAPI + Redis UPS monitoring dashboard copyright: - license: MIT + dependencies: + runtime: + - python3 + +options: + no-depends: true environment: contents: @@ -54,8 +60,3 @@ pipeline: find "${{targets.destdir}}/app/.venv" -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true find "${{targets.destdir}}/app/.venv" -name "*.pyc" -delete 2>/dev/null || true -data: - - name: runtime-deps - items: - python3: python3 - apcupsd: apcupsd From 6de105e556f91aa61715ab861528a0018d09884a Mon Sep 17 00:00:00 2001 From: Ketan Patel Date: Thu, 16 Apr 2026 19:20:31 -0400 Subject: [PATCH 5/6] Adding the fixes --- melange.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/melange.yaml b/melange.yaml index e6f42a3..be3c8cc 100644 --- a/melange.yaml +++ b/melange.yaml @@ -8,9 +8,8 @@ package: dependencies: runtime: - python3 - -options: - no-depends: true + provides: + - python-3.12-base=3.12 environment: contents: From e30c2d8a931d65a86abaa43a7d8cb2ffd0bd9222 Mon Sep 17 00:00:00 2001 From: Ketan Patel Date: Thu, 16 Apr 2026 19:26:00 -0400 Subject: [PATCH 6/6] Adding the fixes --- melange.yaml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/melange.yaml b/melange.yaml index be3c8cc..b1b2dcd 100644 --- a/melange.yaml +++ b/melange.yaml @@ -1,15 +1,10 @@ package: - name: apcupsd-client + name: apcupsd-client-build version: 1.0.0 epoch: 0 - description: FastAPI + Redis UPS monitoring dashboard + description: Build stage for apcupsd-client (not installed directly) copyright: - license: MIT - dependencies: - runtime: - - python3 - provides: - - python-3.12-base=3.12 environment: contents: @@ -59,3 +54,16 @@ pipeline: find "${{targets.destdir}}/app/.venv" -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true find "${{targets.destdir}}/app/.venv" -name "*.pyc" -delete 2>/dev/null || true +subpackages: + - name: apcupsd-client + description: FastAPI + Redis UPS monitoring dashboard + options: + no-depends: true + dependencies: + runtime: + - python3 + pipeline: + - runs: | + set -ex + mkdir -p "${{targets.subpkgdir}}" + mv "${{targets.destdir}}/app" "${{targets.subpkgdir}}/app"