mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-07 12:52:54 -05:00
refac(docker): half the Docker image size due to deferment of compilation (#7227)
* Merge into master (#11) * 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. --------- Co-authored-by: Daan Selen <dselen@systemec.nl> * Integrate the syslog compiler * Changed logging accordingly. * Looks to be a working prototype * chore(docker): bump alpine version * feat: make simon less anxious :P --------- Co-authored-by: Daan Selen <dselen@systemec.nl>
This commit is contained in:
2
.github/workflows/docker.yml
vendored
2
.github/workflows/docker.yml
vendored
@@ -43,7 +43,7 @@ jobs:
|
|||||||
include_postgresql: false
|
include_postgresql: false
|
||||||
include_mysql: true
|
include_mysql: true
|
||||||
tag_suffix: "-mysql"
|
tag_suffix: "-mysql"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -40,11 +40,24 @@ RUN if [ -n "$DISABLE_MINIFY" ] || [ -n "$DISABLE_TRANSLATE" ]; then \
|
|||||||
RUN rm -rf /opt/meshcentral/meshcentral/docker
|
RUN rm -rf /opt/meshcentral/meshcentral/docker
|
||||||
RUN rm -rf /opt/meshcentral/meshcentral/node_modules
|
RUN rm -rf /opt/meshcentral/meshcentral/node_modules
|
||||||
|
|
||||||
### STAGE 2 BUILDING.
|
### STAGE 2 PRECOMPILE SYSLOG MODULE
|
||||||
|
|
||||||
FROM alpine:3.22
|
FROM alpine:3.22 AS syslog-compiler
|
||||||
|
|
||||||
# copy files from builder-image
|
RUN apk update && \
|
||||||
|
echo -e "----------\nINSTALLING ALPINE PACKAGES...\n----------"; \
|
||||||
|
apk add --no-cache --update \
|
||||||
|
bash gcc g++ jq make nodejs npm python3 tzdata
|
||||||
|
|
||||||
|
RUN mkdir -p /opt/syslog
|
||||||
|
WORKDIR /opt/syslog
|
||||||
|
RUN npm install modern-syslog
|
||||||
|
|
||||||
|
### STAGE 3 RUNTIME
|
||||||
|
|
||||||
|
FROM alpine:3.22 AS runtime
|
||||||
|
|
||||||
|
# Copy prepared app from builder stage
|
||||||
COPY --from=builder /opt/meshcentral/meshcentral /opt/meshcentral/meshcentral
|
COPY --from=builder /opt/meshcentral/meshcentral /opt/meshcentral/meshcentral
|
||||||
|
|
||||||
# environment variables
|
# environment variables
|
||||||
@@ -101,13 +114,12 @@ ENV MARIADB_HOST="" \
|
|||||||
MARIADB_PASS="" \
|
MARIADB_PASS="" \
|
||||||
MARIADB_DATABASE=""
|
MARIADB_DATABASE=""
|
||||||
|
|
||||||
RUN mkdir -p /opt/meshcentral/meshcentral
|
|
||||||
WORKDIR /opt/meshcentral
|
WORKDIR /opt/meshcentral
|
||||||
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
echo -e "----------\nINSTALLING ALPINE PACKAGES...\n----------"; \
|
echo -e "----------\nINSTALLING ALPINE PACKAGES...\n----------"; \
|
||||||
apk add --no-cache --update \
|
apk add --no-cache --update \
|
||||||
bash gcc g++ jq make nodejs npm python3 tzdata && \
|
bash jq nodejs npm tzdata && \
|
||||||
rm -rf /var/cache/* \
|
rm -rf /var/cache/* \
|
||||||
/tmp/* \
|
/tmp/* \
|
||||||
/usr/share/man/ \
|
/usr/share/man/ \
|
||||||
@@ -175,6 +187,12 @@ RUN cd meshcentral && \
|
|||||||
npm cache clean --force && \
|
npm cache clean --force && \
|
||||||
rm -rf /root/ /tmp/
|
rm -rf /root/ /tmp/
|
||||||
|
|
||||||
|
COPY --from=syslog-compiler /opt/syslog/node_modules/modern-syslog /opt/meshcentral/meshcentral/node_modules/modern-syslog
|
||||||
|
|
||||||
|
RUN jq '.dependencies["modern-syslog"] = "^1.2.0"' /opt/meshcentral/meshcentral/package.json \
|
||||||
|
> /opt/meshcentral/meshcentral/package.json.tmp \
|
||||||
|
&& mv /opt/meshcentral/meshcentral/package.json.tmp /opt/meshcentral/meshcentral/package.json
|
||||||
|
|
||||||
# Expose needed ports
|
# Expose needed ports
|
||||||
EXPOSE 80 443
|
EXPOSE 80 443
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
graceful_shutdown() {
|
graceful_shutdown() {
|
||||||
echo "Received SIGTERM. Cleaning up..."
|
echo "Received SIGTERM from the container host. Cleaning up..."
|
||||||
node /opt/meshcentral/meshcentral/meshcentral --stop
|
kill -SIGINT $meshcentral_pid
|
||||||
|
|
||||||
echo "MeshCentral process stopped. Exiting..."
|
echo "MeshCentral process stopped. Exiting..."
|
||||||
exit 0
|
exit 0
|
||||||
@@ -11,6 +11,8 @@ trap graceful_shutdown SIGTERM
|
|||||||
|
|
||||||
### Start MeshCentral Docker Container.
|
### Start MeshCentral Docker Container.
|
||||||
|
|
||||||
|
# Make the start more cleared when restarted.
|
||||||
|
echo "-------------------------------------------------------------"
|
||||||
date
|
date
|
||||||
echo "Config file: $CONFIG_FILE"
|
echo "Config file: $CONFIG_FILE"
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
"minimist": "1.2.8",
|
"minimist": "1.2.8",
|
||||||
"multiparty": "4.2.3",
|
"multiparty": "4.2.3",
|
||||||
"node-forge": "1.3.1",
|
"node-forge": "1.3.1",
|
||||||
|
"otplib": "12.0.1",
|
||||||
"ua-client-hints-js": "0.1.2",
|
"ua-client-hints-js": "0.1.2",
|
||||||
"ua-parser-js": "1.0.40",
|
"ua-parser-js": "1.0.40",
|
||||||
"ws": "8.18.0",
|
"ws": "8.18.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user