Merge pull request #65 from PrivateBin/s6-simplify

simplify s6 service handling
This commit is contained in:
El RIDO 2021-09-07 21:20:57 +02:00 committed by GitHub
commit fa2d71bd8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 11 additions and 23 deletions

View file

@ -4,6 +4,8 @@ ARG ALPINE_PACKAGES="php8-pdo_mysql php8-pdo_pgsql php8-openssl"
ARG COMPOSER_PACKAGES=google/cloud-storage
ARG PBURL=https://github.com/PrivateBin/PrivateBin/
ARG RELEASE=1.3.5
ARG UID=65534
ARG GID=82
ENV CONFIG_PATH=/srv/cfg
@ -25,7 +27,7 @@ RUN \
# Install dependencies
&& apk upgrade --no-cache \
&& apk add --no-cache gnupg git nginx php8-fpm php8-json php8-gd php8-opcache \
s6-linux-init s6-rc tzdata ${ALPINE_PACKAGES} ${ALPINE_COMPOSER_PACKAGES} \
s6 tzdata ${ALPINE_PACKAGES} ${ALPINE_COMPOSER_PACKAGES} \
# Remove (some of the) default nginx config
&& rm -f /etc/nginx.conf /etc/nginx/http.d/default.conf /etc/php8/php-fpm.d/www.conf \
&& rm -rf /etc/nginx/sites-* \
@ -67,29 +69,25 @@ RUN \
&& mkdir -p /srv/data \
&& sed -i "s#define('PATH', '');#define('PATH', '/srv/');#" index.php \
# Support running s6 under a non-root user
&& mkdir -p /etc/s6/services/nginx/supervise /etc/s6/services/php-fpm8/supervise /etc/s6-rc \
&& mkdir -p /etc/s6/services/nginx/supervise /etc/s6/services/php-fpm8/supervise \
&& mkfifo \
/etc/s6/services/nginx/supervise/control \
/etc/s6/services/php-fpm8/supervise/control \
&& chown -R 65534:82 /etc/s6 /run /srv/* /var/lib/nginx /var/www \
&& chmod o+rwx /run /var/lib/nginx /var/lib/nginx/tmp /usr/bin/s6-linux-init* \
&& chown -R ${UID}:${GID} /etc/s6 /run /srv/* /var/lib/nginx /var/www \
&& chmod o+rwx /run /var/lib/nginx /var/lib/nginx/tmp \
# Clean up
&& rm -rf "${GNUPGHOME}" /tmp/* \
&& apk del --no-cache gnupg git ${ALPINE_COMPOSER_PACKAGES}
COPY etc/ /etc/
RUN s6-rc-compile /etc/s6-rc/compiled /etc/s6/services \
&& chown -R 65534:82 /etc/s6-rc/compiled \
&& s6-linux-init-maker -C -N -B -s /run/env /etc/s6-linux-init/current
WORKDIR /var/www
# user nobody, group www-data
USER 65534:82
USER ${UID}:${GID}
# mark dirs as volumes that need to be writable, allows running the container --read-only
VOLUME /run /srv/data /tmp /var/lib/nginx/tmp
EXPOSE 8080
ENTRYPOINT ["/etc/s6-linux-init/current/bin/init"]
ENTRYPOINT ["/etc/init.d/rc.local"]

3
etc/init.d/rc.local Executable file
View file

@ -0,0 +1,3 @@
#!/bin/execlineb -P
foreground { cp -r /etc/s6/services /run }
/bin/s6-svscan /run/services

View file

@ -1,6 +0,0 @@
#!/bin/sh -e
rl="$1"
shift
s6-rc-init /run/service
s6-rc -v2 -u change default

View file

@ -1,2 +0,0 @@
nginx
php-fpm8

View file

@ -1 +0,0 @@
bundle

View file

@ -1 +0,0 @@
php-fpm8

View file

@ -1 +0,0 @@
longrun

View file

@ -1,3 +1,2 @@
#!/bin/execlineb -P
s6-envdir /run/env
/usr/sbin/php-fpm8

View file

@ -1 +0,0 @@
longrun