feat: add debian-based docker image (#7414)
Signed-off-by: Simon Smith <simonsmith5521@gmail.com> Signed-off-by: si458 <simonsmith5521@gmail.com> Co-authored-by: Daan Selen <dselen@systemec.nl> Co-authored-by: Simon Smith <simonsmith5521@gmail.com> Co-authored-by: TheDevRyan <175502913+The-Dev-Ryan@users.noreply.github.com>
DaanSelen committed
Nov 20, 2025 at 13:28 UTC
a8c3c8f977b01e493293c5a3a170368507225ccb
10 files changed
+546
-156
.dockerignore
+2
@@ -10,3 +10,5 @@ docs/
10
*.sln
11
*.njsproj
12
*.md
13
+examples
14
+tests
\ No newline at end of file
.github/workflows/docker-alpine.yml
renamed
+3
-3
@@ -1,9 +1,9 @@
1
-name: Docker-Builder
1
+name: Docker-Builder-Alpine
2
3
on:
4
workflow_dispatch:
5
schedule:
6
- - cron: '2 0 * * *' # Daily at 00:02 UTC
6
+ - cron: '0 0 * * *' # Daily at 00:00 UTC
7
release:
8
types: [ published ]
9
@@ -95,7 +95,7 @@ jobs:
95
.
96
97
build-arm64:
98
- runs-on: ubuntu-22.04-arm
98
+ runs-on: ubuntu-24.04-arm
99
needs: translate
100
strategy:
101
fail-fast: false
.github/workflows/docker-debian.yml
new
+230
@@ -0,0 +1,230 @@
1
+name: Docker-Builder-Debian
2
+
3
+on:
4
+ workflow_dispatch:
5
+ schedule:
6
+ - cron: '0 1 * * *' # Daily at 01:00 UTC (I think)
7
+ release:
8
+ types: [ published ]
9
+
10
+jobs:
11
+
12
+ translate:
13
+ runs-on: ubuntu-24.04
14
+ name: Run Translations
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v5
18
+ - name: Set up Node.js
19
+ uses: actions/setup-node@v6
20
+ with:
21
+ node-version: "lts/*"
22
+ - name: Run translate.js (ignore errors)
23
+ run: node translate.js || true
24
+ working-directory: translate
25
+ - name: Run translate extractall
26
+ run: node translate extractall
27
+ working-directory: translate
28
+ - name: Run translate.js minifyall
29
+ run: node translate.js minifyall
30
+ working-directory: translate
31
+ - name: Run translate.js translateall
32
+ run: node translate.js translateall
33
+ working-directory: translate
34
+ - name: Upload repo with translations
35
+ uses: actions/upload-artifact@v5
36
+ with:
37
+ name: repo-with-translations
38
+ path: .
39
+
40
+ build-amd64:
41
+ runs-on: ubuntu-24.04
42
+ needs: translate
43
+ strategy:
44
+ fail-fast: false
45
+ max-parallel: 3
46
+ matrix:
47
+ variant: [mongodb, postgresql, mariadb, all, slim]
48
+ name: Build Docker Image (amd64-${{ matrix.variant }})
49
+ steps:
50
+ - name: Download repo artifact
51
+ uses: actions/download-artifact@v5
52
+ with:
53
+ name: repo-with-translations
54
+ - name: Set up QEMU
55
+ uses: docker/setup-qemu-action@v3
56
+ with:
57
+ cache-image: false
58
+ platforms: amd64
59
+ - name: Set up Docker Buildx
60
+ uses: docker/setup-buildx-action@v3
61
+ with:
62
+ cache-binary: false
63
+ - name: Log in to GitHub Container Registry
64
+ uses: docker/login-action@v3
65
+ with:
66
+ registry: ghcr.io
67
+ username: ${{ github.repository_owner }}
68
+ password: ${{ secrets.MY_TOKEN || secrets.GITHUB_TOKEN }}
69
+ - name: Build and push Docker image (amd64-${{ matrix.variant }})
70
+ run: |
71
+ REPO_OWNER_LC="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
72
+ case "${{ matrix.variant }}" in
73
+ mongodb)
74
+ MONGODB=YES; POSTGRESQL=NO; MARIADB=NO; TAG="-amd64-mongodb-debian";;
75
+ postgresql)
76
+ MONGODB=NO; POSTGRESQL=YES; MARIADB=NO; TAG="-amd64-postgresql-debian";;
77
+ mariadb)
78
+ MONGODB=NO; POSTGRESQL=NO; MARIADB=YES; TAG="-amd64-mariadb-debian";;
79
+ all)
80
+ MONGODB=YES; POSTGRESQL=YES; MARIADB=YES; TAG="-amd64-debian";;
81
+ slim)
82
+ MONGODB=NO; POSTGRESQL=NO; MARIADB=NO; TAG="-amd64-slim-debian";;
83
+ esac
84
+ docker buildx build \
85
+ --platform linux/amd64 \
86
+ --build-arg INCLUDE_MONGODB_TOOLS=$MONGODB \
87
+ --build-arg INCLUDE_POSTGRESQL_TOOLS=$POSTGRESQL \
88
+ --build-arg INCLUDE_MARIADB_TOOLS=$MARIADB \
89
+ --build-arg DISABLE_MINIFY=yes \
90
+ --build-arg DISABLE_TRANSLATE=yes \
91
+ --build-arg DISABLE_EXTRACT=yes \
92
+ --build-arg PREINSTALL_LIBS=true \
93
+ -f docker/Dockerfile-debian \
94
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}$TAG \
95
+ --push \
96
+ .
97
+
98
+ build-arm64:
99
+ runs-on: ubuntu-24.04-arm
100
+ needs: translate
101
+ strategy:
102
+ fail-fast: false
103
+ max-parallel: 3
104
+ matrix:
105
+ variant: [mongodb, postgresql, mariadb, all, slim]
106
+ name: Build Docker Image (arm64-${{ matrix.variant }})
107
+ steps:
108
+ - name: Download repo artifact
109
+ uses: actions/download-artifact@v5
110
+ with:
111
+ name: repo-with-translations
112
+ - name: Set up QEMU
113
+ uses: docker/setup-qemu-action@v3
114
+ with:
115
+ cache-image: false
116
+ platforms: arm64
117
+ - name: Set up Docker Buildx
118
+ uses: docker/setup-buildx-action@v3
119
+ with:
120
+ cache-binary: false
121
+ - name: Log in to GitHub Container Registry
122
+ uses: docker/login-action@v3
123
+ with:
124
+ registry: ghcr.io
125
+ username: ${{ github.repository_owner }}
126
+ password: ${{ secrets.MY_TOKEN || secrets.GITHUB_TOKEN }}
127
+ - name: Build and push Docker image (arm64-${{ matrix.variant }})
128
+ run: |
129
+ REPO_OWNER_LC="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
130
+ case "${{ matrix.variant }}" in
131
+ mongodb)
132
+ MONGODB=YES; POSTGRESQL=NO; MARIADB=NO; TAG="-arm64-mongodb-debian";;
133
+ postgresql)
134
+ MONGODB=NO; POSTGRESQL=YES; MARIADB=NO; TAG="-arm64-postgresql-debian";;
135
+ mariadb)
136
+ MONGODB=NO; POSTGRESQL=NO; MARIADB=YES; TAG="-arm64-mariadb-debian";;
137
+ all)
138
+ MONGODB=YES; POSTGRESQL=YES; MARIADB=YES; TAG="-arm64-debian";;
139
+ slim)
140
+ MONGODB=NO; POSTGRESQL=NO; MARIADB=NO; TAG="-arm64-slim-debian";;
141
+ esac
142
+ docker buildx build \
143
+ --platform linux/arm64 \
144
+ --build-arg INCLUDE_MONGODB_TOOLS=$MONGODB \
145
+ --build-arg INCLUDE_POSTGRESQL_TOOLS=$POSTGRESQL \
146
+ --build-arg INCLUDE_MARIADB_TOOLS=$MARIADB \
147
+ --build-arg DISABLE_MINIFY=yes \
148
+ --build-arg DISABLE_TRANSLATE=yes \
149
+ --build-arg DISABLE_EXTRACT=yes \
150
+ --build-arg PREINSTALL_LIBS=true \
151
+ -f docker/Dockerfile-debian \
152
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}$TAG \
153
+ --push \
154
+ .
155
+
156
+ merge-manifest:
157
+ runs-on: ubuntu-24.04
158
+ needs:
159
+ - translate
160
+ - build-amd64
161
+ - build-arm64
162
+ name: Create and Push Multi-Arch Manifest
163
+ steps:
164
+ - name: Set up Docker Buildx
165
+ uses: docker/setup-buildx-action@v3
166
+ with:
167
+ cache-binary: false
168
+ - name: Log in to GitHub Container Registry
169
+ uses: docker/login-action@v3
170
+ with:
171
+ registry: ghcr.io
172
+ username: ${{ github.repository_owner }}
173
+ password: ${{ secrets.MY_TOKEN || secrets.GITHUB_TOKEN }}
174
+ - name: Create and push multi-arch manifests for all variants
175
+ run: |
176
+ REPO_OWNER_LC="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
177
+ # mongodb
178
+ docker buildx imagetools create \
179
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-mongodb-debian \
180
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-amd64-mongodb-debian \
181
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-arm64-mongodb-debian \
182
+ # postgresql
183
+ docker buildx imagetools create \
184
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-postgresql-debian \
185
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-amd64-postgresql-debian \
186
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-arm64-postgresql-debian \
187
+ # mariadb
188
+ docker buildx imagetools create \
189
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-mariadb-debian \
190
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-amd64-mariadb-debian \
191
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-arm64-mariadb-debian \
192
+ # all (no suffix)
193
+ docker buildx imagetools create \
194
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-debian \
195
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-amd64-debian \
196
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-arm64-debian \
197
+ # slim
198
+ docker buildx imagetools create \
199
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-slim-debian \
200
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-amd64-slim-debian \
201
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-arm64-slim-debian \
202
+ - name: Create and push 'latest' tags (releases only)
203
+ if: github.event_name == 'release'
204
+ run: |
205
+ REPO_OWNER_LC="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
206
+ # latest-mongodb
207
+ docker buildx imagetools create \
208
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:latest-mongodb-debian \
209
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-amd64-mongodb-debian \
210
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-arm64-mongodb-debian \
211
+ # latest-postgresql
212
+ docker buildx imagetools create \
213
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:latest-postgresql-debian \
214
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-amd64-postgresql-debian \
215
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-arm64-postgresql-debian \
216
+ # latest-mariadb
217
+ docker buildx imagetools create \
218
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:latest-mariadb-debian \
219
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-amd64-mariadb-debian \
220
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-arm64-mariadb-debian \
221
+ # latest (all databases)
222
+ docker buildx imagetools create \
223
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:latest-debian \
224
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-amd64-debian \
225
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-arm64-debian \
226
+ # latest-slim
227
+ docker buildx imagetools create \
228
+ -t ghcr.io/$REPO_OWNER_LC/meshcentral:latest-slim-debian \
229
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-amd64-slim-debian \
230
+ ghcr.io/$REPO_OWNER_LC/meshcentral:${{ github.ref_name }}-arm64-slim-debian \
docker/01_nodoc
new
+18
@@ -0,0 +1,18 @@
1
+# Exclude unneeded documentation files to save space
2
+
3
+# Don't install package docs
4
+path-exclude=/usr/share/doc/*
5
+path-include=/usr/share/doc/*/copyright
6
+
7
+# Don't install man pages
8
+path-exclude=/usr/share/man/*
9
+
10
+# Don't install localized man pages
11
+path-exclude=/usr/share/locale/*
12
+
13
+# Optional: exclude info pages
14
+path-exclude=/usr/share/info/*
15
+
16
+# Optional: exclude lintian and other package data
17
+path-exclude=/usr/share/lintian/*
18
+path-exclude=/usr/share/linda/*
docker/Dockerfile
+17
-19
@@ -49,8 +49,7 @@ RUN rm -rf /opt/meshcentral/meshcentral/docker /opt/meshcentral/meshcentral/node
49
50
FROM node:22-alpine3.22 AS dep-compiler
51
52
-RUN apk update && \
53
- echo -e "----------\nINSTALLING ALPINE PACKAGES...\n----------"; \
52
+RUN echo -e "----------\nINSTALLING ALPINE PACKAGES...\n----------"; \
53
apk add --no-cache --update \
54
bash gcc g++ jq make python3 tzdata
55
@@ -59,13 +58,15 @@ WORKDIR /opt/meshcentral/meshcentral
58
59
RUN jq '.dependencies += {"modern-syslog": "1.2.0", "telegram": "2.26.22"}' package.json > temp.json && mv temp.json package.json \
60
&& npm i --package-lock-only \
62
- && npm ci
61
+ && npm ci --omit=dev \
62
+ && npm cache clean --force
63
64
-### STAGE 3 RUNTIME
64
+### STAGE 3 BUILDING.
65
66
-FROM node:22-alpine3.22 AS runtime
66
+FROM node:22-alpine3.22 AS finalizer
67
+#FROM alpine:3.22 AS finalizer
68
68
-# # Copy prepared app from builder stage
69
+# copy files from previous layer
70
COPY --from=dep-compiler /opt/meshcentral/meshcentral /opt/meshcentral/meshcentral
71
72
# environment variables
@@ -122,12 +123,12 @@ ENV MARIADB_HOST="" \
123
MARIADB_PASS="" \
124
MARIADB_DATABASE=""
125
126
+RUN mkdir -p /opt/meshcentral/meshcentral
127
WORKDIR /opt/meshcentral
128
127
-RUN apk update && \
128
- echo -e "----------\nINSTALLING ALPINE PACKAGES...\n----------"; \
129
+RUN echo -e "----------\nINSTALLING ALPINE PACKAGES...\n----------"; \
130
apk add --no-cache --update \
130
- bash curl jq nodejs npm tzdata && \
131
+ bash curl jq tzdata && \
132
rm -rf /var/cache/* \
133
/tmp/* \
134
/usr/share/man/ \
@@ -189,25 +190,22 @@ RUN case "$INCLUDE_MARIADB_TOOLS" in \
190
exit 1;; \
191
esac
192
192
-# install dependencies from package.json
193
-RUN cd meshcentral && \
194
- npm cache clean --force && \
195
- rm -rf /root/ /tmp/
193
+# Remove left over files and cache
194
+RUN cd meshcentral \
195
+ && rm -rf /root /tmp/* /var/tmp/* /usr/lib/node_modules/npm/man /usr/lib/node_modules/npm/doc /usr/lib/node_modules/npm/html \
196
+ && npm cache clean --force
197
198
# Expose needed ports
199
EXPOSE 80 443
200
200
-# These volumes will be created by default even without any declaration, this allows default persistence in Docker/Podman.
201
+# These volumes will be created by default even without any declaration, this allows default persistence in Docker/Podman. Dummy-proofing.
202
VOLUME /opt/meshcentral/meshcentral-data
203
VOLUME /opt/meshcentral/meshcentral-files
204
VOLUME /opt/meshcentral/meshcentral-web
205
VOLUME /opt/meshcentral/meshcentral-backups
206
207
# Copy images from Git repo, place it before ending so recompilation can make good use of cache.
207
-COPY ./docker/entrypoint.sh /opt/meshcentral/entrypoint.sh
208
+COPY ./docker/entrypoint.sh /opt/meshcentral/entrypoint.sh
209
COPY ./docker/config.json.template /opt/meshcentral/config.json.template
210
210
-HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
211
- CMD curl -k --fail https://localhost:443/health.ashx || exit 1
212
-
213
-ENTRYPOINT ["bash", "/opt/meshcentral/entrypoint.sh"]
211
+ENTRYPOINT ["bash", "/opt/meshcentral/entrypoint.sh"]
\ No newline at end of file
docker/Dockerfile-debian
new
+238
@@ -0,0 +1,238 @@
1
+### STAGE 1 BUILDING.
2
+FROM node:22-trixie-slim AS builder
3
+
4
+# Any value inside one of the disable ARGs will be accepted.
5
+ARG DISABLE_EXTRACT="yes"
6
+ARG DISABLE_MINIFY="yes"
7
+ARG DISABLE_TRANSLATE="yes"
8
+# NODE_OPTIONS="--max_old_space_size=4096"
9
+# If your process gets OOM killed, perhaps the above will help.
10
+
11
+RUN mkdir -p /opt/meshcentral/meshcentral
12
+WORKDIR /opt/meshcentral
13
+COPY ./ /opt/meshcentral/meshcentral/
14
+
15
+# Check the Docker build arguments and if they are empty do the task.
16
+RUN if [ -n "$DISABLE_EXTRACT" ] || [ -n "$DISABLE_MINIFY" ] || [ -n "$DISABLE_TRANSLATE" ]; then \
17
+ echo -e "----------\nPREPARING ENVIRONMENT...\n----------"; \
18
+ cd meshcentral && \
19
+ npm install html-minifier-terser@7.2.0 jsdom@26.0.0 esprima@4.0.1 && \
20
+ cd translate && \
21
+ case "$DISABLE_EXTRACT" in \
22
+ false|no|FALSE|NO) \
23
+ echo -e "----------\nSTARTING THE EXTRACTING PROCESS...\n----------"; \
24
+ node translate.js extractall;; \
25
+ *) \
26
+ echo "Setting EXTRACT as disabled.";; \
27
+ esac && \
28
+ case "$DISABLE_MINIFY" in \
29
+ false|no|FALSE|NO) \
30
+ echo -e "----------\nSTARTING THE MINIFYING PROCESS...\n----------"; \
31
+ node translate.js minifyall;; \
32
+ *) \
33
+ echo "Setting MINIFY as disabled.";; \
34
+ esac && \
35
+ case "$DISABLE_TRANSLATE" in \
36
+ false|no|FALSE|NO) \
37
+ echo -e "----------\nSTARTING THE TRANSLATING PROCESS...\n----------"; \
38
+ node translate.js translateall;; \
39
+ *) \
40
+ echo "Setting TRANSLATE as disabled.";; \
41
+ esac; \
42
+ npm uninstall html-minifier-terser jsdom esprima; \
43
+ fi
44
+# Possible more updated alternative? @minify-html/node@0.15.0 -> https://www.npmjs.com/package/@minify-html/node
45
+
46
+RUN rm -rf /opt/meshcentral/meshcentral/docker /opt/meshcentral/meshcentral/node_modules /opt/meshcentral/meshcentral/docs
47
+
48
+### STAGE 2 PRECOMPILE DEPS MODULE
49
+
50
+FROM node:22-trixie-slim AS dep-compiler
51
+
52
+ENV NODE_ENV="production"
53
+
54
+RUN apt-get update && \
55
+ echo -e "----------\nINSTALLING DEBIAN PACKAGES...\n----------"; \
56
+ apt-get install -y --no-install-recommends --no-install-suggests \
57
+ bash gcc g++ jq make python3 tzdata
58
+
59
+COPY --from=builder /opt/meshcentral/meshcentral /opt/meshcentral/meshcentral
60
+WORKDIR /opt/meshcentral/meshcentral
61
+
62
+RUN jq '.dependencies += {"modern-syslog": "1.2.0", "telegram": "2.26.22"}' package.json > temp.json && mv temp.json package.json \
63
+ && npm i --package-lock-only \
64
+ && npm ci --omit=dev \
65
+ && npm cache clean --force
66
+
67
+### STAGE 3 fun. building from source...
68
+
69
+FROM golang:trixie AS mongo-tools-compiler
70
+
71
+ARG INCLUDE_MONGODB_TOOLS="false"
72
+
73
+RUN apt-get update && \
74
+ apt-get install -y --no-install-recommends --no-install-suggests \
75
+ git lsb-release
76
+
77
+RUN case "$INCLUDE_MONGODB_TOOLS" in \
78
+ true|yes|TRUE|YES) \
79
+ git clone https://github.com/mongodb/mongo-tools /mongo-tools; \
80
+ cd /mongo-tools; \
81
+ ./make build -pkgs=mongodump,mongorestore;; \
82
+ false|no|FALSE|NO) \
83
+ echo "Not building MongoDB Tools from source, what a shame!"; \
84
+ mkdir -p /mongo-tools/bin;; \
85
+ *) \
86
+ echo "Invalid value for build argument INCLUDE_MONGODB_TOOLS, possible values: 'yes', 'true', 'no' or 'false'"; \
87
+ exit 1;; \
88
+ esac
89
+
90
+### STAGE 4 BUILDING.
91
+
92
+FROM node:22-trixie-slim AS finalizer
93
+
94
+# Copy files from previous layers
95
+COPY --from=dep-compiler /opt/meshcentral/meshcentral /opt/meshcentral/meshcentral
96
+COPY --from=mongo-tools-compiler /mongo-tools/bin/ /tmp/bin/
97
+
98
+# environment variables
99
+ENV NODE_ENV="production" \
100
+ CONFIG_FILE="/opt/meshcentral/meshcentral-data/config.json" \
101
+ DYNAMIC_CONFIG="false"
102
+
103
+# environment variables for the above defined MeshCentral Config.json. Can be done like that following: https://docs.docker.com/reference/dockerfile/#env
104
+ENV ALLOW_PLUGINS="false" \
105
+ ALLOW_NEW_ACCOUNTS="false" \
106
+ ALLOWED_ORIGIN="false" \
107
+ IFRAME="false" \
108
+ REGEN_SESSIONKEY="false" \
109
+ WEBRTC="false" \
110
+ LOCAL_SESSION_RECORDING="true" \
111
+ MINIFY="true" \
112
+ HOSTNAME="localhost" \
113
+ REVERSE_PROXY="" \
114
+ REVERSE_PROXY_TLS_PORT="443" \
115
+ TRUSTED_PROXY="" \
116
+ ARGS=""
117
+
118
+# Database
119
+# Multi-variable declaration to reduce layers.
120
+ENV USE_MONGODB="false" \
121
+ USE_POSTGRESQL="false" \
122
+ USE_MARIADB="false"
123
+
124
+# Preinstallation args one per line due to: https://docs.docker.com/reference/dockerfile/#arg
125
+ARG PREINSTALL_LIBS="false"
126
+ARG INCLUDE_MONGODB_TOOLS="false"
127
+ARG INCLUDE_POSTGRESQL_TOOLS="false"
128
+ARG INCLUDE_MARIADB_TOOLS="false"
129
+
130
+# MongoDB Variables
131
+# The following MONGO_URL variable overwrites most other mongoDb related varialbes.
132
+ENV MONGO_HOST="" \
133
+ MONGO_PORT="27017" \
134
+ MONGO_USERNAME="" \
135
+ MONGO_PASS="" \
136
+ MONGO_URL=""
137
+
138
+# PostgreSQL Variables
139
+ENV PSQL_HOST="" \
140
+ PSQL_PORT="5432" \
141
+ PSQL_USER="" \
142
+ PSQL_PASS="" \
143
+ PSQL_DATABASE=""
144
+
145
+# MariaDB/MySQL Variables.
146
+ENV MARIADB_HOST="" \
147
+ MARIADB_PORT="3306" \
148
+ MARIADB_USER="" \
149
+ MARIADB_PASS="" \
150
+ MARIADB_DATABASE=""
151
+
152
+WORKDIR /opt/meshcentral
153
+
154
+RUN apt-get update && \
155
+ echo -e "----------\nINSTALLING DEBIAN PACKAGES...\n----------"; \
156
+ apt-get install -y --no-install-recommends --no-install-suggests \
157
+ bash curl jq tzdata && \
158
+ rm -rf \
159
+ /var/cache/* \
160
+ /usr/share/man/ \
161
+ /usr/share/doc/ \
162
+ /var/log/* \
163
+ /var/spool/* \
164
+ /var/tmp/* \
165
+ /usr/lib/debug/ && \
166
+ npm install -g npm@latest
167
+
168
+RUN case "$PREINSTALL_LIBS" in \
169
+ true|yes|TRUE|YES) \
170
+ cd meshcentral && \
171
+ echo -e "----------\nPREINSTALLING LIBRARIES...\n----------"; \
172
+ npm install ssh2@1.16.0 nodemailer@6.10.1 image-size@2.0.2 wildleek@2.0.0 otplib@12.0.1 yub@0.11.1;; \
173
+ false|no|FALSE|NO) \
174
+ echo "Not pre-installing libraries.";; \
175
+ *) \
176
+ echo -e "Invalid value for build argument INCLUDE_POSTGRESQL_TOOLS, possible values: 'yes', 'true', 'no' or 'false'"; \
177
+ exit 1;; \
178
+ esac
179
+
180
+# NOTE: ALL MODULES MUST HAVE A VERSION NUMBER AND THE VERSION MUST MATCH THAT USED IN meshcentraljs mainStart()
181
+RUN case "$INCLUDE_MONGODB_TOOLS" in \
182
+ true|yes|TRUE|YES) \
183
+ mv /tmp/bin/* /usr/bin; \
184
+ cd meshcentral && \
185
+ echo -e "----------\nPREINSTALLING MONGODB LIBRARIES...\n----------"; \
186
+ npm install mongodb@4.17.2 @mongodb-js/saslprep@1.3.1;; \
187
+ false|no|FALSE|NO) \
188
+ echo "Not including MongoDB Tools.";; \
189
+ *) \
190
+ echo "Invalid value for build argument INCLUDE_MONGODB_TOOLS, possible values: 'yes', 'true', 'no' or 'false'"; \
191
+ exit 1;; \
192
+ esac
193
+
194
+RUN case "$INCLUDE_POSTGRESQL_TOOLS" in \
195
+ true|yes|TRUE|YES) \
196
+ apt-get install -y --no-install-recommends --no-install-suggests postgresql-client-17; \
197
+ cd meshcentral && \
198
+ echo -e "----------\nPREINSTALLING POSTGRESQL LIBRARIES...\n----------"; \
199
+ npm install pg@8.14.1;; \
200
+ false|no|FALSE|NO) \
201
+ echo "Not including PostgreSQL Tools.";; \
202
+ *) \
203
+ echo -e "Invalid value for build argument INCLUDE_POSTGRESQL_TOOLS, possible values: 'yes', 'true', 'no' or 'false'"; \
204
+ exit 1;; \
205
+ esac
206
+
207
+RUN case "$INCLUDE_MARIADB_TOOLS" in \
208
+ true|yes|TRUE|YES) \
209
+ apt-get install -y --no-install-recommends --no-install-suggests default-mysql-client mariadb-client; \
210
+ cd meshcentral && \
211
+ echo -e "----------\nPREINSTALLING MARIADB/MYSQL LIBRARIES...\n----------"; \
212
+ npm install mariadb@3.4.0 mysql2@3.11.4;; \
213
+ false|no|FALSE|NO) \
214
+ echo "Not including MariaDB/MySQL Tools.";; \
215
+ *) \
216
+ echo -e "Invalid value for build argument INCLUDE_MARIADB_TOOLS, possible values: 'yes', 'true', 'no' or 'false'"; \
217
+ exit 1;; \
218
+ esac
219
+
220
+# Remove left over files and cache
221
+RUN cd meshcentral \
222
+ && rm -rf /root /tmp/* /var/tmp/* /usr/lib/node_modules/npm/man /usr/lib/node_modules/npm/doc /usr/lib/node_modules/npm/html \
223
+ && npm cache clean --force
224
+
225
+# Expose needed ports
226
+EXPOSE 80 443
227
+
228
+# These volumes will be created by default even without any declaration, this allows default persistence in Docker/Podman. Dummy-proofing.
229
+VOLUME /opt/meshcentral/meshcentral-data
230
+VOLUME /opt/meshcentral/meshcentral-files
231
+VOLUME /opt/meshcentral/meshcentral-web
232
+VOLUME /opt/meshcentral/meshcentral-backups
233
+
234
+# Copy images from Git repo, place it before ending so recompilation can make good use of cache.
235
+COPY ./docker/entrypoint.sh /opt/meshcentral/entrypoint.sh
236
+COPY ./docker/config.json.template /opt/meshcentral/config.json.template
237
+
238
+ENTRYPOINT ["bash", "/opt/meshcentral/entrypoint.sh"]
\ No newline at end of file
docker/README.md
+11
@@ -27,6 +27,17 @@ So for another quick example: if you want to get a released version with a Mongo
27
So for another quick example: if you want a very slim image with the latest code and only a local database: `ghcr.io/ylianst/meshcentral:master-slim`<br>
28
So as a last example: if you want to get a MariaDB/MySQL backend with MeshCentral version 1.1.53: `ghcr.io/ylianst/meshcentral:1.1.53-mysql`
29
30
+## Persistency
31
+
32
+The Docker image has since recently removed its default creation of volumes. It might not be what you want.<br>
33
+If you still want to use volumes to make data persist across containers use Docker volumes (or Kubernetes PVCs).<br>
34
+For examples of how to use these volumes, see the examples below. Most data resides inside:
35
+
36
+- /opt/meshcentral/meshcentral-backups
37
+- /opt/meshcentral/meshcentral-data (most important! Server configurations, certificates, etc... reside here.)
38
+- /opt/meshcentral/meshcentral-files
39
+- /opt/meshcentral/meshcentral-web (relevant if you use a custom theme, such as [Stylish-UI](https://github.com/melo-professional/Meshcentral-Stylish-UI))
40
+
41
## Environment Variables
42
Below is a breakdown of environment variables used in this setup.
43
docker/build-all-variants.sh
new
+15
@@ -0,0 +1,15 @@
1
+#!/bin/bash
2
+
3
+if command -v docker > /dev/null; then
4
+ docker build ../. -f Dockerfile -t meshcentral:alpine-slim --build-arg=PREINSTALL_LIBS=true --build-arg=INCLUDE_MONGODB_TOOLS=false --build-arg=INCLUDE_POSTGRESQL_TOOLS=false --build-arg=INCLUDE_MARIADB_TOOLS=false
5
+ docker build ../. -f Dockerfile -t meshcentral:alpine-complete --build-arg=PREINSTALL_LIBS=true --build-arg=INCLUDE_MONGODB_TOOLS=true --build-arg=INCLUDE_POSTGRESQL_TOOLS=true --build-arg=INCLUDE_MARIADB_TOOLS=true
6
+ docker build ../. -f Dockerfile -t meshcentral:alpine-mongodb --build-arg=PREINSTALL_LIBS=true --build-arg=INCLUDE_MONGODB_TOOLS=true --build-arg=INCLUDE_POSTGRESQL_TOOLS=false --build-arg=INCLUDE_MARIADB_TOOLS=false
7
+ docker build ../. -f Dockerfile -t meshcentral:alpine-postgresql --build-arg=PREINSTALL_LIBS=true --build-arg=INCLUDE_MONGODB_TOOLS=false --build-arg=INCLUDE_POSTGRESQL_TOOLS=true --build-arg=INCLUDE_MARIADB_TOOLS=false
8
+ docker build ../. -f Dockerfile -t meshcentral:alpine-mysql --build-arg=PREINSTALL_LIBS=true --build-arg=INCLUDE_MONGODB_TOOLS=false --build-arg=INCLUDE_POSTGRESQL_TOOLS=false --build-arg=INCLUDE_MARIADB_TOOLS=true
9
+
10
+ docker build ../. -f Dockerfile-debian -t meshcentral:debian-slim --build-arg=PREINSTALL_LIBS=true --build-arg=INCLUDE_MONGODB_TOOLS=false --build-arg=INCLUDE_POSTGRESQL_TOOLS=false --build-arg=INCLUDE_MARIADB_TOOLS=false
11
+ docker build ../. -f Dockerfile-debian -t meshcentral:debian-complete --build-arg=PREINSTALL_LIBS=true --build-arg=INCLUDE_MONGODB_TOOLS=true --build-arg=INCLUDE_POSTGRESQL_TOOLS=true --build-arg=INCLUDE_MARIADB_TOOLS=true
12
+ docker build ../. -f Dockerfile-debian -t meshcentral:debian-mongodb --build-arg=PREINSTALL_LIBS=true --build-arg=INCLUDE_MONGODB_TOOLS=true --build-arg=INCLUDE_POSTGRESQL_TOOLS=false --build-arg=INCLUDE_MARIADB_TOOLS=false
13
+ docker build ../. -f Dockerfile-debian -t meshcentral:debian-postgresql --build-arg=PREINSTALL_LIBS=true --build-arg=INCLUDE_MONGODB_TOOLS=false --build-arg=INCLUDE_POSTGRESQL_TOOLS=true --build-arg=INCLUDE_MARIADB_TOOLS=false
14
+ docker build ../. -f Dockerfile-debian -t meshcentral:debian-mysql --build-arg=PREINSTALL_LIBS=true --build-arg=INCLUDE_MONGODB_TOOLS=false --build-arg=INCLUDE_POSTGRESQL_TOOLS=false --build-arg=INCLUDE_MARIADB_TOOLS=true
15
+fi
docker/entrypoint.sh
+12
-2
@@ -14,12 +14,22 @@ trap graceful_shutdown SIGTERM
14
# Make the start more cleared when restarted.
15
echo "-------------------------------------------------------------"
16
date
17
-echo "Config file: $CONFIG_FILE"
17
+if [ -n "$CONFIG_FILE" ]; then
18
+ echo "Config file: $CONFIG_FILE"
19
+else
20
+ exit 1
21
+fi
22
23
# Failsafe to create a new config if the expected config is not there.
24
if [ -f "${CONFIG_FILE}" ]; then
25
echo "Pre-existing config found, not recreating..."
26
else
27
+ if [ ! -d $(dirname "$CONFIG_FILE") ]; then
28
+ echo "Creating meshcentral-data directory..."
29
+ mkdir -p /opt/meshcentral/meshcentral-data
30
+ fi
31
+
32
+ echo "Placing template into the relevant directory: $(dirname $CONFIG_FILE)"
33
cp /opt/meshcentral/config.json.template "${CONFIG_FILE}"
34
fi
35
@@ -260,7 +270,7 @@ if [[ ${DYNAMIC_CONFIG,,} =~ ^(true|yes)$ ]]; then
270
271
cat "$CONFIG_FILE"
272
else
263
- echo "Leaving config as-is."
273
+ echo "Leaving config as-is. Dynamic Configuration is off."
274
fi
275
276
# Actually start MeshCentral.
docker/tools/docker.build.sh
deleted
-132
@@ -1,132 +0,0 @@
1
-#!/bin/bash
2
-
3
-MSG="";
4
-PRUNE="false";
5
-OVERRIDE_TAGS="false";
6
-ENABLE_LOG="false";
7
-LOG_FILE="$(dirname -- "$( readlink -f -- "$0"; )")/build.log";
8
-
9
-function appendOutput()
10
-{
11
- if [ -z "${MSG}" ]; then echo -e "\n" > /dev/tty; fi
12
-
13
- ARGS=$@;
14
- LINE="${ARGS}\n";
15
- if [ -z "${ENABLE_LOG}" ] || [ "${ENABLE_LOG}" != "true" ]; then echo -e "${LINE}" > /dev/tty; else echo -e "${LINE}" 2>&1 | tee -a ${LOG_FILE}; fi
16
-
17
- MSG="${MSG}${LINE}";
18
-}
19
-
20
-function runDockerBuild()
21
-{
22
- if [ "${PRUNE}" == "true" ]; then
23
- if [ -z "${ENABLE_LOG}" ] || [ "${ENABLE_LOG}" != "true" ]; then docker system prune -a -f;
24
- else docker system prune -a -f | tee -a ${LOG_FILE}; fi
25
- fi
26
-
27
- STARTTS=$(date +%s);
28
- ARGS=$@;
29
-
30
- APP_VERSION=$(grep -o '"version":\s*"[^"]*"' ./package.json | cut -f4- -d\" | tr -d '"');
31
- BASE_TAGS="";
32
- if [ -z "${OVERRIDE_TAGS}" ] || [ "${OVERRIDE_TAGS}" != "true" ]; then
33
- BASE_TAGS="-t meshcentral:latest -t meshcentral:${APP_VERSION}";
34
- fi
35
-
36
- BUILD_CMD="docker build -f docker/Dockerfile --force-rm --no-cache ${ARGS} ${BASE_TAGS} .";
37
- appendOutput "Current build: ${BUILD_CMD}";
38
-
39
- if [ -z "${ENABLE_LOG}" ] || [ "${ENABLE_LOG}" != "true" ]; then ${BUILD_CMD}; else ${BUILD_CMD} | tee -a ${LOG_FILE}; fi
40
- if [ $? -ne 0 ]; then exit $?; fi
41
-
42
- IMAGEID=$(docker images --format "{{.ID}} {{.CreatedAt}}" | sort -rk 2 | awk 'NR==1{print $1}');
43
- appendOutput "\tImageId: ${IMAGEID}";
44
-
45
- ENDTS=$(date +%s);
46
- DIFSEC=$((${ENDTS}-${STARTTS}));
47
- if [ ${DIFSEC} -ge 60 ]; then
48
- TMPMIN=$((${DIFSEC}/60));
49
- TMPSEC=$((${DIFSEC}%60));
50
-
51
- if [ ${TMPMIN} -ge 60 ]; then
52
- TMPHOUR=$((${TMPMIN}/60));
53
- TMPMIN=$((${TMPMIN}%60));
54
-
55
- appendOutput "\tBuild time: ${TMPHOUR} hr ${TMPMIN} min ${TMPSEC} sec";
56
- else appendOutput "\tBuild time: ${TMPMIN} min ${TMPSEC} sec"; fi
57
- else appendOutput "\tBuild time: ${DIFSEC} sec"; fi
58
-
59
- IMG_SIZE=$(docker image inspect ${IMAGEID} | grep -o '"Size":\s*[^,]*' | cut -f2- -d ':' | tr -d ' ');
60
- expr $IMG_SIZE + 0 > /dev/null;
61
- appendOutput "\tImage size: ${IMG_SIZE} ($((${IMG_SIZE}/1024/1024))M)\n";
62
-
63
- return 0;
64
-}
65
-
66
-parent_path=$(dirname -- $(dirname -- "$( readlink -f -- "$0"; )"));
67
-if [ "${parent_path}" != "$(pwd -P)" ]; then
68
- echo -e "change working directory to: ${parent_path}" > /dev/tty;
69
- cd "${parent_path}";
70
-fi
71
-
72
-if ! [ -z $1 ]; then
73
- for arg in "$@"
74
- do
75
- case "${arg}" in
76
- --prune)
77
- PRUNE="true";
78
- shift 1;
79
- ;;
80
- --log)
81
- ENABLE_LOG="true";
82
- shift 1;
83
- ;;
84
- --no-tags)
85
- OVERRIDE_TAGS="true";
86
- shift 1;
87
- ;;
88
- --help)
89
- __usage="\n
90
- Usage: ./$(basename ${0}) [OPTIONS] [BUILD ARGUMENTS]\n
91
- \n
92
- Options:\n
93
- \t--log \t\twrite output to build.log file\n
94
- \t--no-tags \tdo not use default tags (meshcentral:latest and meshcentral:%VERSION%)\n
95
- \t--prune \tWARNING: This will remove:\n
96
- \t\t\t - all stopped docker containers\n
97
- \t\t\t - all docker networks not used by at least one container\n
98
- \t\t\t - all docker images without at least one container associated to them\n
99
- \t\t\t - all docker build cache\n
100
- \n
101
- Build arguments: \tAll build arguments are forwarded to the docker build command, so you can use any option accepted by 'docker build'\n
102
- \t\t\t(https://docs.docker.com/engine/reference/commandline/build/#options)\n\n
103
- \t--build-arg INCLUDE_MONGODBTOOLS=yes \tIncludes mongodb-tools (mongodump, ...) in the image\n
104
- \t--build-arg DISABLE_MINIFY=yes \t\tDisables minification of files\n
105
- \t--build-arg DISABLE_TRANSLATE=yes \tDisables translation of files\n
106
- ";
107
- echo -e $__usage;
108
- exit 0;
109
- ;;
110
- *)
111
- break;
112
- ;;
113
- esac
114
- done
115
-fi
116
-
117
-MAINARGS=$@;
118
-
119
-#runDockerBuild --build-arg DISABLE_MINIFY=yes --build-arg DISABLE_TRANSLATE=yes ${MAINARGS};
120
-#runDockerBuild --build-arg DISABLE_TRANSLATE=yes ${MAINARGS};
121
-#runDockerBuild --build-arg DISABLE_MINIFY=yes ${MAINARGS};
122
-runDockerBuild ${MAINARGS};
123
-
124
-#runDockerBuild --build-arg INCLUDE_MONGODBTOOLS=yes --build-arg DISABLE_MINIFY=yes --build-arg DISABLE_TRANSLATE=yes ${MAINARGS};
125
-#runDockerBuild --build-arg INCLUDE_MONGODBTOOLS=yes --build-arg DISABLE_TRANSLATE=yes ${MAINARGS};
126
-#runDockerBuild --build-arg INCLUDE_MONGODBTOOLS=yes --build-arg DISABLE_MINIFY=yes ${MAINARGS};
127
-#runDockerBuild --build-arg INCLUDE_MONGODBTOOLS=yes ${MAINARGS};
128
-
129
-echo "";
130
-if [ -z "${ENABLE_LOG}" ] || [ "${ENABLE_LOG}" != "true" ]; then echo -e "${MSG}"; else echo -e "${MSG}" 2>&1 | tee -a ${LOG_FILE}; fi
131
-
132
-exit 0;