Files
MeshCentral/.github/workflows/docker.yml
DaanSelen 5032755c29 fix: workflow again where every tag is given. (#7293)
* Workflow split (#14)

* Made the workflow build multiple images for simplicity

* New method

* Trying workflow

* Finalize

* Reset package files to upstream/master

* Edit workflow according to @si458

* Whoops accidentally removed these. Back again.

* Testing out embedded tokens

* Workflow split (#12)

* Made the workflow build multiple images for simplicity

* New method

* Trying workflow

* Finalize

* Reset package files to upstream/master

* Edit workflow according to @si458

* Whoops accidentally removed these. Back again.

* Testing out embedded tokens

---------

Co-authored-by: Daan Selen <dselen@systemec.nl>

* Why the flip do we even use that???

* Testing out suggestions of permissions

* Testing fallback.

* Remove fallback

* Minor removal of comment

---------

Co-authored-by: Daan Selen <dselen@systemec.nl>

* fix: workflow like we want

---------

Co-authored-by: Daan Selen <dselen@systemec.nl>
2025-09-24 20:51:56 +01:00

135 lines
3.8 KiB
YAML

---
name: Docker-Builder
on:
workflow_dispatch:
push:
branches:
- master
release:
types: [ published ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository || 'MeshCentral' }}
REGISTRY_USERNAME: ${{ github.repository_owner || 'meshcentral-extensions' }}
jobs:
build-images:
name: Build Docker Images
permissions:
packages: write
contents: read
runs-on: ubuntu-latest
strategy:
#max-parallel: 1
matrix:
variant:
- name: complete
include_mongodb: true
include_postgresql: true
include_mysql: true
tag_suffix: ""
- name: mongodb
include_mongodb: true
include_postgresql: false
include_mysql: false
tag_suffix: "-mongodb"
- name: postgresql
include_mongodb: false
include_postgresql: true
include_mysql: false
tag_suffix: "-postgresql"
- name: mysql
include_mongodb: false
include_postgresql: false
include_mysql: true
tag_suffix: "-mysql"
- name: slim
include_mongodb: false
include_postgresql: false
include_mysql: false
tag_suffix: "-slim"
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ secrets.MY_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
github-token: ${{ secrets.MY_TOKEN }}
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- name: Install Translate Packages (allowed to fail)
working-directory: ./translate
run: node translate.js || true
- name: Run extractall
working-directory: ./translate
run: node translate.js extractall
- name: Run minifyall
working-directory: ./translate
run: node translate.js minifyall
- name: Run translateall
working-directory: ./translate
run: node translate.js translateall
- name: process tags with suffix
id: clean-tag
run: |
SUFFIX="${{ matrix.variant.tag_suffix }}"
# Read each line into an array
mapfile -t TAGS <<< "${{ steps.meta.outputs.tags }}"
RESULT=""
for tag in "${TAGS[@]}"; do
if [ -n "$RESULT" ]; then
RESULT+=","
fi
RESULT+="${tag}${SUFFIX}"
done
echo "TAGS_WITH_SUFFIX=$RESULT" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
push: true
tags: ${{ env.TAGS_WITH_SUFFIX }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
build-args: |
INCLUDE_MONGODB_TOOLS=${{ matrix.variant.include_mongodb }}
INCLUDE_POSTGRESQL_TOOLS=${{ matrix.variant.include_postgresql }}
INCLUDE_MARIADB_TOOLS=${{ matrix.variant.include_mysql }}
DISABLE_MINIFY=yes
DISABLE_TRANSLATE=yes
PREINSTALL_LIBS=true