3 files changed
+45
-63
No files matched your search
@@ -2,7 +2,6 @@ name: CI - Lint, Test, and Push Docker Image
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
schedule:
|
schedule:
|
||||||
@@ -48,17 +47,17 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup melange
|
||||||
|
uses: chainguard-dev/actions/setup-melange@main
|
||||||
|
|
||||||
- name: Generate melange signing keypair
|
- name: Generate melange signing keypair
|
||||||
uses: chainguard-dev/actions/melange-keygen@main
|
run: melange keygen melange.rsa
|
||||||
with:
|
|
||||||
signing-key-path: melange.rsa
|
|
||||||
|
|
||||||
- name: Build package with melange
|
- name: Build package with melange
|
||||||
uses: chainguard-dev/actions/melange-build@main
|
run: |
|
||||||
with:
|
melange build melange.yaml \
|
||||||
config: melange.yaml
|
--signing-key melange.rsa \
|
||||||
signing-key-path: melange.rsa
|
--arch x86_64,aarch64
|
||||||
archs: x86_64,aarch64
|
|
||||||
|
|
||||||
- name: Log in to GHCR
|
- name: Log in to GHCR
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@@ -75,28 +74,3 @@ jobs:
|
|||||||
tag: ghcr.io/k2patel/apcupsd-client:latest
|
tag: ghcr.io/k2patel/apcupsd-client:latest
|
||||||
keyring-append: melange.rsa.pub
|
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 }}
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
contents:
|
contents:
|
||||||
repositories:
|
repositories:
|
||||||
- https://dl-cdn.alpinelinux.org/alpine/edge/main
|
- https://dl-cdn.alpinelinux.org/alpine/v3.21/main
|
||||||
- https://dl-cdn.alpinelinux.org/alpine/edge/community
|
- https://dl-cdn.alpinelinux.org/alpine/v3.21/community
|
||||||
- '@local ./packages'
|
- '@local ./packages'
|
||||||
packages:
|
packages:
|
||||||
- alpine-baselayout
|
- alpine-baselayout-data
|
||||||
- busybox
|
- ca-certificates-bundle
|
||||||
- python3
|
- python3
|
||||||
- apcupsd
|
- apcupsd
|
||||||
- apcupsd-client@local
|
- apcupsd-client@local
|
||||||
@@ -26,6 +26,6 @@ environment:
|
|||||||
REDIS_URL: "redis://redis:6379/0"
|
REDIS_URL: "redis://redis:6379/0"
|
||||||
|
|
||||||
entrypoint:
|
entrypoint:
|
||||||
command: /usr/bin/start-server
|
command: /app/.venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
|
||||||
|
|
||||||
work-dir: /app
|
work-dir: /app
|
||||||
+32
-24
@@ -1,26 +1,22 @@
|
|||||||
package:
|
package:
|
||||||
name: apcupsd-client
|
name: apcupsd-client-build
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
epoch: 0
|
epoch: 0
|
||||||
description: FastAPI + Redis UPS monitoring dashboard
|
description: Build stage for apcupsd-client (not installed directly)
|
||||||
copyright:
|
copyright:
|
||||||
- license: MIT
|
- license: MIT
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
contents:
|
contents:
|
||||||
repositories:
|
repositories:
|
||||||
- https://dl-cdn.alpinelinux.org/alpine/edge/main
|
- https://dl-cdn.alpinelinux.org/alpine/v3.21/main
|
||||||
- https://dl-cdn.alpinelinux.org/alpine/edge/community
|
- https://dl-cdn.alpinelinux.org/alpine/v3.21/community
|
||||||
packages:
|
packages:
|
||||||
- alpine-baselayout
|
- alpine-baselayout
|
||||||
- busybox
|
- busybox
|
||||||
- python3
|
- python3
|
||||||
- python3-dev
|
|
||||||
- py3-pip
|
- py3-pip
|
||||||
- py3-virtualenv
|
- py3-virtualenv
|
||||||
- gcc
|
|
||||||
- musl-dev
|
|
||||||
- libffi-dev
|
|
||||||
|
|
||||||
pipeline:
|
pipeline:
|
||||||
- name: Create virtualenv and install dependencies
|
- name: Create virtualenv and install dependencies
|
||||||
@@ -30,6 +26,7 @@ pipeline:
|
|||||||
python3 -m virtualenv "${{targets.destdir}}/app/.venv"
|
python3 -m virtualenv "${{targets.destdir}}/app/.venv"
|
||||||
"${{targets.destdir}}/app/.venv/bin/pip" install \
|
"${{targets.destdir}}/app/.venv/bin/pip" install \
|
||||||
--no-cache-dir \
|
--no-cache-dir \
|
||||||
|
--only-binary :all: \
|
||||||
-r requirements.prod.txt
|
-r requirements.prod.txt
|
||||||
|
|
||||||
- name: Copy application source
|
- name: Copy application source
|
||||||
@@ -37,25 +34,36 @@ pipeline:
|
|||||||
set -ex
|
set -ex
|
||||||
cp -r app/ "${{targets.destdir}}/app/app/"
|
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
|
- name: Fix virtualenv shebangs
|
||||||
runs: |
|
runs: |
|
||||||
set -ex
|
set -ex
|
||||||
# Rewrite shebangs so they reference the final installed path
|
|
||||||
find "${{targets.destdir}}/app/.venv/bin" -type f -exec \
|
find "${{targets.destdir}}/app/.venv/bin" -type f -exec \
|
||||||
sed -i "s|${{targets.destdir}}||g" {} +
|
sed -i "s|${{targets.destdir}}||g" {} +
|
||||||
|
|
||||||
data:
|
- name: Strip build artifacts from virtualenv
|
||||||
- name: runtime-deps
|
runs: |
|
||||||
items:
|
set -ex
|
||||||
python3: python3
|
rm -rf "${{targets.destdir}}/app/.venv/bin/pip"*
|
||||||
apcupsd: apcupsd
|
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
|
||||||
|
|
||||||
|
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"
|
||||||
Reference in new issue
Block a user