2022-07-23 07:17:05 -04:00
|
|
|
FROM alpine:latest AS base
|
2021-11-02 09:54:10 -04:00
|
|
|
|
|
|
|
#Add non-root user, add installation directories and assign proper permissions
|
2022-07-23 07:17:05 -04:00
|
|
|
RUN mkdir -p /opt/meshcentral/meshcentral
|
2021-11-02 09:54:10 -04:00
|
|
|
|
2022-06-06 13:39:36 -04:00
|
|
|
# meshcentral installation
|
2022-07-22 12:50:33 -04:00
|
|
|
WORKDIR /opt/meshcentral
|
2021-11-02 09:54:10 -04:00
|
|
|
|
2022-07-23 07:17:05 -04:00
|
|
|
RUN apk update \
|
|
|
|
&& apk add --no-cache --update nodejs npm bash \
|
|
|
|
&& rm -rf /var/cache/apk/*
|
|
|
|
RUN npm install -g npm@latest
|
2021-12-12 16:04:21 -05:00
|
|
|
|
2022-06-06 13:39:36 -04:00
|
|
|
|
2022-06-07 20:46:40 -04:00
|
|
|
FROM base AS builder
|
2022-06-06 13:39:36 -04:00
|
|
|
|
2022-06-08 08:21:23 -04:00
|
|
|
ARG DISABLE_MINIFY=""
|
2022-06-09 15:25:01 -04:00
|
|
|
ARG DISABLE_TRANSLATE=""
|
2022-06-08 08:21:23 -04:00
|
|
|
|
2022-06-07 20:46:40 -04:00
|
|
|
COPY ./ /opt/meshcentral/meshcentral/
|
2022-06-06 13:39:36 -04:00
|
|
|
|
2022-06-09 15:25:01 -04:00
|
|
|
RUN if ! [ -z "$DISABLE_MINIFY" ] && [ "$DISABLE_MINIFY" != "yes" ] && [ "$DISABLE_MINIFY" != "YES" ] \
|
|
|
|
&& [ "$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; \
|
|
|
|
fi
|
|
|
|
RUN if ! [ -z "$DISABLE_TRANSLATE" ] && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "$DISABLE_TRANSLATE" != "YES" ] \
|
|
|
|
&& [ "$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; \
|
|
|
|
fi
|
|
|
|
|
2022-07-22 12:50:33 -04:00
|
|
|
# install translate/minify modules if need too
|
|
|
|
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral && npm install html-minifier jsdom minify-js; fi
|
|
|
|
|
2022-07-22 11:21:29 -04:00
|
|
|
# first extractall if need too
|
2022-07-22 12:50:33 -04:00
|
|
|
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; fi
|
2022-06-08 08:21:23 -04:00
|
|
|
|
|
|
|
# minify files
|
2022-07-22 12:50:33 -04:00
|
|
|
RUN if [ -z "$DISABLE_MINIFY" ]; then cd meshcentral/translate && node translate.js minifyall; fi
|
2022-06-06 13:39:36 -04:00
|
|
|
|
|
|
|
# translate
|
2022-07-22 12:50:33 -04:00
|
|
|
RUN if [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js translateall; fi
|
2021-11-02 09:54:10 -04:00
|
|
|
|
2022-07-23 07:17:05 -04:00
|
|
|
# cleanup
|
|
|
|
RUN rm -rf /opt/meshcentral/meshcentral/docker
|
|
|
|
RUN rm -rf /opt/meshcentral/meshcentral/node_modules
|
|
|
|
|
2022-06-07 20:46:40 -04:00
|
|
|
|
|
|
|
FROM base
|
|
|
|
|
|
|
|
ARG INCLUDE_MONGODBTOOLS=""
|
2022-07-23 07:21:19 -04: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"
|
|
|
|
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 07:22:55 -04:00
|
|
|
ENV SESSION_KEY=""
|
2022-07-23 07:21:19 -04:00
|
|
|
ENV REVERSE_PROXY="false"
|
|
|
|
ENV REVERSE_PROXY_TLS_PORT=""
|
|
|
|
|
2022-06-09 15:25:01 -04:00
|
|
|
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ] && [ "$INCLUDE_MONGODBTOOLS" != "yes" ] && [ "$INCLUDE_MONGODBTOOLS" != "YES" ] \
|
|
|
|
&& [ "$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; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
RUN if ! [ -z "$INCLUDE_MONGODBTOOLS" ]; then apk add --no-cache mongodb-tools; fi
|
2022-06-07 20:46:40 -04:00
|
|
|
|
|
|
|
# copy files from builder-image
|
|
|
|
COPY --from=builder /opt/meshcentral/meshcentral /opt/meshcentral/meshcentral
|
2022-07-23 07:17:05 -04:00
|
|
|
COPY ./docker/startup.sh ./startup.sh
|
|
|
|
COPY ./docker/config.json.template /opt/meshcentral/config.json.template
|
2022-06-07 20:46:40 -04:00
|
|
|
|
2022-07-22 11:21:29 -04:00
|
|
|
# install dependencies from package.json and nedb
|
|
|
|
RUN cd meshcentral && npm install && npm install nedb
|
2022-06-07 20:46:40 -04:00
|
|
|
|
2022-06-07 08:53:16 -04:00
|
|
|
EXPOSE 80 443 4433
|
2021-11-02 09:54:10 -04:00
|
|
|
|
2022-06-06 13:40:49 -04:00
|
|
|
# volumes
|
2021-11-02 09:54:10 -04:00
|
|
|
VOLUME /opt/meshcentral/meshcentral-data
|
|
|
|
VOLUME /opt/meshcentral/meshcentral-files
|
2022-06-06 13:40:49 -04:00
|
|
|
VOLUME /opt/meshcentral/meshcentral-web
|
|
|
|
VOLUME /opt/meshcentral/meshcentral-backup
|
2021-11-02 09:54:10 -04:00
|
|
|
|
2022-06-06 13:39:36 -04:00
|
|
|
CMD ["bash", "/opt/meshcentral/startup.sh"]
|