2024-12-06 05:49:23 +01:00
|
|
|
FROM alpine:3.21
|
2017-03-28 19:46:14 +02:00
|
|
|
|
2025-02-01 12:02:25 +01:00
|
|
|
ARG ALPINE_PACKAGES="php84-iconv php84-pdo_mysql php84-pdo_pgsql php84-openssl php84-simplexml"
|
2023-01-17 19:51:22 +01:00
|
|
|
ARG COMPOSER_PACKAGES="aws/aws-sdk-php google/cloud-storage"
|
2021-07-13 21:05:43 +02:00
|
|
|
ARG PBURL=https://github.com/PrivateBin/PrivateBin/
|
2025-02-01 11:25:56 +01:00
|
|
|
ARG RELEASE=1.7.6
|
2021-09-07 07:16:02 +02:00
|
|
|
ARG UID=65534
|
|
|
|
ARG GID=82
|
2017-03-28 19:46:14 +02:00
|
|
|
|
2021-08-09 21:12:16 +02:00
|
|
|
ENV CONFIG_PATH=/srv/cfg
|
2022-12-20 19:18:17 +01:00
|
|
|
ENV PATH=$PATH:/srv/bin
|
2017-03-28 19:46:14 +02:00
|
|
|
|
2021-07-13 21:05:43 +02:00
|
|
|
LABEL org.opencontainers.image.authors=support@privatebin.org \
|
|
|
|
org.opencontainers.image.vendor=PrivateBin \
|
|
|
|
org.opencontainers.image.documentation=https://github.com/PrivateBin/docker-nginx-fpm-alpine/blob/master/README.md \
|
|
|
|
org.opencontainers.image.source=https://github.com/PrivateBin/docker-nginx-fpm-alpine \
|
|
|
|
org.opencontainers.image.licenses=zlib-acknowledgement \
|
|
|
|
org.opencontainers.image.version=${RELEASE}
|
2018-05-28 07:31:11 +02:00
|
|
|
|
2023-07-15 09:50:45 +02:00
|
|
|
COPY release.asc /tmp/
|
|
|
|
|
2017-03-28 19:46:14 +02:00
|
|
|
RUN \
|
2021-07-13 21:05:43 +02:00
|
|
|
# Prepare composer dependencies
|
2021-07-14 21:32:17 +02:00
|
|
|
ALPINE_PACKAGES="$(echo ${ALPINE_PACKAGES} | sed 's/,/ /g')" ;\
|
2021-07-13 21:05:43 +02:00
|
|
|
ALPINE_COMPOSER_PACKAGES="" ;\
|
|
|
|
if [ -n "${COMPOSER_PACKAGES}" ] ; then \
|
2025-02-01 12:02:25 +01:00
|
|
|
# we need these PHP 8.3 packages until composer gets updated to depend on PHP 8.4
|
2024-05-09 19:22:53 +02:00
|
|
|
ALPINE_COMPOSER_PACKAGES="composer" ;\
|
2023-12-09 13:50:35 +01:00
|
|
|
if [ -n "${ALPINE_PACKAGES##*php83-curl*}" ] ; then \
|
|
|
|
ALPINE_COMPOSER_PACKAGES="php83-curl ${ALPINE_COMPOSER_PACKAGES}" ;\
|
2023-01-03 19:57:33 +01:00
|
|
|
fi ;\
|
2023-12-09 13:50:35 +01:00
|
|
|
if [ -n "${ALPINE_PACKAGES##*php83-mbstring*}" ] ; then \
|
|
|
|
ALPINE_COMPOSER_PACKAGES="php83-mbstring ${ALPINE_COMPOSER_PACKAGES}" ;\
|
2023-01-17 21:45:59 +01:00
|
|
|
fi ;\
|
2025-02-01 12:02:25 +01:00
|
|
|
if [ -z "${ALPINE_PACKAGES##*php84-simplexml*}" ] ; then \
|
|
|
|
ALPINE_COMPOSER_PACKAGES="php83-simplexml ${ALPINE_COMPOSER_PACKAGES}" ;\
|
|
|
|
fi ;\
|
2021-07-13 21:05:43 +02:00
|
|
|
fi \
|
2017-03-28 19:46:14 +02:00
|
|
|
# Install dependencies
|
2020-04-22 20:01:16 +02:00
|
|
|
&& apk upgrade --no-cache \
|
2025-02-01 12:02:25 +01:00
|
|
|
&& apk add --no-cache gnupg git nginx php84 php84-ctype php84-fpm php84-gd \
|
|
|
|
php84-opcache s6 tzdata ${ALPINE_PACKAGES} ${ALPINE_COMPOSER_PACKAGES} \
|
2023-05-21 10:15:29 +02:00
|
|
|
# Stabilize php config location
|
2025-02-01 12:02:25 +01:00
|
|
|
&& mv /etc/php84 /etc/php \
|
|
|
|
&& ln -s /etc/php /etc/php84 \
|
|
|
|
&& ln -s $(which php84) /usr/local/bin/php \
|
2023-05-21 10:15:29 +02:00
|
|
|
# Remove (some of the) default nginx & php config
|
|
|
|
&& rm -f /etc/nginx.conf /etc/nginx/http.d/default.conf /etc/php/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
|
2023-07-15 09:50:45 +02:00
|
|
|
&& cd /tmp \
|
2021-09-15 19:18:20 +02:00
|
|
|
&& export GNUPGHOME="$(mktemp -d -p /tmp)" \
|
2018-05-28 07:31:11 +02:00
|
|
|
&& gpg2 --list-public-keys || /bin/true \
|
2023-07-15 09:50:45 +02:00
|
|
|
&& gpg2 --import /tmp/release.asc \
|
2018-06-03 20:33:50 +02:00
|
|
|
&& rm -rf /var/www/* \
|
2021-07-17 20:57:55 +02:00
|
|
|
&& if expr "${RELEASE}" : '[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$' >/dev/null ; then \
|
|
|
|
echo "getting release ${RELEASE}"; \
|
|
|
|
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 ; \
|
|
|
|
else \
|
|
|
|
echo "getting tarball for ${RELEASE}"; \
|
|
|
|
git clone ${PBURL%%/}.git -b ${RELEASE}; \
|
|
|
|
(cd $(basename ${PBURL}) && git archive --prefix ${RELEASE}/ --format tgz ${RELEASE} > /tmp/${RELEASE}.tar.gz); \
|
|
|
|
fi \
|
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-07-13 21:05:43 +02:00
|
|
|
&& if [ -n "${COMPOSER_PACKAGES}" ] ; then \
|
2024-02-12 21:30:59 +01:00
|
|
|
composer remove --dev --no-update phpunit/phpunit \
|
2024-05-09 19:22:53 +02:00
|
|
|
&& composer config --unset platform \
|
2021-07-13 21:05:43 +02:00
|
|
|
&& composer require --no-update ${COMPOSER_PACKAGES} \
|
2021-07-14 21:12:09 +02:00
|
|
|
&& composer update --no-dev --optimize-autoloader \
|
2024-02-12 21:30:59 +01:00
|
|
|
rm /usr/local/bin/* ;\
|
2021-07-13 21:05:43 +02:00
|
|
|
fi \
|
2021-07-14 21:12:09 +02:00
|
|
|
&& rm *.md cfg/conf.sample.php \
|
2022-12-20 19:18:17 +01:00
|
|
|
&& mv bin 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
|
2025-02-01 12:02:25 +01:00
|
|
|
&& mkdir -p /etc/s6/services/nginx/supervise /etc/s6/services/php-fpm84/supervise \
|
2019-12-21 14:21:24 +01:00
|
|
|
&& mkfifo \
|
2021-01-17 08:54:28 +01:00
|
|
|
/etc/s6/services/nginx/supervise/control \
|
2025-02-01 12:02:25 +01:00
|
|
|
/etc/s6/services/php-fpm84/supervise/control \
|
2021-09-07 07:16:02 +02:00
|
|
|
&& chown -R ${UID}:${GID} /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
|
2021-09-29 05:43:58 +02:00
|
|
|
&& gpgconf --kill gpg-agent \
|
2024-02-12 21:30:59 +01:00
|
|
|
&& rm -rf /tmp/* composer.* \
|
2024-05-09 19:22:53 +02:00
|
|
|
&& apk del --no-cache gnupg git ${ALPINE_COMPOSER_PACKAGES}
|
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
|
2021-09-07 07:16:02 +02:00
|
|
|
USER ${UID}:${GID}
|
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
|
|
|
|
2021-09-07 07:16:02 +02:00
|
|
|
ENTRYPOINT ["/etc/init.d/rc.local"]
|