mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-07 12:52:54 -05:00
feat(workflows): Create multiple docker images for lean image usage (#7222)
Co-authored-by: Daan Selen <dselen@systemec.nl>
This commit is contained in:
71
.github/workflows/docker.yml
vendored
71
.github/workflows/docker.yml
vendored
@@ -1,6 +1,7 @@
|
||||
name: Docker-Builder
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
@@ -9,28 +10,40 @@ on:
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
IMAGE_NAME: ${{ github.repository || 'MeshCentral' }}
|
||||
REGISTRY_USERNAME: ${{ github.repository_owner || 'DaanSelen' }}
|
||||
|
||||
jobs:
|
||||
|
||||
check-token:
|
||||
name: Check Token
|
||||
build-images:
|
||||
name: Build Docker Images
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
token_defined: ${{ steps.token_check.outputs.token_defined }}
|
||||
steps:
|
||||
- name: Check token
|
||||
id: token_check
|
||||
env:
|
||||
MY_TOKEN: ${{ secrets.MY_TOKEN }}
|
||||
if: "${{ env.MY_TOKEN != '' }}"
|
||||
run: echo "token_defined=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
needs: [check-token]
|
||||
if: needs.check-token.outputs.token_defined == 'true'
|
||||
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"
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -50,7 +63,7 @@ jobs:
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.repository_owner }}
|
||||
username: ${{ env.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.MY_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
@@ -58,6 +71,7 @@ jobs:
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
github-token: ${{ secrets.MY_TOKEN }}
|
||||
env:
|
||||
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
|
||||
|
||||
@@ -84,22 +98,13 @@ jobs:
|
||||
file: docker/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
tags: ${{ steps.meta.outputs.tags }}${{ matrix.variant.tag_suffix }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
annotations: ${{ steps.meta.outputs.annotations }}
|
||||
build-args: |
|
||||
INCLUDE_MONGODB_TOOLS=true
|
||||
INCLUDE_POSTGRESQL_TOOLS=true
|
||||
INCLUDE_MARIADB_TOOLS=true
|
||||
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
|
||||
|
||||
#- name: Docker Scout
|
||||
# id: docker-scout
|
||||
# uses: docker/scout-action@v1
|
||||
# with:
|
||||
# command: quickview,cves
|
||||
# image: image://
|
||||
# summary: true
|
||||
# only-severities: critical,high,medium,low,unspecified
|
||||
|
||||
Reference in New Issue
Block a user