Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 70e6b11

Browse files
committed
new: add mongo-express to all-in-one image for accessing of internal mongodb
1 parent dc8ccc5 commit 70e6b11

File tree

7 files changed

+87
-7
lines changed

7 files changed

+87
-7
lines changed

‎deploy/docker/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ COPY deploy/docker/frontend/nginx-http.conf /etc/nginx/nginx-http.conf
239239
COPY deploy/docker/frontend/nginx-https.conf /etc/nginx/nginx-https.conf
240240
COPY deploy/docker/frontend/ssl-certificate.conf /etc/nginx/ssl-certificate.conf
241241
COPY deploy/docker/frontend/ssl-params.conf /etc/nginx/ssl-params.conf
242+
COPY deploy/docker/all-in-one/conf/nginx_mongo-ui.conf /etc/nginx/mongo-ui.conf
242243

243244

244245
# Add lowcoder frontend
@@ -259,6 +260,11 @@ RUN mkdir -p /lowcoder/plugins/ && chown lowcoder:lowcoder /lowcoder/plugins/
259260
# Add lowcoder node-service
260261
COPY --chown=lowcoder:lowcoder --from=lowcoder-ce-node-service /lowcoder/node-service /lowcoder/node-service
261262

263+
# Add mongo-express for managing mongodb database
264+
RUN mkdir -p /lowcoder/mongo-express && chown lowcoder:lowcoder /lowcoder/mongo-express
265+
COPY --chown=lowcoder:lowcoder --from=mongo-express:1-20-alpine3.19 /app /lowcoder/mongo-express/app
266+
COPY --chown=lowcoder:lowcoder --chmod=0755 deploy/docker/all-in-one/scripts/mongo-ui-entrypoint.sh /lowcoder/mongo-express/mongo-ui-entrypoint.sh
267+
262268
# Add services configuration
263269
COPY --chown=lowcoder:lowcoder deploy/docker/all-in-one/etc /lowcoder/etc
264270

@@ -276,9 +282,9 @@ RUN echo \
276282
&& chown -R lowcoder:root /var/log \
277283
&& chmod -R g+rw /run /etc/nginx /var/cache/nginx /var/log
278284

279-
EXPOSE 27017
280285
EXPOSE 3000
281286
EXPOSE 3443
287+
EXPOSE 9999
282288

283289
ENTRYPOINT [ "/bin/sh" , "/lowcoder/entrypoint.sh" ]
284290
CMD ["/usr/bin/supervisord", "-n" , "-c" , "/lowcoder/etc/supervisord.conf"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
location /mongo-ui {
3+
proxy_set_header X-Forwarded-Proto $scheme;
4+
proxy_set_header X-Forwarded-Host $host;
5+
proxy_set_header X-Forwarded-For $remote_addr;
6+
proxy_set_header X-Real-IP $remote_addr;
7+
proxy_pass http://127.0.0.1:9999/mongo-ui;
8+
}
9+

‎deploy/docker/all-in-one/entrypoint.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ if [ ! "$(id --group lowcoder)" -eq ${GROUP_ID} ]; then
1818
fi;
1919

2020
# Update host on which mongo is supposed to listen
21-
# If LOWCODER_MONGODB_EXPOSED is true, it will listen on all interfaces
22-
if [ "${LOWCODER_MONGODB_EXPOSED}" = "true" ]; then
23-
export MONGO_LISTEN_HOST="0.0.0.0"
24-
else
25-
export MONGO_LISTEN_HOST="127.0.0.1"
26-
fi;
21+
export MONGO_LISTEN_HOST="127.0.0.1"
2722

2823
# Set the default mongodb connection string if not set explicitly
2924
if [ -z "${LOWCODER_MONGODB_URL}" ]; then
@@ -36,6 +31,7 @@ CERT="/lowcoder-stacks/ssl"
3631
# Create folder for holding application logs and data
3732
mkdir -p ${LOGS}/redis \
3833
${LOGS}/mongodb \
34+
${LOGS}/mongo-ui \
3935
${LOGS}/api-service \
4036
${LOGS}/node-service \
4137
${LOGS}/frontend \
@@ -78,9 +74,17 @@ if [ "${LOWCODER_NODE_SERVICE_ENABLED:=true}" = "true" ]; then
7874
ln ${SUPERVISOR_AVAILABLE}/11-node-service.conf ${SUPERVISOR_ENABLED}/11-node-service.conf
7975
fi;
8076

77+
# Enable mongo-express web UI for mongodb if configured to run
78+
if [ "${LOWCODER_MONGODB_EXPOSED:=false}" = "true" ]; then
79+
ln ${SUPERVISOR_AVAILABLE}/15-mongo-express.conf ${SUPERVISOR_ENABLED}/15-mongo-express.conf
80+
fi;
81+
8182
# Enable frontend if configured to run
8283
if [ "${LOWCODER_FRONTEND_ENABLED:=true}" = "true" ]; then
8384
ln ${SUPERVISOR_AVAILABLE}/20-frontend.conf ${SUPERVISOR_ENABLED}/20-frontend.conf
85+
sed -i 's@# include mongo-ui.conf;@include mongo-ui.conf;@' /etc/nginx/server.conf
86+
else
87+
sed -i 's@\(\s*\)\(include mongo-ui\.conf;\)@\1# \2@' /etc/nginx/server.conf
8488
fi;
8589

8690
# disable user directive if image is running non-root (Openshift)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[program:mongo-ui]
2+
# privileges will be dropped in entrypoint
3+
user=root
4+
directory=/lowcoder/mongo-express
5+
command=/lowcoder/mongo-express/mongo-ui-entrypoint.sh
6+
priority=15
7+
autostart=true
8+
autorestart=true
9+
startsecs=10
10+
startretries=3
11+
stdout_logfile=/lowcoder-stacks/logs/%(program_name)s/%(program_name)s.log
12+
redirect_stderr=true
13+
stdout_logfile_maxbytes=10MB
14+
stderr_logfile_maxbytes=10MB
15+
stdout_logfile_backups=5
16+
stderr_logfile_backups=5
17+
stdout_events_enabled=true
18+
stderr_events_enabled=true
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
export USER_ID=${LOWCODER_PUID:=9001}
6+
export GROUP_ID=${LOWCODER_PGID:=9001}
7+
8+
# Mongo express configuration
9+
export ME_CONFIG_MONGODB_URL="${LOWCODER_MONGODB_URL:=mongodb://localhost:27017/lowcoder?authSource=admin}"
10+
export ME_CONFIG_MONGODB_ENABLE_ADMIN=true
11+
export ME_CONFIG_SITE_BASEURL="/mongo-ui"
12+
export ME_CONFIG_REQUEST_SIZE=200mb
13+
export ME_CONFIG_OPTIONS_NO_DELETE=true
14+
export ME_CONFIG_OPTIONS_EDITORTHEME=rubyblue
15+
export ME_CONFIG_SITE_GRIDFS_ENABLED=true
16+
export ME_CONFIG_OPTIONS_FULLWIDTH_LAYOUT=false
17+
export ME_CONFIG_BASICAUTH=${LOWCODER_MONGODB_EXPOSED:false}
18+
export ME_CONFIG_BASICAUTH_USERNAME="${LOWCODER_MONGOUI_USERNAME}"
19+
export ME_CONFIG_BASICAUTH_PASSWORD="${LOWCODER_MONGOUI_PASSWORD}"
20+
export VCAP_APP_HOST="127.0.0.1"
21+
export PORT="9999"
22+
23+
export ME_CONFIG_SITE_COOKIESECRET=`cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 30`
24+
export ME_CONFIG_SITE_SESSIONSECRET=`cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 30`
25+
26+
cd /lowcoder/mongo-express/app
27+
28+
echo
29+
echo "Running Mongodb UI with:"
30+
if [ "$(id -u)" -eq 0 ]; then
31+
# only use su if its possible, suppress for containers running non-root
32+
echo " user id: ${USER_ID}"
33+
echo " group id: ${GROUP_ID}"
34+
GOSU="gosu ${USER_ID}:${GROUP_ID}"
35+
fi
36+
echo
37+
38+
exec $GOSU node app
39+

‎deploy/docker/default.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ LOWCODER_FRONTEND_ENABLED="true"
3333
# (applies to all-in-one deployment)
3434
#
3535
LOWCODER_MONGODB_EXPOSED="false"
36+
LOWCODER_MONGOUI_USERNAME="admin"
37+
LOWCODER_MONGOUI_PASSWORD="s3cr3t!"
3638

3739
##
3840
## Generic parameters

‎deploy/docker/frontend/server.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@
5656
proxy_pass __LOWCODER_NODE_SERVICE_URL__;
5757
}
5858

59+
# include mongo-ui.conf;
60+

0 commit comments

Comments
 (0)