mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-07-16 12:21:51 -04:00
Refactored more Dockerfile
This commit is contained in:
parent
ddeeb8cd58
commit
6eb85fa892
@ -1,40 +1,47 @@
|
|||||||
### STAGE 1 BUILDING.
|
### STAGE 1 BUILDING.
|
||||||
FROM node:current-alpine AS builder
|
FROM node:lts-alpine AS builder
|
||||||
|
|
||||||
RUN mkdir -p /opt/meshcentral/meshcentral
|
|
||||||
COPY ./ /opt/meshcentral/meshcentral/
|
|
||||||
WORKDIR /opt/meshcentral
|
|
||||||
|
|
||||||
ARG DISABLE_MINIFY=""
|
ARG DISABLE_MINIFY=""
|
||||||
ARG DISABLE_TRANSLATE="yes"
|
ARG DISABLE_TRANSLATE="yes"
|
||||||
|
|
||||||
RUN if ! [ -z "$DISABLE_MINIFY" ] && [ "$DISABLE_MINIFY" != "yes" ] && [ "$DISABLE_MINIFY" != "YES" ] \
|
RUN mkdir -p /opt/meshcentral/meshcentral
|
||||||
|
COPY ./ /opt/meshcentral/meshcentral/
|
||||||
|
|
||||||
|
# Check if minify should be disabled on compilation.
|
||||||
|
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 "Invalid value for build argument DISABLE_MINIFY, possible values: 'yes' or 'true'"; \
|
||||||
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
RUN if ! [ -z "$DISABLE_TRANSLATE" ] && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "$DISABLE_TRANSLATE" != "YES" ] \
|
# Check if translations should be compiled.
|
||||||
|
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 "Invalid value for build argument DISABLE_TRANSLATE, possible values: 'yes' or 'true'"; \
|
||||||
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install translate/minify modules if need too
|
# Check the Docker build arguments and execute them accordingly.
|
||||||
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then \
|
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 meshcentral && \
|
||||||
cd translate && node translate.js extractall; \
|
npm install html-minifier@4.0.0 jsdom@26.0.0 esprima@4.0.1 && \
|
||||||
fi
|
\
|
||||||
# @minify-html/node@0.15.0
|
cd translate && \
|
||||||
|
node translate.js extractall && \
|
||||||
# minify files
|
\
|
||||||
RUN if [ -z "$DISABLE_MINIFY" ]; then \
|
if [ -z "$DISABLE_MINIFY" ]; then \
|
||||||
cd meshcentral/translate && node translate.js minifyall; \
|
node translate.js minifyall; \
|
||||||
fi
|
fi; \
|
||||||
|
\
|
||||||
# translate
|
if [ -z "$DISABLE_TRANSLATE" ]; then \
|
||||||
RUN if [ -z "$DISABLE_TRANSLATE" ]; then \
|
node translate.js translateall; \
|
||||||
cd meshcentral/translate && node translate.js translateall; \
|
fi \
|
||||||
fi
|
fi
|
||||||
|
# Possible more updated alternative? @minify-html/node@0.15.0 -> https://www.npmjs.com/package/@minify-html/node
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
|
RUN ls -l /opt/meshcentral/meshcentral
|
||||||
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
|
||||||
|
|
||||||
@ -42,17 +49,6 @@ RUN rm -rf /opt/meshcentral/meshcentral/node_modules
|
|||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
RUN mkdir -p /opt/meshcentral/meshcentral
|
|
||||||
|
|
||||||
# meshcentral installation
|
|
||||||
WORKDIR /opt/meshcentral
|
|
||||||
|
|
||||||
RUN apk update \
|
|
||||||
&& 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
|
|
||||||
|
|
||||||
ARG INCLUDE_MONGODBTOOLS=""
|
ARG INCLUDE_MONGODBTOOLS=""
|
||||||
ARG PREINSTALL_LIBS="false"
|
ARG PREINSTALL_LIBS="false"
|
||||||
|
|
||||||
@ -72,19 +68,29 @@ ENV LOCALSESSIONRECORDING="true"
|
|||||||
ENV MINIFY="false"
|
ENV MINIFY="false"
|
||||||
ENV WEBRTC="false"
|
ENV WEBRTC="false"
|
||||||
ENV IFRAME="false"
|
ENV IFRAME="false"
|
||||||
ENV SESSION_KEY=""
|
|
||||||
ENV REVERSE_PROXY="false"
|
ENV REVERSE_PROXY="false"
|
||||||
ENV REVERSE_PROXY_TLS_PORT=""
|
ENV REVERSE_PROXY_TLS_PORT=""
|
||||||
ENV ARGS=""
|
ENV ARGS=""
|
||||||
ENV ALLOWED_ORIGIN="false"
|
ENV ALLOWED_ORIGIN="false"
|
||||||
|
|
||||||
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ] && [ "$INCLUDE_MONGODBTOOLS" != "yes" ] && [ "$INCLUDE_MONGODBTOOLS" != "YES" ] \
|
RUN mkdir -p /opt/meshcentral/meshcentral
|
||||||
|
|
||||||
|
# meshcentral installation
|
||||||
|
WORKDIR /opt/meshcentral
|
||||||
|
|
||||||
|
RUN apk update \
|
||||||
|
&& 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
|
||||||
|
|
||||||
|
# NOTE: ALL MODULES MUST HAVE A VERSION NUMBER AND THE VERSION MUST MATCH THAT USED IN meshcentral.js mainStart()
|
||||||
|
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
|
else \
|
||||||
|
|
||||||
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ]; then \
|
|
||||||
apk add --no-cache mongodb-tools; \
|
apk add --no-cache mongodb-tools; \
|
||||||
|
cd meshcentral && npm install mongodb@6.15.0 saslprep@1.0.3; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# copy files from builder-image
|
# copy files from builder-image
|
||||||
@ -95,12 +101,8 @@ 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()
|
RUN if ! [ -z "$PREINSTALL_LIBS" ] \
|
||||||
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ]; then \
|
&& [ "$PREINSTALL_LIBS" == "true" ]; 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; \
|
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
|
fi
|
||||||
|
|
||||||
@ -112,4 +114,5 @@ 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
|
||||||
|
|
||||||
|
WORKDIR /opt/meshcentral
|
||||||
CMD ["bash", "/opt/meshcentral/entrypoint.sh"]
|
CMD ["bash", "/opt/meshcentral/entrypoint.sh"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user