2021-06-19 05:59:14 +02:00
|
|
|
FROM alpine:3.14
|
2017-03-28 19:46:14 +02:00
|
|
|
|
2018-05-27 23:22:08 +02:00
|
|
|
MAINTAINER PrivateBin <support@privatebin.org>
|
2017-03-28 19:46:14 +02:00
|
|
|
|
2021-07-11 19:40:47 +02:00
|
|
|
ARG ALPINE_PACKAGES="php8-pdo_mysql php8-pdo_pgsql"
|
|
|
|
ARG COMPOSER_PACKAGES="google/cloud-storage"
|
|
|
|
|
|
|
|
ENV RELEASE 1.3.5
|
|
|
|
ENV PBURL https://github.com/PrivateBin/PrivateBin/
|
2019-09-23 07:19:50 +02:00
|
|
|
ENV S6_READ_ONLY_ROOT 1
|
2021-07-06 06:26:18 +02:00
|
|
|
ENV CONFIG_PATH /srv/cfg
|
2018-05-28 07:31:11 +02:00
|
|
|
|
2017-03-28 19:46:14 +02:00
|
|
|
RUN \
|
|
|
|
# Install dependencies
|
2021-06-06 10:41:52 +02:00
|
|
|
apk add --no-cache gnupg nginx php8 php8-curl php8-fpm php8-json php8-gd \
|
2021-07-11 19:40:47 +02:00
|
|
|
php8-mbstring php8-opcache php8-phar \
|
|
|
|
s6-overlay tzdata php8-openssl $ALPINE_PACKAGES \
|
2020-04-22 20:01:16 +02:00
|
|
|
&& apk upgrade --no-cache \
|
2017-03-28 19:46:14 +02:00
|
|
|
# Remove (some of the) default nginx config
|
2021-01-17 09:13:47 +01:00
|
|
|
&& rm -f /etc/nginx.conf /etc/nginx/http.d/default.conf /etc/php8/php-fpm.d/www.conf \
|
2017-03-28 19:46:14 +02:00
|
|
|
&& rm -rf /etc/nginx/sites-* \
|
|
|
|
# Ensure nginx logs, even if the config has errors, are written to stderr
|
2019-09-23 07:19:50 +02:00
|
|
|
&& ln -s /dev/stderr /var/log/nginx/error.log \
|
2018-05-28 06:44:54 +02:00
|
|
|
# Install PrivateBin
|
2018-05-28 07:31:11 +02:00
|
|
|
&& export GNUPGHOME="$(mktemp -d)" \
|
|
|
|
&& gpg2 --list-public-keys || /bin/true \
|
2019-12-21 14:21:24 +01:00
|
|
|
&& wget -qO - https://privatebin.info/key/release.asc | gpg2 --import - \
|
2018-06-03 20:33:50 +02:00
|
|
|
&& rm -rf /var/www/* \
|
2018-05-28 06:44:54 +02:00
|
|
|
&& cd /tmp \
|
2019-12-21 14:21:24 +01: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 \
|
2021-06-06 10:41:52 +02:00
|
|
|
&& wget -qO composer-setup.php https://getcomposer.org/installer \
|
|
|
|
&& ln -s $(which php8) /usr/local/bin/php \
|
|
|
|
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
|
2018-05-28 06:44:54 +02:00
|
|
|
&& cd /var/www \
|
2019-12-21 14:21:24 +01:00
|
|
|
&& tar -xzf /tmp/${RELEASE}.tar.gz --strip 1 \
|
2021-06-06 10:41:52 +02:00
|
|
|
&& wget -q $(echo ${PBURL} | sed s/github.com/raw.githubusercontent.com/)${RELEASE}/composer.json \
|
|
|
|
&& wget -q $(echo ${PBURL} | sed s/github.com/raw.githubusercontent.com/)${RELEASE}/composer.lock \
|
|
|
|
&& composer remove --dev --no-update phpunit/phpunit \
|
2021-07-11 19:40:47 +02:00
|
|
|
&& ([ -z "$COMPOSER_PACKAGES"] || composer require --no-update $COMPOSER_PACKAGES) \
|
2021-06-06 10:41:52 +02:00
|
|
|
&& composer update --no-dev --optimize-autoloader \
|
|
|
|
&& rm *.md cfg/conf.sample.php composer.* /usr/local/bin/* \
|
2019-12-21 14:21:24 +01:00
|
|
|
&& mv cfg lib tpl vendor /srv \
|
2018-05-28 06:44:54 +02:00
|
|
|
&& mkdir -p /srv/data \
|
|
|
|
&& sed -i "s#define('PATH', '');#define('PATH', '/srv/');#" index.php \
|
2019-09-23 07:19:50 +02:00
|
|
|
# Support running s6 under a non-root user
|
2021-01-17 08:54:28 +01:00
|
|
|
&& mkdir -p /etc/s6/services/nginx/supervise /etc/s6/services/php-fpm8/supervise \
|
2019-12-21 14:21:24 +01:00
|
|
|
&& mkfifo \
|
2021-01-17 08:54:28 +01:00
|
|
|
/etc/s6/services/nginx/supervise/control \
|
|
|
|
/etc/s6/services/php-fpm8/supervise/control \
|
2021-04-28 18:29:58 +02:00
|
|
|
&& chown -R 65534:82 /etc/s6 /run /srv/* /var/lib/nginx /var/www \
|
|
|
|
&& chmod o+rwx /run /var/lib/nginx /var/lib/nginx/tmp \
|
2019-09-23 07:19:50 +02:00
|
|
|
# Clean up
|
2018-05-28 07:31:11 +02:00
|
|
|
&& rm -rf "${GNUPGHOME}" /tmp/* \
|
2021-06-06 10:41:52 +02:00
|
|
|
&& apk del gnupg php8 php8-curl php8-mbstring php8-phar
|
2017-03-28 19:46:14 +02:00
|
|
|
|
2019-09-23 07:19:50 +02:00
|
|
|
COPY etc/ /etc/
|
2017-03-28 19:46:14 +02:00
|
|
|
|
2019-09-23 07:19:50 +02:00
|
|
|
WORKDIR /var/www
|
2020-10-01 19:18:14 +02:00
|
|
|
# user nobody, group www-data
|
|
|
|
USER 65534:82
|
2017-03-28 19:46:14 +02:00
|
|
|
|
2018-05-27 23:22:08 +02:00
|
|
|
# mark dirs as volumes that need to be writable, allows running the container --read-only
|
2019-12-21 15:06:56 +01:00
|
|
|
VOLUME /run /srv/data /tmp /var/lib/nginx/tmp
|
2018-05-27 23:22:08 +02:00
|
|
|
|
2020-04-28 07:10:27 +02:00
|
|
|
EXPOSE 8080
|
2017-03-28 19:46:14 +02:00
|
|
|
|
2019-09-23 07:19:50 +02:00
|
|
|
ENTRYPOINT ["/init"]
|