Move template to template/ dir, add CI workflow, use pre-built image
This commit is contained in:
70
.gitea/workflows/build-publish.yaml
Normal file
70
.gitea/workflows/build-publish.yaml
Normal file
@@ -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
|
||||||
@@ -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"
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build: ./app
|
image: ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}
|
||||||
ports:
|
ports:
|
||||||
- "${WEB_PORT}:5000"
|
- "${WEB_PORT}:5000"
|
||||||
environment:
|
environment:
|
||||||
10
template/install-pre.sh
Executable file
10
template/install-pre.sh
Executable file
@@ -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"
|
||||||
@@ -3,7 +3,7 @@ source "${AGENT_PATH}/common.sh"
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
cd "$SCRIPT_DIR"
|
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_docker_installed || _die "Docker test failed"
|
||||||
|
|
||||||
# Check SSH key exists
|
# Check SSH key exists
|
||||||
@@ -12,11 +12,13 @@ _check_docker_installed || _die "Docker test failed"
|
|||||||
# Check infrastructure.conf exists
|
# Check infrastructure.conf exists
|
||||||
[ -f "${CONFIG_PATH}/infrastructure.conf" ] || _die "infrastructure.conf not found at ${CONFIG_PATH}/infrastructure.conf"
|
[ -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
|
# Create data volume
|
||||||
docker volume create "${DATA_VOLUME}" 2>/dev/null || true
|
docker volume create "${DATA_VOLUME}" 2>/dev/null || true
|
||||||
|
|
||||||
bash ./stop.sh || 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 "Installation of ${CONTAINER_NAME} complete"
|
||||||
echo "Web UI available at http://localhost:${WEB_PORT}"
|
echo "Web UI available at http://localhost:${WEB_PORT}"
|
||||||
@@ -2,4 +2,8 @@ REQUIRES_HOST_ROOT=false
|
|||||||
REQUIRES_DOCKER=true
|
REQUIRES_DOCKER=true
|
||||||
REQUIRES_DOCKER_ROOT=false
|
REQUIRES_DOCKER_ROOT=false
|
||||||
|
|
||||||
|
IMAGE_REGISTRY="gitea.jde.nz"
|
||||||
|
IMAGE_REPO="public/infmap"
|
||||||
|
IMAGE_TAG="latest"
|
||||||
|
|
||||||
DATA_VOLUME="${CONTAINER_NAME}_data"
|
DATA_VOLUME="${CONTAINER_NAME}_data"
|
||||||
Reference in New Issue
Block a user