mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-07-16 12:21:51 -04:00
Modified Dockerfile for readability
Renamed startup.sh to entrypoint.sh
This commit is contained in:
parent
5cb565c005
commit
da5ef522f8
@ -1,49 +1,55 @@
|
|||||||
FROM --platform=$BUILDPLATFORM node:22-alpine AS builder
|
### STAGE 1 BUILDING.
|
||||||
|
FROM node:current-alpine AS builder
|
||||||
|
|
||||||
RUN mkdir -p /opt/meshcentral/meshcentral
|
RUN mkdir -p /opt/meshcentral/meshcentral
|
||||||
COPY ./ /opt/meshcentral/meshcentral/
|
COPY ./ /opt/meshcentral/meshcentral/
|
||||||
WORKDIR /opt/meshcentral
|
WORKDIR /opt/meshcentral
|
||||||
|
|
||||||
ARG DISABLE_MINIFY=""
|
ARG DISABLE_MINIFY=""
|
||||||
ARG DISABLE_TRANSLATE=""
|
ARG DISABLE_TRANSLATE="yes"
|
||||||
|
|
||||||
|
|
||||||
RUN if ! [ -z "$DISABLE_MINIFY" ] && [ "$DISABLE_MINIFY" != "yes" ] && [ "$DISABLE_MINIFY" != "YES" ] \
|
RUN if ! [ -z "$DISABLE_MINIFY" ] && [ "$DISABLE_MINIFY" != "yes" ] && [ "$DISABLE_MINIFY" != "YES" ] \
|
||||||
&& [ "$DISABLE_MINIFY" != "true" ] && [ "$DISABLE_MINIFY" != "TRUE" ]; then \
|
&& [ "$DISABLE_MINIFY" != "true" ] && [ "$DISABLE_MINIFY" != "TRUE" ]; then \
|
||||||
echo -e "\e[0;31;49mInvalid value for build argument DISABLE_MINIFY, possible values: yes/true\e[;0m"; exit 1; \
|
echo -e "\e[0;31;49mInvalid value for build argument DISABLE_MINIFY, possible values: yes/true\e[;0m"; exit 1; \
|
||||||
fi
|
fi
|
||||||
RUN if ! [ -z "$DISABLE_TRANSLATE" ] && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "$DISABLE_TRANSLATE" != "YES" ] \
|
RUN if ! [ -z "$DISABLE_TRANSLATE" ] && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "$DISABLE_TRANSLATE" != "YES" ] \
|
||||||
&& [ "$DISABLE_TRANSLATE" != "true" ] && [ "$DISABLE_TRANSLATE" != "TRUE" ]; then \
|
&& [ "$DISABLE_TRANSLATE" != "true" ] && [ "$DISABLE_TRANSLATE" != "TRUE" ]; then \
|
||||||
echo -e "\e[0;31;49mInvalid value for build argument DISABLE_TRANSLATE, possible values: yes/true\e[;0m"; exit 1; \
|
echo -e "\e[0;31;49mInvalid value for build argument DISABLE_TRANSLATE, possible values: yes/true\e[;0m"; exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install translate/minify modules if need too
|
# 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
|
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; \
|
||||||
# first extractall if need too
|
cd translate && node translate.js extractall; \
|
||||||
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; fi
|
fi
|
||||||
|
# @minify-html/node@0.15.0
|
||||||
|
|
||||||
# minify files
|
# 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
|
# 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
|
# cleanup
|
||||||
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.
|
||||||
|
|
||||||
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
|
RUN mkdir -p /opt/meshcentral/meshcentral
|
||||||
|
|
||||||
# meshcentral installation
|
# meshcentral installation
|
||||||
WORKDIR /opt/meshcentral
|
WORKDIR /opt/meshcentral
|
||||||
|
|
||||||
RUN apk update \
|
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/*
|
&& rm -rf /var/cache/apk/*
|
||||||
RUN npm install -g npm@latest
|
RUN npm install -g npm@latest
|
||||||
|
|
||||||
@ -74,22 +80,29 @@ ENV ALLOWED_ORIGIN="false"
|
|||||||
|
|
||||||
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ] && [ "$INCLUDE_MONGODBTOOLS" != "yes" ] && [ "$INCLUDE_MONGODBTOOLS" != "YES" ] \
|
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ] && [ "$INCLUDE_MONGODBTOOLS" != "yes" ] && [ "$INCLUDE_MONGODBTOOLS" != "YES" ] \
|
||||||
&& [ "$INCLUDE_MONGODBTOOLS" != "true" ] && [ "$INCLUDE_MONGODBTOOLS" != "TRUE" ]; then \
|
&& [ "$INCLUDE_MONGODBTOOLS" != "true" ] && [ "$INCLUDE_MONGODBTOOLS" != "TRUE" ]; then \
|
||||||
echo -e "\e[0;31;49mInvalid value for build argument INCLUDE_MONGODBTOOLS, possible values: yes/true\e[;0m"; exit 1; \
|
echo -e "\e[0;31;49mInvalid value for build argument INCLUDE_MONGODBTOOLS, possible values: yes/true\e[;0m"; exit 1; \
|
||||||
fi
|
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 files from builder-image
|
||||||
COPY --from=builder /opt/meshcentral/meshcentral /opt/meshcentral/meshcentral
|
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
|
COPY ./docker/config.json.template /opt/meshcentral/config.json.template
|
||||||
|
|
||||||
# install dependencies from package.json
|
# install dependencies from package.json
|
||||||
RUN cd meshcentral && npm install
|
RUN cd meshcentral && npm install
|
||||||
|
|
||||||
# NOTE: ALL MODULES MUST HAVE A VERSION NUMBER AND THE VERSION MUST MATCH THAT USED IN meshcentral.js mainStart()
|
# 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 "$INCLUDE_MONGODBTOOLS" ]; then \
|
||||||
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
|
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
|
EXPOSE 80 443 4433
|
||||||
|
|
||||||
@ -99,4 +112,4 @@ VOLUME /opt/meshcentral/meshcentral-files
|
|||||||
VOLUME /opt/meshcentral/meshcentral-web
|
VOLUME /opt/meshcentral/meshcentral-web
|
||||||
VOLUME /opt/meshcentral/meshcentral-backups
|
VOLUME /opt/meshcentral/meshcentral-backups
|
||||||
|
|
||||||
CMD ["bash", "/opt/meshcentral/startup.sh"]
|
CMD ["bash", "/opt/meshcentral/entrypoint.sh"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user