add mydocker.yml

Signed-off-by: Simon Smith <simonsmith5521@gmail.com>
This commit is contained in:
Simon Smith 2025-10-25 20:15:04 +01:00
parent c899ee2404
commit 0e0b454b9e

170
.github/workflows/mydocker.yml vendored Normal file
View File

@ -0,0 +1,170 @@
---
name: My-Docker-Builder
on:
workflow_dispatch:
# push:
# branches:
# - master
# paths:
# - '**'
# - '!docs/**'
# release:
# types: [ published ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository || 'MeshCentral' }}
REGISTRY_USERNAME: ${{ github.repository_owner || 'meshcentral-extensions' }}
jobs:
translate:
name: Translate Job
permissions:
packages: write
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: List directory before cache
run: ls -R ./
- 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: Cache Translate Files
id: cache-translate-save
uses: actions/cache/save@v4
with:
path: ./
key: cache-translate
- name: List directory after cache
run: ls -R ./
build-image:
name: Build Docker Images
needs: translate
permissions:
packages: write
contents: read
runs-on: ubuntu-latest
strategy:
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: Restore cached Translate
id: cache-translate-restore
uses: actions/cache/restore@v4
with:
path: ./
key: cache-translate
- 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: 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