create separate images for fs, pdo and gcs
- modified buildx.sh to build privatebin/fs, privatebin/pdo, privatebin/gcs and privatebin/nginx-fpm-alpine - default build of privatebin/nginx-fpm-alpine contains everything
This commit is contained in:
parent
9568519e50
commit
0a39c4075b
3 changed files with 69 additions and 26 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Dockerfile.edge
|
13
Dockerfile
13
Dockerfile
|
@ -2,16 +2,19 @@ FROM alpine:3.14
|
||||||
|
|
||||||
MAINTAINER PrivateBin <support@privatebin.org>
|
MAINTAINER PrivateBin <support@privatebin.org>
|
||||||
|
|
||||||
ENV RELEASE 1.3.5
|
ARG ALPINE_PACKAGES="php8-pdo_mysql php8-pdo_pgsql"
|
||||||
ENV PBURL https://github.com/PrivateBin/PrivateBin/
|
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 S6_READ_ONLY_ROOT 1
|
||||||
ENV CONFIG_PATH /srv/cfg
|
ENV CONFIG_PATH /srv/cfg
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
apk add --no-cache gnupg nginx php8 php8-curl php8-fpm php8-json php8-gd \
|
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 \
|
php8-mbstring php8-opcache php8-phar \
|
||||||
s6-overlay tzdata \
|
s6-overlay tzdata php8-openssl $ALPINE_PACKAGES \
|
||||||
&& apk upgrade --no-cache \
|
&& apk upgrade --no-cache \
|
||||||
# Remove (some of the) default nginx config
|
# 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 -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.json \
|
||||||
&& wget -q $(echo ${PBURL} | sed s/github.com/raw.githubusercontent.com/)${RELEASE}/composer.lock \
|
&& wget -q $(echo ${PBURL} | sed s/github.com/raw.githubusercontent.com/)${RELEASE}/composer.lock \
|
||||||
&& composer remove --dev --no-update phpunit/phpunit \
|
&& 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 \
|
&& composer update --no-dev --optimize-autoloader \
|
||||||
&& rm *.md cfg/conf.sample.php composer.* /usr/local/bin/* \
|
&& rm *.md cfg/conf.sample.php composer.* /usr/local/bin/* \
|
||||||
&& mv cfg lib tpl vendor /srv \
|
&& mv cfg lib tpl vendor /srv \
|
||||||
|
|
81
buildx.sh
81
buildx.sh
|
@ -4,29 +4,68 @@
|
||||||
# accessing an uninitialized variable and print commands before executing them
|
# accessing an uninitialized variable and print commands before executing them
|
||||||
set -euxo pipefail
|
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=$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
|
build_image() {
|
||||||
docker build --no-cache --pull --output "type=image,push=false" ${BUILDX_ARGS}
|
local push build_args
|
||||||
sed 's/^FROM alpine:.*$/FROM alpine:edge/' Dockerfile > Dockerfile-edge
|
push=$1; shift 1;
|
||||||
docker build --no-cache --pull --output "type=image,push=false" ${BUILDX_EDGE_ARGS}
|
build_args="$@"
|
||||||
|
|
||||||
# push cached images
|
docker buildx build \
|
||||||
if [ "${EVENT}" != "pull_request" ] && ([ "${GITHUB_REF}" != "refs/heads/master" ] || [ "${EVENT}" = "schedule" ])
|
--platform linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le \
|
||||||
then
|
--output type=image,push=$push \
|
||||||
printenv DOCKER_PASSWORD | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
--pull \
|
||||||
docker build --output "type=image,push=true" ${BUILDX_ARGS}
|
--no-cache \
|
||||||
docker build --output "type=image,push=true" ${BUILDX_EDGE_ARGS}
|
--progress plain \
|
||||||
rm -f ${HOME}/.docker/config.json
|
$build_args \
|
||||||
fi
|
.
|
||||||
|
}
|
||||||
|
|
||||||
|
image_build_arguments() {
|
||||||
|
cat<<!
|
||||||
|
privatebin/fs --build-arg ALPINE_PACKAGES= --build-arg COMPOSER_PACKAGES=
|
||||||
|
privatebin/pdo --build-arg COMPOSER_PACKAGES=
|
||||||
|
privatebin/gcs --build-arg ALPINE_PACKAGES=
|
||||||
|
privatebin/nginx-fpm-alpine
|
||||||
|
!
|
||||||
|
}
|
||||||
|
|
||||||
|
docker_login() {
|
||||||
|
printenv DOCKER_PASSWORD | docker login --username "$DOCKER_USERNAME" --password-stdin
|
||||||
|
}
|
||||||
|
|
||||||
|
is_image_push_required() {
|
||||||
|
[[ $EVENT != pull_request ]] && ([[ $GITHUB_REF != refs/heads/master ]] || [[ $EVENT = schedule ]])
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local push tag image build_args
|
||||||
|
|
||||||
|
# tag the image with nightly, if it is the scheduled event
|
||||||
|
|
||||||
|
[[ $EVENT == schedule ]] && tag=nightly || tag=$VERSION
|
||||||
|
if is_image_push_required; then
|
||||||
|
push=true
|
||||||
|
docker_login
|
||||||
|
else
|
||||||
|
push=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
image_build_arguments | while read image build_args ; do
|
||||||
|
build_image $push --tag $image:latest --tag $image:$tag "$build_args"
|
||||||
|
done
|
||||||
|
|
||||||
|
sed -e 's/^FROM alpine:.*$/FROM alpine:edge/' Dockerfile > 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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue