From cd090691ccab5f606e1de80a5704d3071d82ab50 Mon Sep 17 00:00:00 2001 From: Einar Stenberg Date: Tue, 2 Nov 2021 14:54:10 +0100 Subject: [PATCH 1/9] Create Dockerfile --- Dockerfile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..12f5cbec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Filename: Dockerfile + +FROM ubuntu:latest + +# Disable Prompt During Packages Installation +ARG DEBIAN_FRONTEND=noninteractive + +#install dependencies +RUN apt-get update && apt-get install -y nodejs npm nano + +#Add non-root user, add installation directories and assign proper permissions +RUN mkdir -p /opt/meshcentral + +#meshcentral installation +WORKDIR /opt/meshcentral + +RUN npm install meshcentral + +COPY config.json.template /opt/meshcentral/config.json.template +COPY startup.sh startup.sh +#environment variables + +EXPOSE 80 443 + +#volumes +VOLUME /opt/meshcentral/meshcentral-data +VOLUME /opt/meshcentral/meshcentral-files + +CMD ["bash","/opt/meshcentral/startup.sh"] From 9d32a03c8244a1edae55c69981fba928df0b8f36 Mon Sep 17 00:00:00 2001 From: Einar Stenberg Date: Tue, 2 Nov 2021 14:56:22 +0100 Subject: [PATCH 2/9] Create config.json.template --- docker/config.json.template | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docker/config.json.template diff --git a/docker/config.json.template b/docker/config.json.template new file mode 100644 index 00000000..4df6a6d7 --- /dev/null +++ b/docker/config.json.template @@ -0,0 +1,34 @@ +{ + "$schema": "http://info.meshcentral.com/downloads/meshcentral-config-schema.json", + "settings": { + "cert": "myserver.mydomain.com", + "_WANonly": true, + "_LANonly": true, + "_sessionKey": "MyReallySecretPassword1", + "port": 443, + "_aliasPort": 443, + "redirPort": 80, + "_redirAliasPort": 80, + "AgentPong": 300, + "TLSOffload": false, + "SelfUpdate": false, + "AllowFraming": false, + "WebRTC": false + }, + "domains": { + "": { + "_title": "MyServer", + "_title2": "Servername", + "_minify": true, + "NewAccounts": true, + "_userNameIsEmail": true, + "_certUrl": "my.reverse.proxy" + } + }, + "_letsencrypt": { + "__comment__": "Requires NodeJS 8.x or better, Go to https://letsdebug.net/ first before>", + "_email": "myemail@mydomain.com", + "_names": "myserver.mydomain.com", + "production": false + } +} From a11631502d58fcb0f46a9e050ee85ffdafc07a0a Mon Sep 17 00:00:00 2001 From: Einar Stenberg Date: Tue, 2 Nov 2021 14:56:53 +0100 Subject: [PATCH 3/9] Create startup.sh --- docker/startup.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docker/startup.sh diff --git a/docker/startup.sh b/docker/startup.sh new file mode 100644 index 00000000..39a852d1 --- /dev/null +++ b/docker/startup.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +export NODE_ENV=production + +export HOSTNAME +export REVERSE_PROXY +export REVERSE_PROXY_TLS_PORT +export IFRAME +export ALLOW_NEW_ACCOUNTS +export WEBRTC + +if [ -f "meshcentral-data/config.json" ] + then + node node_modules/meshcentral + else + cp config.json.template meshcentral-data/config.json + sed -i "s/\"cert\": \"myserver.mydomain.com\"/\"cert\": \"$HOSTNAME\"/" meshcentral-data/config.json + sed -i "s/\"NewAccounts\": true/\"NewAccounts\": \"$ALLOW_NEW_ACCOUNTS\"/" meshcentral-data/config.json + sed -i "s/\"WebRTC\": false/\"WebRTC\": \"$WEBRTC\"/" meshcentral-data/config.json + sed -i "s/\"AllowFraming\": false/\"AllowFraming\": \"$IFRAME\"/" meshcentral-data/config.json + if [ "$REVERSE_PROXY" != "false" ] + then + sed -i "s/\"_certUrl\": \"my\.reverse\.proxy\"/\"certUrl\": \"https:\/\/$REVERSE_PROXY:$REVERSE_PROXY_TLS_PORT\"/" meshcentral-data/config.json + node node_modules/meshcentral + exit + fi + node node_modules/meshcentral --cert "$HOSTNAME" +fi From 7c3fcfd4a9c995d60dea3f8cbc52c9a3c507b4bf Mon Sep 17 00:00:00 2001 From: Einar Stenberg Date: Tue, 2 Nov 2021 14:57:50 +0100 Subject: [PATCH 4/9] Update Dockerfile --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 12f5cbec..84be781a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,9 @@ WORKDIR /opt/meshcentral RUN npm install meshcentral -COPY config.json.template /opt/meshcentral/config.json.template -COPY startup.sh startup.sh +#Copy config template and startup script +COPY docker/config.json.template /opt/meshcentral/config.json.template +COPY docker/startup.sh startup.sh #environment variables EXPOSE 80 443 From 7eb4b809454b5954b7f745d017a3a80e3e50cdff Mon Sep 17 00:00:00 2001 From: Einar Stenberg Date: Tue, 2 Nov 2021 15:31:56 +0100 Subject: [PATCH 5/9] Update and rename Dockerfile to docker/Dockerfile --- Dockerfile => docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename Dockerfile => docker/Dockerfile (85%) diff --git a/Dockerfile b/docker/Dockerfile similarity index 85% rename from Dockerfile rename to docker/Dockerfile index 84be781a..cdd0403b 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -17,8 +17,8 @@ WORKDIR /opt/meshcentral RUN npm install meshcentral #Copy config template and startup script -COPY docker/config.json.template /opt/meshcentral/config.json.template -COPY docker/startup.sh startup.sh +COPY config.json.template /opt/meshcentral/config.json.template +COPY startup.sh startup.sh #environment variables EXPOSE 80 443 From 7cf3ad1e58dccc595b81c822c406af4006b39242 Mon Sep 17 00:00:00 2001 From: Einar Stenberg Date: Tue, 2 Nov 2021 15:32:15 +0100 Subject: [PATCH 6/9] Create readme.md --- docker/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 docker/readme.md diff --git a/docker/readme.md b/docker/readme.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/docker/readme.md @@ -0,0 +1 @@ + From ec1e1d631f6d7845f62d50761b42f797e026f698 Mon Sep 17 00:00:00 2001 From: Einar Stenberg Date: Tue, 2 Nov 2021 15:33:49 +0100 Subject: [PATCH 7/9] Update readme.md --- docker/readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker/readme.md b/docker/readme.md index 8b137891..9840ea51 100644 --- a/docker/readme.md +++ b/docker/readme.md @@ -1 +1,5 @@ +# How to create a docker image for meshcentral + + +docker build -t meshcentral . From 6e5e77f547b91df6dee375c90d7c3bbd653022a0 Mon Sep 17 00:00:00 2001 From: Einar Stenberg Date: Tue, 2 Nov 2021 15:37:06 +0100 Subject: [PATCH 8/9] Update readme.md --- docker/readme.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/docker/readme.md b/docker/readme.md index 9840ea51..0d35ab5d 100644 --- a/docker/readme.md +++ b/docker/readme.md @@ -1,5 +1,30 @@ # How to create a docker image for meshcentral - +``` +git clone https://github.com/Ylianst/MeshCentral.git +cd MeshCentral/docker docker build -t meshcentral . +``` + +docker-compose.yml example: +```yaml +version: '2' +services: + meshcentral: + restart: always + container_name: meshcentral + image: meshcentral + ports: + - 8086:443 #MeshCentral will moan and try everything not to use port 80, but you can also use it if you so desire, just change the config.json according to your needs + environment: + - HOSTNAME=my.domain.com #your hostname + - REVERSE_PROXY=false #set to your reverse proxy IP if you want to put meshcentral behind a reverse proxy + - REVERSE_PROXY_TLS_PORT= + - IFRAME=false #set to true if you wish to enable iframe support + - ALLOW_NEW_ACCOUNTS=true #set to false if you want disable self-service creation of new accounts besides the first (admin) + - WEBRTC=false #set to true to enable WebRTC - per documentation it is not officially released with meshcentral, but is solid enough to work with. Use with caution + volumes: + - ./meshcentral/data:/opt/meshcentral/meshcentral-data #config.json and other important files live here. A must for data persistence + - ./meshcentral/user_files:/opt/meshcentral/meshcentral-files #where file uploads for users live +``` From bf4345efbd54ab69246bad98612451e704543c31 Mon Sep 17 00:00:00 2001 From: Einar Stenberg Date: Tue, 2 Nov 2021 15:37:43 +0100 Subject: [PATCH 9/9] Update readme.md --- docker/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/readme.md b/docker/readme.md index 0d35ab5d..76480c33 100644 --- a/docker/readme.md +++ b/docker/readme.md @@ -16,7 +16,7 @@ services: container_name: meshcentral image: meshcentral ports: - - 8086:443 #MeshCentral will moan and try everything not to use port 80, but you can also use it if you so desire, just change the config.json according to your needs + - 443:443 #MeshCentral will moan and try everything not to use port 80, but you can also use it if you so desire, just change the config.json according to your needs environment: - HOSTNAME=my.domain.com #your hostname - REVERSE_PROXY=false #set to your reverse proxy IP if you want to put meshcentral behind a reverse proxy