Skip to content

Commit 4349d42

Browse files
authored
Merge pull request #2904 from NginxProxyManager/s6-verbose
Fixes for s6 timeout at startup
2 parents 67208e4 + 4b6f9d9 commit 4349d42

File tree

15 files changed

+99
-50
lines changed

15 files changed

+99
-50
lines changed

docker/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ ARG BUILD_VERSION
1010
ARG BUILD_COMMIT
1111
ARG BUILD_DATE
1212

13+
# See: https://github.com/just-containers/s6-overlay/blob/master/README.md
1314
ENV SUPPRESS_NO_CONFIG_WARNING=1 \
14-
S6_FIX_ATTRS_HIDDEN=1 \
1515
S6_BEHAVIOUR_IF_STAGE2_FAILS=1 \
16+
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
17+
S6_FIX_ATTRS_HIDDEN=1 \
18+
S6_KILL_FINISH_MAXTIME=10000 \
19+
S6_VERBOSITY=1 \
1620
NODE_ENV=production \
1721
NPM_BUILD_VERSION="${BUILD_VERSION}" \
1822
NPM_BUILD_COMMIT="${BUILD_COMMIT}" \

docker/dev/Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
FROM jc21/nginx-full:certbot-node
22
LABEL maintainer="Jamie Curnow <jc@jc21.com>"
33

4-
ENV S6_LOGGING=0 \
5-
SUPPRESS_NO_CONFIG_WARNING=1 \
6-
S6_FIX_ATTRS_HIDDEN=1
4+
# See: https://github.com/just-containers/s6-overlay/blob/master/README.md
5+
ENV SUPPRESS_NO_CONFIG_WARNING=1 \
6+
S6_BEHAVIOUR_IF_STAGE2_FAILS=1 \
7+
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
8+
S6_FIX_ATTRS_HIDDEN=1 \
9+
S6_KILL_FINISH_MAXTIME=10000 \
10+
S6_VERBOSITY=2
711

812
RUN echo "fs.file-max = 65535" > /etc/sysctl.conf \
913
&& apt-get update \

docker/docker-compose.ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ services:
3535
DB_SQLITE_FILE: '/data/mydb.sqlite'
3636
PUID: 1000
3737
PGID: 1000
38+
DISABLE_IPV6: 'true'
3839
volumes:
3940
- npm_data:/data
4041
expose:

docker/rootfs/bin/common.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ export CYAN BLUE YELLOW RED RESET
1212
PUID=${PUID:-0}
1313
PGID=${PGID:-0}
1414

15+
NPMUSER=npm
16+
NPMGROUP=npm
17+
NPMHOME=/tmp/npmuserhome
18+
export NPMUSER NPMGROUP NPMHOME
19+
1520
if [[ "$PUID" -ne '0' ]] && [ "$PGID" = '0' ]; then
1621
# set group id to same as user id,
1722
# the user probably forgot to specify the group id and
@@ -40,3 +45,10 @@ log_fatal () {
4045
/run/s6/basedir/bin/halt
4146
exit 1
4247
}
48+
49+
# param $1: group_name
50+
get_group_id () {
51+
if [ "${1:-}" != '' ]; then
52+
getent group "$1" | cut -d: -f3
53+
fi
54+
}

docker/rootfs/etc/nginx/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# run nginx in foreground
22
daemon off;
33
pid /run/nginx/nginx.pid;
4-
user npmuser;
4+
user npm;
55

66
# Set number of worker processes automatically based on number of CPU cores.
77
worker_processes auto;

docker/rootfs/etc/s6-overlay/s6-rc.d/backend/run

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ cd /app || exit 1
1010
log_info 'Starting backend ...'
1111

1212
if [ "${DEVELOPMENT:-}" = 'true' ]; then
13-
s6-setuidgid npmuser yarn install
14-
exec s6-setuidgid npmuser bash -c 'export HOME=/tmp/npmuserhome;node --max_old_space_size=250 --abort_on_uncaught_exception node_modules/nodemon/bin/nodemon.js'
13+
s6-setuidgid "$PUID:$PGID" yarn install
14+
exec s6-setuidgid "$PUID:$PGID" bash -c "export HOME=$NPMHOME;node --max_old_space_size=250 --abort_on_uncaught_exception node_modules/nodemon/bin/nodemon.js"
1515
else
1616
while :
1717
do
18-
s6-setuidgid npmuser bash -c 'export HOME=/tmp/npmuserhome;node --abort_on_uncaught_exception --max_old_space_size=250 index.js'
18+
s6-setuidgid "$PUID:$PGID" bash -c "export HOME=$NPMHOME;node --abort_on_uncaught_exception --max_old_space_size=250 index.js"
1919
sleep 1
2020
done
2121
fi

docker/rootfs/etc/s6-overlay/s6-rc.d/frontend/run

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ set -e
88
if [ "$DEVELOPMENT" = 'true' ]; then
99
. /bin/common.sh
1010
cd /app/frontend || exit 1
11-
HOME=/tmp/npmuserhome
11+
HOME=$NPMHOME
1212
export HOME
1313
mkdir -p /app/frontend/dist
1414
chown -R "$PUID:$PGID" /app/frontend/dist
1515

1616
log_info 'Starting frontend ...'
17-
s6-setuidgid npmuser yarn install
18-
exec s6-setuidgid npmuser yarn watch
17+
s6-setuidgid "$PUID:$PGID" yarn install
18+
exec s6-setuidgid "$PUID:$PGID" yarn watch
1919
else
2020
exit 0
2121
fi

docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ set -e
66
. /bin/common.sh
77

88
log_info 'Starting nginx ...'
9-
exec s6-setuidgid npmuser nginx
9+
exec s6-setuidgid "$PUID:$PGID" nginx

docker/rootfs/etc/s6-overlay/s6-rc.d/prepare/00-all.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ if [ "$(id -u)" != "0" ]; then
99
log_fatal "This docker container must be run as root, do not specify a user.\nYou can specify PUID and PGID env vars to run processes as that user and group after initialization."
1010
fi
1111

12-
. /etc/s6-overlay/s6-rc.d/prepare/10-npmuser.sh
12+
if [ "$DEBUG" = "true" ]; then
13+
set -x
14+
fi
15+
16+
. /etc/s6-overlay/s6-rc.d/prepare/10-usergroup.sh
1317
. /etc/s6-overlay/s6-rc.d/prepare/20-paths.sh
1418
. /etc/s6-overlay/s6-rc.d/prepare/30-ownership.sh
1519
. /etc/s6-overlay/s6-rc.d/prepare/40-dynamic.sh

docker/rootfs/etc/s6-overlay/s6-rc.d/prepare/10-npmuser.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)