feat(workflows): Create multiple docker images for lean image usage (#7222)
Co-authored-by: Daan Selen <dselen@systemec.nl>
DaanSelen committed
Sep 16, 2025 at 19:41 UTC
0f247f835f08ed08f68afa6f372351d2fa13c8a1
1 file changed
+38
-33
.github/workflows/docker.yml
+38
-33
@@ -1,6 +1,7 @@
1
name: Docker-Builder
2
3
on:
4
+ workflow_dispatch:
5
push:
6
branches:
7
- master
@@ -9,28 +10,40 @@ on:
10
11
env:
12
REGISTRY: ghcr.io
12
- IMAGE_NAME: ${{ github.repository }}
13
+ IMAGE_NAME: ${{ github.repository || 'MeshCentral' }}
14
+ REGISTRY_USERNAME: ${{ github.repository_owner || 'DaanSelen' }}
15
16
jobs:
15
-
16
- check-token:
17
- name: Check Token
18
- runs-on: ubuntu-latest
19
- outputs:
20
- token_defined: ${{ steps.token_check.outputs.token_defined }}
21
- steps:
22
- - name: Check token
23
- id: token_check
24
- env:
25
- MY_TOKEN: ${{ secrets.MY_TOKEN }}
26
- if: "${{ env.MY_TOKEN != '' }}"
27
- run: echo "token_defined=true" >> "$GITHUB_OUTPUT"
28
-
29
- build:
30
- name: Build
17
+ build-images:
18
+ name: Build Docker Images
19
+ permissions:
20
+ packages: write
21
+ contents: read
22
runs-on: ubuntu-latest
32
- needs: [check-token]
33
- if: needs.check-token.outputs.token_defined == 'true'
23
+ strategy:
24
+ matrix:
25
+ variant:
26
+ - name: complete
27
+ include_mongodb: true
28
+ include_postgresql: true
29
+ include_mysql: true
30
+ tag_suffix: ""
31
+ - name: mongodb
32
+ include_mongodb: true
33
+ include_postgresql: false
34
+ include_mysql: false
35
+ tag_suffix: "-mongodb"
36
+ - name: postgresql
37
+ include_mongodb: false
38
+ include_postgresql: true
39
+ include_mysql: false
40
+ tag_suffix: "-postgresql"
41
+ - name: mysql
42
+ include_mongodb: false
43
+ include_postgresql: false
44
+ include_mysql: true
45
+ tag_suffix: "-mysql"
46
+
47
steps:
48
- name: Checkout repository
49
uses: actions/checkout@v4
@@ -50,7 +63,7 @@ jobs:
63
uses: docker/login-action@v3
64
with:
65
registry: ${{ env.REGISTRY }}
53
- username: ${{ github.repository_owner }}
66
+ username: ${{ env.REGISTRY_USERNAME }}
67
password: ${{ secrets.MY_TOKEN }}
68
69
- name: Extract metadata (tags, labels) for Docker
@@ -58,6 +71,7 @@ jobs:
71
uses: docker/metadata-action@v5
72
with:
73
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
74
+ github-token: ${{ secrets.MY_TOKEN }}
75
env:
76
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
77
@@ -84,22 +98,13 @@ jobs:
98
file: docker/Dockerfile
99
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
100
push: true
87
- tags: ${{ steps.meta.outputs.tags }}
101
+ tags: ${{ steps.meta.outputs.tags }}${{ matrix.variant.tag_suffix }}
102
labels: ${{ steps.meta.outputs.labels }}
103
annotations: ${{ steps.meta.outputs.annotations }}
104
build-args: |
91
- INCLUDE_MONGODB_TOOLS=true
92
- INCLUDE_POSTGRESQL_TOOLS=true
93
- INCLUDE_MARIADB_TOOLS=true
105
+ INCLUDE_MONGODB_TOOLS=${{ matrix.variant.include_mongodb }}
106
+ INCLUDE_POSTGRESQL_TOOLS=${{ matrix.variant.include_postgresql }}
107
+ INCLUDE_MARIADB_TOOLS=${{ matrix.variant.include_mysql }}
108
DISABLE_MINIFY=yes
109
DISABLE_TRANSLATE=yes
110
PREINSTALL_LIBS=true
97
-
98
- #- name: Docker Scout
99
- # id: docker-scout
100
- # uses: docker/scout-action@v1
101
- # with:
102
- # command: quickview,cves
103
- # image: image://
104
- # summary: true
105
- # only-severities: critical,high,medium,low,unspecified