2024-01-13 21:52:59 +03:00
|
|
|
FROM --platform=$BUILDPLATFORM node:20-alpine AS builder
|
2021-11-02 16:54:10 +03:00
|
|
|
|
2022-07-23 14:17:05 +03:00
|
|
|
RUN mkdir -p /opt/meshcentral/meshcentral
|
2022-11-16 12:45:22 +03:00
|
|
|
COPY ./ /opt/meshcentral/meshcentral/
|
2022-07-22 19:50:33 +03:00
|
|
|
WORKDIR /opt/meshcentral
|
2021-11-02 16:54:10 +03:00
|
|
|
|
2022-06-08 15:21:23 +03:00
|
|
|
ARG DISABLE_MINIFY=""
|
2022-06-09 22:25:01 +03:00
|
|
|
ARG DISABLE_TRANSLATE=""
|
2022-06-08 15:21:23 +03:00
|
|
|
|
2022-06-06 20:39:36 +03:00
|
|
|
|
2022-06-09 22:25:01 +03:00
|
|
|
RUN if ! [ -z "$DISABLE_MINIFY" ] && [ "$DISABLE_MINIFY" != "yes" ] && [ "$DISABLE_MINIFY" != "YES" ] \
|
|
|
|
&& [ "$DISABLE_MINIFY" != "true" ] && [ "$DISABLE_MINIFY" != "TRUE" ]; then \
|
2022-12-10 10:24:01 +03:00
|
|
|
echo -e "\e[0;31;49mInvalid value for build argument DISABLE_MINIFY, possible values: yes/true\e[;0m"; exit 1; \
|
2022-06-09 22:25:01 +03:00
|
|
|
fi
|
|
|
|
RUN if ! [ -z "$DISABLE_TRANSLATE" ] && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "$DISABLE_TRANSLATE" != "YES" ] \
|
|
|
|
&& [ "$DISABLE_TRANSLATE" != "true" ] && [ "$DISABLE_TRANSLATE" != "TRUE" ]; then \
|
2022-12-10 10:24:01 +03:00
|
|
|
echo -e "\e[0;31;49mInvalid value for build argument DISABLE_TRANSLATE, possible values: yes/true\e[;0m"; exit 1; \
|
2022-06-09 22:25:01 +03:00
|
|
|
fi
|
|
|
|
|
2022-07-22 19:50:33 +03:00
|
|
|
# install translate/minify modules if need too
|
2024-09-10 22:14:08 +03:00
|
|
|
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
|
2022-07-22 19:50:33 +03:00
|
|
|
|
2022-07-22 18:21:29 +03:00
|
|
|
# first extractall if need too
|
2022-07-22 19:50:33 +03:00
|
|
|
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; fi
|
2022-06-08 15:21:23 +03:00
|
|
|
|
|
|
|
# minify files
|
2022-07-22 19:50:33 +03:00
|
|
|
RUN if [ -z "$DISABLE_MINIFY" ]; then cd meshcentral/translate && node translate.js minifyall; fi
|
2022-06-06 20:39:36 +03:00
|
|
|
|
|
|
|
# translate
|
2022-07-22 19:50:33 +03:00
|
|
|
RUN if [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js translateall; fi
|
2021-11-02 16:54:10 +03:00
|
|
|
|
2022-07-23 14:17:05 +03:00
|
|
|
# cleanup
|
|
|
|
RUN rm -rf /opt/meshcentral/meshcentral/docker
|
|
|
|
RUN rm -rf /opt/meshcentral/meshcentral/node_modules
|
|
|
|
|
2022-06-08 03:46:40 +03:00
|
|
|
|
2024-01-13 21:52:59 +03:00
|
|
|
FROM --platform=$TARGETPLATFORM alpine:3.19
|
2022-11-16 12:45:22 +03:00
|
|
|
|
|
|
|
#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 \
|
2024-01-10 15:22:22 +03:00
|
|
|
&& apk add --no-cache --update tzdata nodejs npm bash python3 make gcc g++ \
|
2022-11-16 12:45:22 +03:00
|
|
|
&& rm -rf /var/cache/apk/*
|
|
|
|
RUN npm install -g npm@latest
|
2022-06-08 03:46:40 +03:00
|
|
|
|
|
|
|
ARG INCLUDE_MONGODBTOOLS=""
|
2022-07-23 14:35:21 +03:00
|
|
|
ARG PREINSTALL_LIBS="false"
|
2022-07-23 14:21:19 +03:00
|
|
|
|
|
|
|
# environment variables
|
|
|
|
ENV NODE_ENV="production"
|
|
|
|
ENV CONFIG_FILE="config.json"
|
|
|
|
|
|
|
|
# environment variables for initial configuration file
|
|
|
|
ENV USE_MONGODB="false"
|
|
|
|
ENV MONGO_INITDB_ROOT_USERNAME="root"
|
|
|
|
ENV MONGO_INITDB_ROOT_PASSWORD="pass"
|
2023-03-08 06:30:33 +03:00
|
|
|
ENV MONGO_URL=""
|
2022-07-23 14:21:19 +03:00
|
|
|
ENV HOSTNAME="localhost"
|
|
|
|
ENV ALLOW_NEW_ACCOUNTS="true"
|
|
|
|
ENV ALLOWPLUGINS="false"
|
|
|
|
ENV LOCALSESSIONRECORDING="false"
|
|
|
|
ENV MINIFY="true"
|
|
|
|
ENV WEBRTC="false"
|
|
|
|
ENV IFRAME="false"
|
2022-07-23 14:22:55 +03:00
|
|
|
ENV SESSION_KEY=""
|
2022-07-23 14:21:19 +03:00
|
|
|
ENV REVERSE_PROXY="false"
|
|
|
|
ENV REVERSE_PROXY_TLS_PORT=""
|
2023-09-24 18:23:28 +03:00
|
|
|
ENV ARGS=""
|
2022-07-23 14:21:19 +03:00
|
|
|
|
2022-06-09 22:25:01 +03:00
|
|
|
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ] && [ "$INCLUDE_MONGODBTOOLS" != "yes" ] && [ "$INCLUDE_MONGODBTOOLS" != "YES" ] \
|
|
|
|
&& [ "$INCLUDE_MONGODBTOOLS" != "true" ] && [ "$INCLUDE_MONGODBTOOLS" != "TRUE" ]; then \
|
2022-12-10 10:24:01 +03:00
|
|
|
echo -e "\e[0;31;49mInvalid value for build argument INCLUDE_MONGODBTOOLS, possible values: yes/true\e[;0m"; exit 1; \
|
2022-06-09 22:25:01 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ]; then apk add --no-cache mongodb-tools; fi
|
2022-06-08 03:46:40 +03:00
|
|
|
|
|
|
|
# copy files from builder-image
|
|
|
|
COPY --from=builder /opt/meshcentral/meshcentral /opt/meshcentral/meshcentral
|
2022-07-23 14:17:05 +03:00
|
|
|
COPY ./docker/startup.sh ./startup.sh
|
|
|
|
COPY ./docker/config.json.template /opt/meshcentral/config.json.template
|
2022-06-08 03:46:40 +03:00
|
|
|
|
2022-07-22 18:21:29 +03:00
|
|
|
# install dependencies from package.json and nedb
|
|
|
|
RUN cd meshcentral && npm install && npm install nedb
|
2022-06-08 03:46:40 +03:00
|
|
|
|
2024-01-12 04:49:12 +03:00
|
|
|
# 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
|
2024-10-17 22:45:11 +03:00
|
|
|
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
|
2022-07-23 14:35:21 +03:00
|
|
|
|
2022-06-07 15:53:16 +03:00
|
|
|
EXPOSE 80 443 4433
|
2021-11-02 16:54:10 +03:00
|
|
|
|
2022-06-06 20:40:49 +03:00
|
|
|
# volumes
|
2021-11-02 16:54:10 +03:00
|
|
|
VOLUME /opt/meshcentral/meshcentral-data
|
|
|
|
VOLUME /opt/meshcentral/meshcentral-files
|
2022-06-06 20:40:49 +03:00
|
|
|
VOLUME /opt/meshcentral/meshcentral-web
|
2022-12-10 10:24:01 +03:00
|
|
|
VOLUME /opt/meshcentral/meshcentral-backups
|
2021-11-02 16:54:10 +03:00
|
|
|
|
2022-06-06 20:39:36 +03:00
|
|
|
CMD ["bash", "/opt/meshcentral/startup.sh"]
|