From 070cca7c8d20001fda5031da67e475e411e6db9c Mon Sep 17 00:00:00 2001 From: j Date: Sat, 7 Mar 2026 19:54:06 +1300 Subject: [PATCH] Move template to template/ dir, add CI workflow, use pre-built image --- .gitea/workflows/build-publish.yaml | 70 +++++++++++++++++++ install-pre.sh | 10 --- backup.sh => template/backup.sh | 0 .../config}/infrastructure.conf | 0 {config => template/config}/service.env | 0 destroy.sh => template/destroy.sh | 0 .../docker-compose.yml | 2 +- template/install-pre.sh | 10 +++ install.sh => template/install.sh | 6 +- logs.sh => template/logs.sh | 0 ports.sh => template/ports.sh | 0 restore.sh => template/restore.sh | 0 start.sh => template/start.sh | 0 status.sh => template/status.sh | 0 stop.sh => template/stop.sh | 0 .../template_info.env | 4 ++ uninstall.sh => template/uninstall.sh | 0 17 files changed, 89 insertions(+), 13 deletions(-) create mode 100644 .gitea/workflows/build-publish.yaml delete mode 100755 install-pre.sh rename backup.sh => template/backup.sh (100%) rename {config => template/config}/infrastructure.conf (100%) rename {config => template/config}/service.env (100%) rename destroy.sh => template/destroy.sh (100%) rename docker-compose.yml => template/docker-compose.yml (88%) create mode 100755 template/install-pre.sh rename install.sh => template/install.sh (75%) rename logs.sh => template/logs.sh (100%) rename ports.sh => template/ports.sh (100%) rename restore.sh => template/restore.sh (100%) rename start.sh => template/start.sh (100%) rename status.sh => template/status.sh (100%) rename stop.sh => template/stop.sh (100%) rename template_info.env => template/template_info.env (59%) rename uninstall.sh => template/uninstall.sh (100%) diff --git a/.gitea/workflows/build-publish.yaml b/.gitea/workflows/build-publish.yaml new file mode 100644 index 0000000..ba21875 --- /dev/null +++ b/.gitea/workflows/build-publish.yaml @@ -0,0 +1,70 @@ +name: Build-Publish +run-name: Build and publish infmap Docker image + +on: [push] + +defaults: + run: + shell: bash + +jobs: + build: + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + runs-on: ${{ matrix.platform }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to Gitea + uses: docker/login-action@v3 + with: + registry: gitea.jde.nz + username: DoesntMatter + password: ${{ secrets.DOCKER_PUSH_TOKEN }} + + - name: Build + run: | + ARCH=$(uname -m) + docker build -t gitea.jde.nz/public/infmap:latest-${ARCH} ./app + + - name: Publish + run: | + if [ "$GITHUB_REF" = "refs/heads/main" ]; then + ARCH=$(uname -m) + docker push gitea.jde.nz/public/infmap:latest-${ARCH} + fi + + create-manifest: + needs: [build] + runs-on: ubuntu-latest + steps: + - name: Login to Gitea + uses: docker/login-action@v3 + with: + registry: gitea.jde.nz + username: DoesntMatter + password: ${{ secrets.DOCKER_PUSH_TOKEN }} + + - name: Create and push manifest list + run: | + if [ "$GITHUB_REF" = "refs/heads/main" ]; then + docker manifest rm gitea.jde.nz/public/infmap:latest 2>/dev/null || true + + docker manifest create gitea.jde.nz/public/infmap:latest \ + --amend gitea.jde.nz/public/infmap:latest-x86_64 \ + --amend gitea.jde.nz/public/infmap:latest-aarch64 + + docker manifest annotate gitea.jde.nz/public/infmap:latest \ + gitea.jde.nz/public/infmap:latest-x86_64 --arch amd64 + + docker manifest annotate gitea.jde.nz/public/infmap:latest \ + gitea.jde.nz/public/infmap:latest-aarch64 --arch arm64 + + docker manifest push gitea.jde.nz/public/infmap:latest + + echo "Manifest list created and pushed successfully" + fi diff --git a/install-pre.sh b/install-pre.sh deleted file mode 100755 index 8f48d3c..0000000 --- a/install-pre.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source "${AGENT_PATH}/common.sh" -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -cd "$SCRIPT_DIR" - -_check_required_env_vars "CONTAINER_NAME" - -docker compose -p "${CONTAINER_NAME}" pull || echo "Warning: pre-pull failed, install.sh will retry" - -echo "Pre-install complete" diff --git a/backup.sh b/template/backup.sh similarity index 100% rename from backup.sh rename to template/backup.sh diff --git a/config/infrastructure.conf b/template/config/infrastructure.conf similarity index 100% rename from config/infrastructure.conf rename to template/config/infrastructure.conf diff --git a/config/service.env b/template/config/service.env similarity index 100% rename from config/service.env rename to template/config/service.env diff --git a/destroy.sh b/template/destroy.sh similarity index 100% rename from destroy.sh rename to template/destroy.sh diff --git a/docker-compose.yml b/template/docker-compose.yml similarity index 88% rename from docker-compose.yml rename to template/docker-compose.yml index a29de3d..504702d 100644 --- a/docker-compose.yml +++ b/template/docker-compose.yml @@ -1,6 +1,6 @@ services: app: - build: ./app + image: ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG} ports: - "${WEB_PORT}:5000" environment: diff --git a/template/install-pre.sh b/template/install-pre.sh new file mode 100755 index 0000000..2dc6adf --- /dev/null +++ b/template/install-pre.sh @@ -0,0 +1,10 @@ +#!/bin/bash +source "${AGENT_PATH}/common.sh" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$SCRIPT_DIR" + +_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" + +docker pull -q "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || echo "Warning: pre-pull failed, install.sh will retry" + +echo "Pre-install complete" diff --git a/install.sh b/template/install.sh similarity index 75% rename from install.sh rename to template/install.sh index 7fc55a5..5235d54 100755 --- a/install.sh +++ b/template/install.sh @@ -3,7 +3,7 @@ source "${AGENT_PATH}/common.sh" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" -_check_required_env_vars "CONTAINER_NAME" "WEB_PORT" "SSH_KEY_PATH" "DATA_VOLUME" +_check_required_env_vars "CONTAINER_NAME" "WEB_PORT" "SSH_KEY_PATH" "DATA_VOLUME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" _check_docker_installed || _die "Docker test failed" # Check SSH key exists @@ -12,11 +12,13 @@ _check_docker_installed || _die "Docker test failed" # Check infrastructure.conf exists [ -f "${CONFIG_PATH}/infrastructure.conf" ] || _die "infrastructure.conf not found at ${CONFIG_PATH}/infrastructure.conf" +docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image" + # Create data volume docker volume create "${DATA_VOLUME}" 2>/dev/null || true bash ./stop.sh || true -docker compose -p "${CONTAINER_NAME}" up -d --build || _die "Failed to start services" +docker compose -p "${CONTAINER_NAME}" up -d || _die "Failed to start services" echo "Installation of ${CONTAINER_NAME} complete" echo "Web UI available at http://localhost:${WEB_PORT}" diff --git a/logs.sh b/template/logs.sh similarity index 100% rename from logs.sh rename to template/logs.sh diff --git a/ports.sh b/template/ports.sh similarity index 100% rename from ports.sh rename to template/ports.sh diff --git a/restore.sh b/template/restore.sh similarity index 100% rename from restore.sh rename to template/restore.sh diff --git a/start.sh b/template/start.sh similarity index 100% rename from start.sh rename to template/start.sh diff --git a/status.sh b/template/status.sh similarity index 100% rename from status.sh rename to template/status.sh diff --git a/stop.sh b/template/stop.sh similarity index 100% rename from stop.sh rename to template/stop.sh diff --git a/template_info.env b/template/template_info.env similarity index 59% rename from template_info.env rename to template/template_info.env index 33988df..337e468 100644 --- a/template_info.env +++ b/template/template_info.env @@ -2,4 +2,8 @@ REQUIRES_HOST_ROOT=false REQUIRES_DOCKER=true REQUIRES_DOCKER_ROOT=false +IMAGE_REGISTRY="gitea.jde.nz" +IMAGE_REPO="public/infmap" +IMAGE_TAG="latest" + DATA_VOLUME="${CONTAINER_NAME}_data" diff --git a/uninstall.sh b/template/uninstall.sh similarity index 100% rename from uninstall.sh rename to template/uninstall.sh