diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34cdb35 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Dockerfile.edge diff --git a/Dockerfile b/Dockerfile index 8710108..c10e1ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,16 +2,19 @@ FROM alpine:3.14 MAINTAINER PrivateBin -ENV RELEASE 1.3.5 -ENV PBURL https://github.com/PrivateBin/PrivateBin/ +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/ ENV S6_READ_ONLY_ROOT 1 ENV CONFIG_PATH /srv/cfg RUN \ # Install dependencies apk add --no-cache gnupg nginx php8 php8-curl php8-fpm php8-json php8-gd \ - php8-mbstring php8-opcache php8-pdo_mysql php8-pdo_pgsql php8-phar \ - s6-overlay tzdata \ + php8-mbstring php8-opcache php8-phar \ + s6-overlay tzdata php8-openssl $ALPINE_PACKAGES \ && apk upgrade --no-cache \ # 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 \ @@ -35,7 +38,7 @@ RUN \ && 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 \ - && composer require --no-update google/cloud-storage \ + && ([ -z "$COMPOSER_PACKAGES"] || composer require --no-update $COMPOSER_PACKAGES) \ && composer update --no-dev --optimize-autoloader \ && rm *.md cfg/conf.sample.php composer.* /usr/local/bin/* \ && mv cfg lib tpl vendor /srv \ diff --git a/buildx.sh b/buildx.sh index 782a8dc..3a10302 100755 --- a/buildx.sh +++ b/buildx.sh @@ -4,29 +4,68 @@ # accessing an uninitialized variable and print commands before executing them set -euxo pipefail -IMAGE=privatebin/nginx-fpm-alpine -QEMU_PLATFORMS=linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le -VERSION=${GITHUB_REF##*/} EVENT=$1 -[ "${EVENT}" = "schedule" ] && VERSION=nightly +VERSION=${GITHUB_REF##*/} -BUILDX_ARGS="--tag ${IMAGE}:latest \ ---tag ${IMAGE}:${VERSION} --tag ${IMAGE}:${VERSION%%-*} \ ---platform ${QEMU_PLATFORMS} ." -BUILDX_EDGE_ARGS="--tag ${IMAGE}:edge \ ---platform ${QEMU_PLATFORMS} -f Dockerfile-edge ." -# build images -docker build --no-cache --pull --output "type=image,push=false" ${BUILDX_ARGS} -sed 's/^FROM alpine:.*$/FROM alpine:edge/' Dockerfile > Dockerfile-edge -docker build --no-cache --pull --output "type=image,push=false" ${BUILDX_EDGE_ARGS} +build_image() { + local push build_args + push=$1; shift 1; + build_args="$@" -# push cached images -if [ "${EVENT}" != "pull_request" ] && ([ "${GITHUB_REF}" != "refs/heads/master" ] || [ "${EVENT}" = "schedule" ]) -then - printenv DOCKER_PASSWORD | docker login --username "${DOCKER_USERNAME}" --password-stdin - docker build --output "type=image,push=true" ${BUILDX_ARGS} - docker build --output "type=image,push=true" ${BUILDX_EDGE_ARGS} - rm -f ${HOME}/.docker/config.json -fi + docker buildx build \ + --platform linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le \ + --output type=image,push=$push \ + --pull \ + --no-cache \ + --progress plain \ + $build_args \ + . +} +image_build_arguments() { + cat< Dockerfile.edge + + image_build_arguments | while read image build_args ; do + build_image $push -f Dockerfile.edge --tag $image:edge "$build_args" + done + + rm -f Dockerfile.edge + + rm -f "$HOME/.docker/config.json" +} + +main