ci: gitea workflow + compose registry deployment
Some checks are pending
Build & Push Docker Image / docker (push) Waiting to run
Some checks are pending
Build & Push Docker Image / docker (push) Waiting to run
This commit is contained in:
parent
68930c6e4b
commit
ae8e647cf0
48
.gitea/workflows/docker-build-push.yml
Normal file
48
.gitea/workflows/docker-build-push.yml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
name: Build & Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: debian-runner
|
||||||
|
env:
|
||||||
|
REGISTRY_URL: ${{ secrets.REGISTRY_URL || 'git.4nkweb.com' }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node (for potential pre-steps)
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20.19'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Compute tags
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
# sanitize branch to be a valid docker tag
|
||||||
|
SANITIZED=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9._-]+/-/g')
|
||||||
|
echo "branch=$SANITIZED" >> "$GITHUB_OUTPUT"
|
||||||
|
VERSION=$(jq -r .version package.json)
|
||||||
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Log in to registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY_URL }}
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build & Push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
provenance: false
|
||||||
|
tags: |
|
||||||
|
${{ env.REGISTRY_URL }}/4nk/4nk-ia-front:${{ steps.meta.outputs.branch }}
|
||||||
|
${{ env.REGISTRY_URL }}/4nk/4nk-ia-front:${{ steps.meta.outputs.version }}
|
17
docker-compose.registry.yml
Normal file
17
docker-compose.registry.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
frontend:
|
||||||
|
image: "git.4nkweb.com/4nk/4nk-ia-front:${TAG:-dev}"
|
||||||
|
container_name: 4nk-ia-front
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
environment:
|
||||||
|
- VITE_API_URL=${VITE_API_URL:-http://172.23.0.10:8000}
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "wget", "-qO-", "http://localhost/"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
start_period: 10s
|
@ -4,7 +4,15 @@ set -euo pipefail
|
|||||||
IMAGE_REGISTRY=${IMAGE_REGISTRY:-git.4nkweb.com}
|
IMAGE_REGISTRY=${IMAGE_REGISTRY:-git.4nkweb.com}
|
||||||
IMAGE_NAMESPACE=${IMAGE_NAMESPACE:-4nk}
|
IMAGE_NAMESPACE=${IMAGE_NAMESPACE:-4nk}
|
||||||
IMAGE_NAME=${IMAGE_NAME:-4nk-ia-front}
|
IMAGE_NAME=${IMAGE_NAME:-4nk-ia-front}
|
||||||
IMAGE_TAG=${IMAGE_TAG:-$(git rev-parse --short HEAD)}
|
# Default tag from branch name if available, else short SHA
|
||||||
|
if [ -z "${IMAGE_TAG:-}" ]; then
|
||||||
|
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9._-]+/-/g')
|
||||||
|
if [ "$BRANCH_NAME" = "HEAD" ]; then
|
||||||
|
IMAGE_TAG=$(git rev-parse --short HEAD)
|
||||||
|
else
|
||||||
|
IMAGE_TAG=$BRANCH_NAME
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
FULL_IMAGE_REF="$IMAGE_REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$IMAGE_TAG"
|
FULL_IMAGE_REF="$IMAGE_REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$IMAGE_TAG"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user