Skip to content

Commit d668d20

Browse files
committed
Merge branch 'feature/s6-overlay'
2 parents d2be919 + c5cfa56 commit d668d20

File tree

73 files changed

+199
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+199
-176
lines changed

common/Dockerfile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@ FROM alpine:${ALPINE_VERSION} AS base
88
# Install packages
99
# hadolint ignore=DL3018
1010
RUN apk add --no-cache \
11-
supervisor
11+
s6-overlay
1212

1313
# Copy files
14-
COPY config/supervisor/supervisord.conf /etc/supervisor/
14+
COPY config/s6-overlay /etc/s6-overlay/s6-rc.d/
1515
COPY scripts /scripts/
1616

17+
# S6-overlay configuration
18+
ENV S6_LINUX_INIT=0
19+
ENV S6_VERBOSITY=0
20+
ENV S6_KILL_GRACETIME=1000
21+
1722
# Clean Up
1823
WORKDIR /app/www
19-
RUN chown -R nobody:nobody \
20-
/app/www \
21-
/run \
24+
RUN chown -R nobody:nobody /app/www \
2225
&& addgroup nobody tty
2326

2427
ENTRYPOINT ["/scripts/docker-entrypoint.sh"]
@@ -37,14 +40,9 @@ RUN apk add --no-cache \
3740

3841
# Copy files
3942
COPY config/nginx/ /etc/nginx/
40-
COPY config/supervisor/conf.d/nginx.conf /etc/supervisor/conf.d/
4143

42-
# Clean Up
44+
# Remove unneeded nginx site and enable service
4345
RUN rm -f /etc/nginx/conf.d/default.conf \
44-
&& chown -R nobody:nobody \
45-
/etc/nginx/site-mods-enabled.d \
46-
/etc/nginx/snippets/vars/ \
47-
/var/lib/nginx \
48-
/var/log/nginx
46+
&& touch /etc/s6-overlay/s6-rc.d/user/contents.d/nginx
4947

5048
EXPOSE 8080

common/config/s6-overlay/nginx/dependencies.d/startup-scripts

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SIGQUIT

common/config/s6-overlay/nginx/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/execlineb -P
2+
s6-setuidgid nobody
3+
nginx
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
longrun
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env sh
2+
3+
set -euo pipefail
4+
5+
# Set defaults
6+
SECRET_DIR=/secrets
7+
8+
# Correct permissions so we can run as `nobody`
9+
EXTRA_DIRS=
10+
[ -d /var/lib/nginx ] && EXTRA_DIRS="$EXTRA_DIRS /var/lib/nginx"
11+
[ -d /var/log/nginx ] && EXTRA_DIRS="$EXTRA_DIRS /var/log/nginx"
12+
chown nobody:nogroup \
13+
/dev/stdout \
14+
/dev/stderr \
15+
/run \
16+
$EXTRA_DIRS
17+
18+
# Ensure our working path is correct
19+
OLD_PWD="$PWD"
20+
if [ -d /app/www ]; then
21+
cd /app/www
22+
fi
23+
24+
# Execute individual startup scripts
25+
for script in /scripts/startup/*.sh; do
26+
s6-envdir -I "$SECRET_DIR" $script
27+
done
28+
29+
# Cleanup
30+
cd "$OLD_PWD"

common/config/s6-overlay/startup-scripts/dependencies.d/base

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oneshot
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/execlineb -P
2+
with-contenv
3+
/etc/s6-overlay/s6-rc.d/startup-scripts/data/run.sh

common/config/supervisor/conf.d/nginx.conf

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

0 commit comments

Comments
 (0)