Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf21c70f

Browse files
authored
Merge pull request#757 from sseide/openshift-compatibility
first part of changes for OpenShift compatibility
2 parents6f12cf3 +13ead68 commitf21c70f

File tree

5 files changed

+64
-31
lines changed

5 files changed

+64
-31
lines changed

‎deploy/docker/Dockerfile‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RUN chmod +x /lowcoder/api-service/*.sh
2525
## To create a separate image out of it, build it with:
2626
## DOCKER_BUILDKIT=1 docker build -f deploy/docker/Dockerfile -t lowcoderorg/lowcoder-ce-api-service --target lowcoder-ce-api-service .
2727
##
28-
FROM eclipse-temurin:17-jammyas lowcoder-ce-api-service
28+
FROM eclipse-temurin:17-jammyAS lowcoder-ce-api-service
2929
LABEL maintainer="lowcoder"
3030

3131
RUN apt-get update && apt-get install -y --no-install-recommends gosu \
@@ -49,7 +49,7 @@ CMD [ "/bin/bash" , "/lowcoder/api-service/entrypoint.sh" ]
4949
##
5050
## Build lowcoder node service
5151
##
52-
FROM ubuntu:jammyas build-node-service
52+
FROM ubuntu:jammyAS build-node-service
5353

5454
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y curl ca-certificates build-essential gnupg
5555

@@ -80,7 +80,7 @@ RUN chmod +x /lowcoder/node-service/*.sh
8080
## To create a separate image out of it, build it with:
8181
## DOCKER_BUILDKIT=1 docker build -f deploy/docker/Dockerfile -t lowcoderorg/lowcoder-ce-node-service --target lowcoder-ce-node-service .
8282
##
83-
FROM ubuntu:jammyas lowcoder-ce-node-service
83+
FROM ubuntu:jammyAS lowcoder-ce-node-service
8484
LABEL maintainer="lowcoder"
8585

8686
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y curl ca-certificates gnupg
@@ -145,7 +145,7 @@ RUN yarn build
145145
## To create a separate image out of it, build it with:
146146
## DOCKER_BUILDKIT=1 docker build -f deploy/docker/Dockerfile -t lowcoderorg/lowcoder-ce-frontend --target lowcoder-ce-frontend .
147147
##
148-
FROM nginx:1.25.1as lowcoder-ce-frontend
148+
FROM nginx:1.25.1AS lowcoder-ce-frontend
149149
LABEL maintainer="lowcoder"
150150

151151
# Change default nginx user into lowcoder user and remove default nginx config
@@ -189,7 +189,10 @@ EXPOSE 3443
189189
FROM lowcoder-ce-frontend
190190
LABEL maintainer="lowcoder"
191191

192-
RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y curl ca-certificates gnupg
192+
RUN apt-get update && apt-get upgrade -y \
193+
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y curl ca-certificates gnupg \
194+
&& rm -rf /var/cache/apt/lists /var/lib/apt/lists/* /var/log/dpkg.log \
195+
&& apt-get clean
193196

194197
# Add nodejs repo and keys
195198
RUN mkdir -p /etc/apt/keyrings \
@@ -211,8 +214,10 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-instal
211214
nodejs \
212215
openjdk-17-jdk-headless \
213216
&& npm install -g yarn \
214-
&& rm -rf /var/cache/apt/lists \
215-
&& mkdir -p /lowcoder/assets
217+
&& rm -rf /var/cache/apt/lists /var/lib/apt/lists/* /var/log/dpkg.log \
218+
&& mkdir -p /lowcoder/assets \
219+
&& apt-get clean \
220+
&& rm -rf /tmp/*
216221

217222
# Add lowcoder api-service
218223
COPY --chown=lowcoder:lowcoder --from=lowcoder-ce-api-service /lowcoder/api-service /lowcoder/api-service
@@ -227,6 +232,17 @@ COPY --chown=lowcoder:lowcoder deploy/docker/all-in-one/etc /lowcoder/etc
227232
# Add startup script
228233
COPY --chown=lowcoder:lowcoder deploy/docker/all-in-one/entrypoint.sh /lowcoder/entrypoint.sh
229234

235+
# Fixes for OpenShift compatibility (after all files are copied)
236+
RUN echo \
237+
&& adduser lowcoder root \
238+
&& mkdir -p /lowcoder-stacks \
239+
&& for i in /lowcoder-stacks /lowcoder/assets /lowcoder/api-service/logs /lowcoder/etc/supervisord; do \
240+
chmod -R g+rw"$i"; \
241+
chown -R lowcoder:root"$i"; \
242+
done \
243+
&& chown -R lowcoder:root /var/log \
244+
&& chmod -R g+rw /run /etc/nginx /var/cache/nginx /var/log
245+
230246
EXPOSE 27017
231247
EXPOSE 3000
232248
EXPOSE 3443

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ export USER_ID=${LOWCODER_PUID:=9001}
66
export GROUP_ID=${LOWCODER_PGID:=9001}
77

88
# Update ID of lowcoder user if required
9-
if [!`id --user lowcoder`-eq${USER_ID} ];then
9+
if [!"$(id --user lowcoder)"-eq${USER_ID} ];then
1010
usermod --uid${USER_ID} lowcoder
1111
echo"ID for lowcoder user changed to:${USER_ID}"
1212
fi;
1313

1414
# Update ID of lowcoder group if required
15-
if [!`id --group lowcoder`-eq${GROUP_ID} ];then
15+
if [!"$(id --group lowcoder)"-eq${GROUP_ID} ];then
1616
groupmod --gid${GROUP_ID} lowcoder
1717
echo"ID for lowcoder group changed to:${GROUP_ID}"
1818
fi;
1919

2020
# Update host on which mongo is supposed to listen
21-
# If LOWCODER_MONGODB_EXPOSED is true, it willisten on all interfaces
21+
# If LOWCODER_MONGODB_EXPOSED is true, it willlisten on all interfaces
2222
if ["${LOWCODER_MONGODB_EXPOSED}"="true" ];then
2323
export MONGO_LISTEN_HOST="0.0.0.0"
2424
else
@@ -38,8 +38,10 @@ mkdir -p ${LOGS}/redis \
3838
${DATA}/mongodb \
3939
${CERT}
4040

41-
# Update owner of logs and data
42-
chown -R${USER_ID}:${GROUP_ID} /lowcoder-stacks/ /lowcoder/etc
41+
# Update owner of logs and data - do not try if not running as root (OpenShift)
42+
if ["$(id -u)"-eq 0 ];then
43+
chown -R"${USER_ID}:${GROUP_ID}" /lowcoder-stacks/ /lowcoder/etc
44+
fi
4345

4446
# Enable services
4547
SUPERVISOR_AVAILABLE="/lowcoder/etc/supervisord/conf-available"
@@ -73,8 +75,15 @@ fi;
7375

7476
# Enable frontend if configured to run
7577
if ["${LOWCODER_FRONTEND_ENABLED:=true}"="true" ];then
76-
ln${SUPERVISOR_AVAILABLE}/20-frontend.conf${SUPERVISOR_ENABLED}/20-frontend.conf
78+
ln${SUPERVISOR_AVAILABLE}/20-frontend.conf${SUPERVISOR_ENABLED}/20-frontend.conf
7779
fi;
7880

81+
# disable user directive if image is running non-root (Openshift)
82+
if ["$(id -u)"-ne 0 ];then
83+
foriin"${SUPERVISOR_ENABLED}"/*.conf;do
84+
sed -Ei's/^\s*user=.*$//'"$i"
85+
done
86+
fi
87+
7988
# Handle CMD command
8089
"$@"

‎deploy/docker/all-in-one/etc/supervisord.conf‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
; supervisor config file
22

33
[unix_http_server]
4-
file=/var/run/supervisor.sock ; (the path to the socket file)
5-
chmod=0700 ;sockef file mode (default 0700)
4+
file =/var/run/supervisor.sock ; (the path to the socket file)
5+
chmod =0700 ;socket file mode (default 0700)
66

77
;[inet_http_server] ; inet (TCP) server disabled by default
88
;port=*:9001 ; (ip_address:port specifier, *:port for all iface)
99
;username=user ; (default is no username (open server))
1010
;password=123 ; (default is no password (open server))
1111

1212
[supervisord]
13-
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
14-
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
15-
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
13+
logfile = /dev/null ; (no logfile, stdout only; default $CWD/supervisord.log)
14+
pidfile = /var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
15+
childlogdir = /var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
16+
logfile_maxbytes = 0
1617
stdout_logfile_maxbytes = 0
1718
stderr_logfile_maxbytes = 0
1819

@@ -23,7 +24,7 @@ stderr_logfile_maxbytes = 0
2324
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
2425

2526
[supervisorctl]
26-
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
27+
serverurl =unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
2728

2829
; The [include] section can just contain the "files" setting. This
2930
; setting can list multiple files (separated by whitespace or

‎deploy/docker/api-service/entrypoint.sh‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export GROUP_ID="${LOWCODER_PGID:=9001}"
99
echo"Initializing api-service..."
1010
/lowcoder/api-service/init.sh
1111

12-
if [-z$JAVA_HOME ];then
13-
JAVA_HOME=`dirname$(dirname$(readlink -f$(which javac)))`
12+
if [-z"$JAVA_HOME" ];then
13+
JAVA_HOME=$(dirname"$(dirname"$(readlink -f"$(which javac)")")")
1414
fi;
1515
APP_JAR="${APP_JAR:=/lowcoder/api-service/lowcoder-api-service.jar}"
1616
JAVA_OPTS="${JAVA_OPTS:=}"
@@ -19,16 +19,20 @@ CONTEXT_PATH=${CONTEXT_PATH:=/}
1919

2020
echo
2121
echo"Running lowcoder api-server with:"
22-
echo" user id:${USER_ID}"
23-
echo" group id:${GROUP_ID}"
2422
echo" base path:${CONTEXT_PATH}"
23+
24+
if ["$(id -u)"-eq 0 ];then
25+
# only use su if its possible, suppress for containers running non-root
26+
echo" user id:${USER_ID}"
27+
echo" group id:${GROUP_ID}"
28+
GOSU="gosu${USER_ID}:${GROUP_ID}"
29+
fi
2530
echo
26-
${JAVA_HOME}/bin/java -version
31+
"${JAVA_HOME}/bin/java" -version
2732
echo
2833

2934
cd /lowcoder/api-service
30-
31-
exec gosu${USER_ID}:${GROUP_ID}${JAVA_HOME}/bin/java \
35+
exec$GOSU"${JAVA_HOME}/bin/java" \
3236
-Djava.util.prefs.userRoot=/tmp \
3337
-Djava.security.egd=file:/dev/./urandom \
3438
-Dhttps.protocols=TLSv1.1,TLSv1.2 \
@@ -37,5 +41,5 @@ exec gosu ${USER_ID}:${GROUP_ID} ${JAVA_HOME}/bin/java \
3741
--add-opens java.base/java.nio=ALL-UNNAMED \
3842
${JAVA_OPTS} \
3943
-Dpf4j.pluginsDir=/lowcoder/api-service/plugins \
40-
-jar${APP_JAR} --spring.webflux.base-path=${CONTEXT_PATH}${CUSTOM_APP_PROPERTIES}
44+
-jar"${APP_JAR}" --spring.webflux.base-path="${CONTEXT_PATH}"${CUSTOM_APP_PROPERTIES}
4145

‎deploy/docker/node-service/entrypoint.sh‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ cd /lowcoder/node-service/app
1515
echo
1616
echo"Running Lowcoder node-service with:"
1717
echo" API service host:${API_HOST}"
18-
echo" user id:${USER_ID}"
19-
echo" group id:${GROUP_ID}"
18+
if ["$(id -u)"-eq 0 ];then
19+
# only use su if its possible, suppress for containers running non-root
20+
echo" user id:${USER_ID}"
21+
echo" group id:${GROUP_ID}"
22+
GOSU="gosu${USER_ID}:${GROUP_ID}"
23+
fi
2024
echo
2125

22-
exec gosu${USER_ID}:${GROUP_ID} yarn start
23-
26+
exec$GOSU yarn start

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp