mirror of
https://github.com/MrUnknownDE/utools.git
synced 2026-04-19 14:13:44 +02:00
move to DockerHUB + manuell trigger
This commit is contained in:
72
.github/workflows/docker-build-push.yml
vendored
72
.github/workflows/docker-build-push.yml
vendored
@@ -1,9 +1,16 @@
|
|||||||
name: Docker Build and Push
|
# .github/workflows/dockerhub-build-and-push.yml
|
||||||
|
name: Docker Build and Push (Docker Hub, Multi-Arch)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main # Löst den Workflow bei jedem Push auf den main-Branch aus
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
extra_tag:
|
||||||
|
description: "Optionaler zusätzlicher Tag (z.B. v1.2.3). Wird zusätzlich zu :latest und :<sha> gepusht."
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
@@ -13,15 +20,17 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Notwendig, um den Git-Hash zu bekommen
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Log in to GitHub Container Registry
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: docker.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
# Verwendet Ihr dediziertes Secret für die Authentifizierung
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
password: ${{ secrets.GHC_PUSH }}
|
|
||||||
|
- name: Set up QEMU (for multi-arch)
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -30,28 +39,39 @@ jobs:
|
|||||||
id: git_sha
|
id: git_sha
|
||||||
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Define Image Names in Lowercase
|
# Namespace für Docker Hub (alles lowercase)
|
||||||
|
- name: Define Docker Hub image names
|
||||||
id: image_names
|
id: image_names
|
||||||
run: |
|
run: |
|
||||||
OWNER_LC=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
NS_LC=$(echo "${{ secrets.DOCKERHUB_USERNAME }}" | tr '[:upper:]' '[:lower:]')
|
||||||
echo "backend_image=ghcr.io/$OWNER_LC/utools-backend" >> $GITHUB_OUTPUT
|
echo "backend_image=docker.io/$NS_LC/utools-backend" >> $GITHUB_OUTPUT
|
||||||
echo "frontend_image=ghcr.io/$OWNER_LC/utools-frontend" >> $GITHUB_OUTPUT
|
echo "frontend_image=docker.io/$NS_LC/utools-frontend" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Build images using compose.build.yml
|
# Multi-Arch Build & Push über Bake mit deiner compose.build.yml
|
||||||
env:
|
# WICHTIG: Die Service-Namen in compose.build.yml sollten "backend" und "frontend" heißen
|
||||||
GIT_COMMIT_SHA: ${{ steps.git_sha.outputs.sha }}
|
# und unter 'image:' jeweils docker.io/<user>/utools-... gesetzt sein.
|
||||||
SENTRY_DSN: ${{ secrets.SENTRY_DSN }} # Sentry DSN als Secret übergeben
|
- name: Build & push multi-arch images via Bake (latest + sha)
|
||||||
run: |
|
uses: docker/bake-action@v5
|
||||||
docker compose -f compose.build.yml build
|
with:
|
||||||
|
files: |
|
||||||
|
compose.build.yml
|
||||||
|
push: true
|
||||||
|
set: |
|
||||||
|
*.platform=linux/amd64,linux/arm64
|
||||||
|
backend.tags=${{ steps.image_names.outputs.backend_image }}:latest,${{ steps.image_names.outputs.backend_image }}:${{ steps.git_sha.outputs.sha }}
|
||||||
|
frontend.tags=${{ steps.image_names.outputs.frontend_image }}:latest,${{ steps.image_names.outputs.frontend_image }}:${{ steps.git_sha.outputs.sha }}
|
||||||
|
|
||||||
- name: Tag images with Git SHA
|
# Optionaler Zusatz-Tag ohne Rebuild: manifest neu taggen
|
||||||
|
- name: Tag backend image with extra tag (manifest)
|
||||||
|
if: ${{ github.event.inputs.extra_tag && github.event.inputs.extra_tag != '' }}
|
||||||
run: |
|
run: |
|
||||||
docker tag ${{ steps.image_names.outputs.backend_image }}:latest ${{ steps.image_names.outputs.backend_image }}:${{ steps.git_sha.outputs.sha }}
|
docker buildx imagetools create \
|
||||||
docker tag ${{ steps.image_names.outputs.frontend_image }}:latest ${{ steps.image_names.outputs.frontend_image }}:${{ steps.git_sha.outputs.sha }}
|
-t ${{ steps.image_names.outputs.backend_image }}:${{ github.event.inputs.extra_tag }} \
|
||||||
|
${{ steps.image_names.outputs.backend_image }}:${{ steps.git_sha.outputs.sha }}
|
||||||
|
|
||||||
- name: Push images to GHCR (both tags)
|
- name: Tag frontend image with extra tag (manifest)
|
||||||
|
if: ${{ github.event.inputs.extra_tag && github.event.inputs.extra_tag != '' }}
|
||||||
run: |
|
run: |
|
||||||
docker push ${{ steps.image_names.outputs.backend_image }}:latest
|
docker buildx imagetools create \
|
||||||
docker push ${{ steps.image_names.outputs.backend_image }}:${{ steps.git_sha.outputs.sha }}
|
-t ${{ steps.image_names.outputs.frontend_image }}:${{ github.event.inputs.extra_tag }} \
|
||||||
docker push ${{ steps.image_names.outputs.frontend_image }}:latest
|
${{ steps.image_names.outputs.frontend_image }}:${{ steps.git_sha.outputs.sha }}
|
||||||
docker push ${{ steps.image_names.outputs.frontend_image }}:${{ steps.git_sha.outputs.sha }}
|
|
||||||
@@ -2,7 +2,7 @@ services:
|
|||||||
# Backend Service (Node.js App)
|
# Backend Service (Node.js App)
|
||||||
backend:
|
backend:
|
||||||
# Verwendet ein bereits gebautes Image
|
# Verwendet ein bereits gebautes Image
|
||||||
image: ghcr.io/mrunknownde/utools-backend:latest
|
image: mrunknownde/utools-backend
|
||||||
container_name: utools_backend
|
container_name: utools_backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
@@ -28,7 +28,7 @@ services:
|
|||||||
# Frontend Service (Nginx)
|
# Frontend Service (Nginx)
|
||||||
frontend:
|
frontend:
|
||||||
# Verwendet ein bereits gebautes Image
|
# Verwendet ein bereits gebautes Image
|
||||||
image: ghcr.io/mrunknownde/utools-frontend:latest
|
image: mrunknownde/utools-frontend
|
||||||
container_name: utools_frontend
|
container_name: utools_frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
Reference in New Issue
Block a user