added mongodb-service to docker-compose.yml (readme.md)
Simon Schön committed
Jun 6, 2022 at 19:44 UTC
e17e181d5befaad92e8d8f94f401fb148d0142f6
3 files changed
+140
-33
docker/config.json.template
+11
-10
@@ -2,6 +2,7 @@
2
"$schema": "http://info.meshcentral.com/downloads/meshcentral-config-schema.json",
3
"settings": {
4
"plugins":{"enabled": false},
5
+ "_mongoDb": null,
6
"cert": "myserver.mydomain.com",
7
"_WANonly": true,
8
"_LANonly": true,
@@ -17,20 +18,20 @@
18
"WebRTC": false
19
},
20
"domains": {
20
- "": {
21
- "_title": "MyServer",
22
- "_title2": "Servername",
23
- "minify": true,
24
- "NewAccounts": true,
25
- "localSessionRecording": false,
26
- "_userNameIsEmail": true,
27
- "_certUrl": "my.reverse.proxy"
28
- }
21
+ "": {
22
+ "_title": "MyServer",
23
+ "_title2": "Servername",
24
+ "minify": true,
25
+ "NewAccounts": true,
26
+ "localSessionRecording": false,
27
+ "_userNameIsEmail": true,
28
+ "_certUrl": "my.reverse.proxy"
29
+ }
30
},
31
"_letsencrypt": {
32
"__comment__": "Requires NodeJS 8.x or better, Go to https://letsdebug.net/ first before>",
33
"_email": "myemail@mydomain.com",
34
"_names": "myserver.mydomain.com",
34
- "production": false
35
+ "production": false
36
}
37
}
\ No newline at end of file
docker/readme.md
+123
-23
@@ -2,32 +2,132 @@
2
# How to create a docker image for meshcentral
3
4
```
5
-git clone https://github.com/Ylianst/MeshCentral.git
6
-cd MeshCentral/docker
7
-docker build -t meshcentral .
5
+> git clone https://github.com/Ylianst/MeshCentral.git
6
+> cd MeshCentral
7
+
8
+> docker build -f docker/Dockerfile --force-rm -t meshcentral .
9
+
10
+# (optional) cleanup after docker build:
11
+> cd ..
12
+> rm -rf MeshCentral/
13
```
14
10
-docker-compose.yml example:
15
+> | Argument | Description |
16
+> | :--- | :--- |
17
+> | -f docker/Dockerfile | Path/Name of the Dockerfile |
18
+> | --force-rm | Always remove intermediate containers |
19
+> | -t meshcentral | Name and optionally a tag in the 'name:tag' format |
20
+
21
+# Create folder-structure and files
22
+
23
+```
24
+| - meshcentral/ # this folder contains the persistent data
25
+ | - data/ # MeshCentral data-files
26
+ | - user_files/ # where file uploads for users live
27
+ | - web/ # location for site customization files
28
+ | - backup/ # location for the meshcentral-backups
29
+| - .env # environment file with initial variables
30
+| - docker-compose.yml
31
+```
32
+
33
+# Templates:
34
+## .env:
35
+```ini
36
+NODE_ENV=production
37
+
38
+# initial mongodb-variables
39
+MONGO_INITDB_ROOT_USERNAME=mongodbadmin
40
+MONGO_INITDB_ROOT_PASSWORD=mongodbpasswd
41
+
42
+# initial meshcentral-variables
43
+# the following options are only used if no config.json exists in the data-folder
44
+
45
+# your hostname
46
+HOSTNAME=my.domain.com
47
+USE_MONGODB=false
48
+# set to your reverse proxy IP if you want to put meshcentral behind a reverse proxy
49
+REVERSE_PROXY=false
50
+REVERSE_PROXY_TLS_PORT=
51
+# set to true if you wish to enable iframe support
52
+IFRAME=false
53
+# set to false if you want disable self-service creation of new accounts besides the first (admin)
54
+ALLOW_NEW_ACCOUNTS=true
55
+# 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
56
+WEBRTC=false
57
+# set to true to allow plugins
58
+ALLOWPLUGINS=false
59
+# set to true to allow session recording
60
+LOCALSESSIONRECORDING=false
61
+# set to enable or disable minification of json, reduces traffic
62
+MINIFY=true
63
+```
64
+
65
+## docker-compose.yml:
66
+```yaml
67
+version: '3'
68
+
69
+services:
70
+ meshcentral:
71
+ restart: always
72
+ container_name: meshcentral
73
+ image: meshcentral
74
+ ports:
75
+ # 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
76
+ - 8086:443
77
+ env_file:
78
+ - .env
79
+ volumes:
80
+ # config.json and other important files live here. A must for data persistence
81
+ - ./meshcentral/data:/opt/meshcentral/meshcentral-data
82
+ # where file uploads for users live
83
+ - ./meshcentral/user_files:/opt/meshcentral/meshcentral-files
84
+ # location for the meshcentral-backups - this should be mounted to an external storage
85
+ - ./meshcentral/backup:/opt/meshcentral/meshcentral-backup
86
+ # location for site customization files
87
+ - ./meshcentral/web:/opt/meshcentral/meshcentral-web
88
+```
89
+
90
+## docker-compose.yml mongodb:
91
```yaml
92
version: '3'
93
+
94
+networks:
95
+ meshcentral-tier:
96
+ driver: bridge
97
+
98
services:
14
- meshcentral:
15
- restart: always
16
- container_name: meshcentral
17
- image: einar/meshcentral
18
- ports:
19
- - 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
20
- environment:
21
- - HOSTNAME=my.domain.com #your hostname
22
- - REVERSE_PROXY=false #set to your reverse proxy IP if you want to put meshcentral behind a reverse proxy
23
- - REVERSE_PROXY_TLS_PORT=
24
- - IFRAME=false #set to true if you wish to enable iframe support
25
- - ALLOW_NEW_ACCOUNTS=true #set to false if you want disable self-service creation of new accounts besides the first (admin)
26
- - 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
27
- - ALLOWPLUGINS=false #set to true to allow plugins
28
- - LOCALSESSIONRECORDING=false # set to true to allow session recording
29
- - MINIFY=true #set to enable or disable minification of json, reduces traffic
30
- volumes:
31
- - ./meshcentral/data:/opt/meshcentral/meshcentral-data #config.json and other important files live here. A must for data persistence
32
- - ./meshcentral/user_files:/opt/meshcentral/meshcentral-files #where file uploads for users live
99
+ mongodb:
100
+ restart: always
101
+ container_name: mongodb
102
+ image: mongo:latest
103
+ env_file:
104
+ - .env
105
+ volumes:
106
+ # mongodb data-directory - A must for data persistence
107
+ - ./meshcentral/mongodb_data:/data/db
108
+ networks:
109
+ - meshcentral-tier
110
+
111
+ meshcentral:
112
+ restart: always
113
+ container_name: meshcentral
114
+ image: meshcentral
115
+ depends_on:
116
+ - mongodb
117
+ ports:
118
+ # 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
119
+ - 8086:443
120
+ env_file:
121
+ - .env
122
+ volumes:
123
+ # config.json and other important files live here. A must for data persistence
124
+ - ./meshcentral/data:/opt/meshcentral/meshcentral-data
125
+ # where file uploads for users live
126
+ - ./meshcentral/user_files:/opt/meshcentral/meshcentral-files
127
+ # location for the meshcentral-backups - this should be mounted to an external storage
128
+ - ./meshcentral/backup:/opt/meshcentral/meshcentral-backup
129
+ # location for site customization files
130
+ - ./meshcentral/web:/opt/meshcentral/meshcentral-web
131
+ networks:
132
+ - meshcentral-tier
133
```
docker/startup.sh
+6
@@ -8,12 +8,18 @@ export REVERSE_PROXY_TLS_PORT
8
export IFRAME
9
export ALLOW_NEW_ACCOUNTS
10
export WEBRTC
11
+export MONGO_INITDB_ROOT_USERNAME
12
+export MONGO_INITDB_ROOT_PASSWORD
13
+export USE_MONGODB
14
15
if [ -f "meshcentral-data/config.json" ]
16
then
17
node meshcentral/meshcentral
18
else
19
cp config.json.template meshcentral-data/config.json
20
+ if [ $USE_MONGODB == true ]; then
21
+ sed -i "s/\"_mongoDb\": null/\"mongoDb\": \"mongodb:\/\/$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@mongodb:27017\"/" meshcentral-data/config.json
22
+ fi
23
sed -i "s/\"cert\": \"myserver.mydomain.com\"/\"cert\": \"$HOSTNAME\"/" meshcentral-data/config.json
24
sed -i "s/\"NewAccounts\": true/\"NewAccounts\": \"$ALLOW_NEW_ACCOUNTS\"/" meshcentral-data/config.json
25
sed -i "s/\"enabled\": false/\"enabled\": \"$ALLOWPLUGINS\"/" meshcentral-data/config.json