Modified Dockerfile for readability

Renamed startup.sh to entrypoint.sh
This commit is contained in:
Daan Selen 2025-03-19 15:32:28 +01:00
parent 5cb565c005
commit da5ef522f8
2 changed files with 33 additions and 20 deletions

View File

@ -1,12 +1,12 @@
FROM --platform=$BUILDPLATFORM node:22-alpine AS builder
### STAGE 1 BUILDING.
FROM node:current-alpine AS builder
RUN mkdir -p /opt/meshcentral/meshcentral
COPY ./ /opt/meshcentral/meshcentral/
WORKDIR /opt/meshcentral
ARG DISABLE_MINIFY=""
ARG DISABLE_TRANSLATE=""
ARG DISABLE_TRANSLATE="yes"
RUN if ! [ -z "$DISABLE_MINIFY" ] && [ "$DISABLE_MINIFY" != "yes" ] && [ "$DISABLE_MINIFY" != "YES" ] \
&& [ "$DISABLE_MINIFY" != "true" ] && [ "$DISABLE_MINIFY" != "TRUE" ]; then \
@ -18,32 +18,38 @@ RUN if ! [ -z "$DISABLE_TRANSLATE" ] && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "
fi
# install translate/minify modules if need too
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral && npm install html-minifier@4.0.0 jsdom@22.1.0 esprima@4.0.1; fi
# first extractall if need too
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; fi
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then \
cd meshcentral && npm install html-minifier@4.0.0 jsdom@26.0.0 esprima@4.0.1; \
cd translate && node translate.js extractall; \
fi
# @minify-html/node@0.15.0
# minify files
RUN if [ -z "$DISABLE_MINIFY" ]; then cd meshcentral/translate && node translate.js minifyall; fi
RUN if [ -z "$DISABLE_MINIFY" ]; then \
cd meshcentral/translate && node translate.js minifyall; \
fi
# translate
RUN if [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js translateall; fi
RUN if [ -z "$DISABLE_TRANSLATE" ]; then \
cd meshcentral/translate && node translate.js translateall; \
fi
# cleanup
RUN rm -rf /opt/meshcentral/meshcentral/docker
RUN rm -rf /opt/meshcentral/meshcentral/node_modules
### STAGE 2 BUILDING.
FROM --platform=$TARGETPLATFORM alpine:3.21
FROM alpine:latest
#Add non-root user, add installation directories and assign proper permissions
RUN mkdir -p /opt/meshcentral/meshcentral
# meshcentral installation
WORKDIR /opt/meshcentral
RUN apk update \
&& apk add --no-cache --update tzdata nodejs npm bash python3 make gcc g++ \
&& apk add --no-cache --update \
tzdata nodejs npm bash python3 postgresql-client make gcc g++ \
&& rm -rf /var/cache/apk/*
RUN npm install -g npm@latest
@ -77,19 +83,26 @@ RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ] && [ "$INCLUDE_MONGODBTOOLS" != "yes" ]
echo -e "\e[0;31;49mInvalid value for build argument INCLUDE_MONGODBTOOLS, possible values: yes/true\e[;0m"; exit 1; \
fi
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ]; then apk add --no-cache mongodb-tools; fi
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ]; then \
apk add --no-cache mongodb-tools; \
fi
# copy files from builder-image
COPY --from=builder /opt/meshcentral/meshcentral /opt/meshcentral/meshcentral
COPY ./docker/startup.sh ./startup.sh
COPY ./docker/entrypoint.sh ./entrypoint.sh
COPY ./docker/config.json.template /opt/meshcentral/config.json.template
# install dependencies from package.json
RUN cd meshcentral && npm install
# NOTE: ALL MODULES MUST HAVE A VERSION NUMBER AND THE VERSION MUST MATCH THAT USED IN meshcentral.js mainStart()
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ]; then cd meshcentral && npm install mongodb@4.13.0 saslprep@1.0.3; fi
RUN if ! [ -z "$PREINSTALL_LIBS" ] && [ "$PREINSTALL_LIBS" == "true" ]; then cd meshcentral && npm install ssh2@1.16.0 semver@7.5.4 nodemailer@6.9.15 image-size@1.1.1 wildleek@2.0.0 otplib@10.2.3 yubikeyotp@0.2.0; fi
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ]; then \
cd meshcentral && npm install mongodb@6.15.0 saslprep@1.0.3; \
fi
RUN if ! [ -z "$PREINSTALL_LIBS" ] && [ "$PREINSTALL_LIBS" == "true" ]; then \
cd meshcentral && npm install ssh2@1.16.0 semver@7.7.1 nodemailer@6.10.0 image-size@2.0.1 wildleek@2.0.0 otplib@12.0.1 yubikeyotp@0.2.0; \
fi
EXPOSE 80 443 4433
@ -99,4 +112,4 @@ VOLUME /opt/meshcentral/meshcentral-files
VOLUME /opt/meshcentral/meshcentral-web
VOLUME /opt/meshcentral/meshcentral-backups
CMD ["bash", "/opt/meshcentral/startup.sh"]
CMD ["bash", "/opt/meshcentral/entrypoint.sh"]