2019-12-21 06:38:01 +00:00
|
|
|
FROM alpine:3.11
|
2017-03-28 17:46:14 +00:00
|
|
|
|
2018-05-27 21:22:08 +00:00
|
|
|
MAINTAINER PrivateBin <support@privatebin.org>
|
2017-03-28 17:46:14 +00:00
|
|
|
|
2020-01-11 11:07:47 +00:00
|
|
|
ENV RELEASE 1.3.2
|
2019-09-23 05:19:50 +00:00
|
|
|
ENV PBURL https://github.com/PrivateBin/PrivateBin/
|
|
|
|
ENV S6RELEASE v1.22.1.0
|
|
|
|
ENV S6URL https://github.com/just-containers/s6-overlay/releases/download/
|
|
|
|
ENV S6_READ_ONLY_ROOT 1
|
2018-05-28 05:31:11 +00:00
|
|
|
|
2017-03-28 17:46:14 +00:00
|
|
|
RUN \
|
|
|
|
# Install dependencies
|
2019-12-21 13:21:24 +00:00
|
|
|
apk add --no-cache gnupg libcap nginx php7-fpm php7-json php7-gd \
|
|
|
|
php7-opcache php7-pdo_mysql php7-pdo_pgsql tzdata \
|
2017-03-28 17:46:14 +00:00
|
|
|
# Remove (some of the) default nginx config
|
2019-09-23 05:19:50 +00:00
|
|
|
&& rm -f /etc/nginx.conf /etc/nginx/conf.d/default.conf /etc/php7/php-fpm.d/www.conf \
|
2017-03-28 17:46:14 +00:00
|
|
|
&& rm -rf /etc/nginx/sites-* \
|
|
|
|
# Ensure nginx logs, even if the config has errors, are written to stderr
|
2019-09-23 05:19:50 +00:00
|
|
|
&& ln -s /dev/stderr /var/log/nginx/error.log \
|
2018-05-28 04:44:54 +00:00
|
|
|
# Install PrivateBin
|
2018-05-28 05:31:11 +00:00
|
|
|
&& export GNUPGHOME="$(mktemp -d)" \
|
|
|
|
&& gpg2 --list-public-keys || /bin/true \
|
2019-12-21 13:21:24 +00:00
|
|
|
&& wget -qO - https://privatebin.info/key/release.asc | gpg2 --import - \
|
2018-06-03 18:33:50 +00:00
|
|
|
&& rm -rf /var/www/* \
|
2018-05-28 04:44:54 +00:00
|
|
|
&& cd /tmp \
|
2019-12-21 13:21:24 +00:00
|
|
|
&& wget -qO ${RELEASE}.tar.gz.asc ${PBURL}releases/download/${RELEASE}/PrivateBin-${RELEASE}.tar.gz.asc \
|
|
|
|
&& wget -q ${PBURL}archive/${RELEASE}.tar.gz \
|
|
|
|
&& gpg2 --verify ${RELEASE}.tar.gz.asc \
|
2018-05-28 04:44:54 +00:00
|
|
|
&& cd /var/www \
|
2019-12-21 13:21:24 +00:00
|
|
|
&& tar -xzf /tmp/${RELEASE}.tar.gz --strip 1 \
|
2018-05-28 05:31:11 +00:00
|
|
|
&& rm *.md cfg/conf.sample.php \
|
2019-12-21 13:21:24 +00:00
|
|
|
&& mv cfg lib tpl vendor /srv \
|
2018-05-28 04:44:54 +00:00
|
|
|
&& mkdir -p /srv/data \
|
|
|
|
&& sed -i "s#define('PATH', '');#define('PATH', '/srv/');#" index.php \
|
2019-09-23 05:19:50 +00:00
|
|
|
# Install s6 overlay for service management
|
2019-12-21 13:21:24 +00:00
|
|
|
&& wget -qO - https://keybase.io/justcontainers/key.asc | gpg2 --import - \
|
2019-09-23 05:19:50 +00:00
|
|
|
&& cd /tmp \
|
2019-10-04 05:38:32 +00:00
|
|
|
&& S6ARCH=$(uname -m) \
|
|
|
|
&& case ${S6ARCH} in \
|
|
|
|
x86_64) S6ARCH=amd64;; \
|
|
|
|
armv7l) S6ARCH=armhf;; \
|
|
|
|
esac \
|
2019-12-21 13:21:24 +00:00
|
|
|
&& wget -q ${S6URL}${S6RELEASE}/s6-overlay-${S6ARCH}.tar.gz.sig \
|
|
|
|
&& wget -q ${S6URL}${S6RELEASE}/s6-overlay-${S6ARCH}.tar.gz \
|
2019-10-04 05:38:32 +00:00
|
|
|
&& gpg2 --verify s6-overlay-${S6ARCH}.tar.gz.sig \
|
|
|
|
&& tar -xzf s6-overlay-${S6ARCH}.tar.gz -C / \
|
2019-09-23 05:19:50 +00:00
|
|
|
# Support running s6 under a non-root user
|
|
|
|
&& mkdir -p /etc/services.d/nginx/supervise /etc/services.d/php-fpm7/supervise \
|
2019-12-21 13:21:24 +00:00
|
|
|
&& mkfifo \
|
|
|
|
/etc/services.d/nginx/supervise/control \
|
|
|
|
/etc/services.d/php-fpm7/supervise/control \
|
|
|
|
/etc/s6/services/s6-fdholderd/supervise/control \
|
2019-09-23 05:19:50 +00:00
|
|
|
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx \
|
2019-12-21 14:06:56 +00:00
|
|
|
&& chown -R nobody.www-data /etc/services.d /etc/s6 /run /srv/* /var/lib/nginx /var/www \
|
2019-09-23 05:19:50 +00:00
|
|
|
# Clean up
|
2018-05-28 05:31:11 +00:00
|
|
|
&& rm -rf "${GNUPGHOME}" /tmp/* \
|
2019-12-21 13:21:24 +00:00
|
|
|
&& apk del gnupg libcap
|
2017-03-28 17:46:14 +00:00
|
|
|
|
2019-09-23 05:19:50 +00:00
|
|
|
COPY etc/ /etc/
|
2017-03-28 17:46:14 +00:00
|
|
|
|
2019-09-23 05:19:50 +00:00
|
|
|
WORKDIR /var/www
|
2019-09-23 05:52:34 +00:00
|
|
|
USER nobody:www-data
|
2017-03-28 17:46:14 +00:00
|
|
|
|
2018-05-27 21:22:08 +00:00
|
|
|
# mark dirs as volumes that need to be writable, allows running the container --read-only
|
2019-12-21 14:06:56 +00:00
|
|
|
VOLUME /run /srv/data /tmp /var/lib/nginx/tmp
|
2018-05-27 21:22:08 +00:00
|
|
|
|
2019-12-07 08:20:39 +00:00
|
|
|
EXPOSE 80 8080
|
2017-03-28 17:46:14 +00:00
|
|
|
|
2019-09-23 05:19:50 +00:00
|
|
|
ENTRYPOINT ["/init"]
|