From f624545dfdbb997d6faae49ff83b61e044ad88fe Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 6 Jun 2023 00:16:19 +0200 Subject: [PATCH 01/14] rebase on php:8.1 --- Dockerfile => Containerfile | 38 ++++++++++++++++++++------ Jenkinsfile | 54 +++++++++++++++---------------------- asset-notes.txt | 34 ----------------------- entrypoint.sh | 2 +- 4 files changed, 53 insertions(+), 75 deletions(-) rename Dockerfile => Containerfile (55%) delete mode 100644 asset-notes.txt diff --git a/Dockerfile b/Containerfile similarity index 55% rename from Dockerfile rename to Containerfile index f4262d5..aa74750 100644 --- a/Dockerfile +++ b/Containerfile @@ -1,17 +1,28 @@ -FROM reg.zknt.org/zknt/debian-php:8.1 as builder +FROM docker.io/php:8.1-apache-bullseye as builder ARG DATE -ENV PHPVER=8.1 ENV IP_PATCH=a665f449bfad129b0e20d3f2b386e30332452b40 ENV DISCOVERY_PATCH=4c82fa3e0a2d0a94417cd6b1637893c92f1b1bd5 ENV GITHUB_PATCH=920b06f6f16c22b32c8e2a14772fc053fbb973bb RUN set -xe;\ - apt-install git unzip php${PHPVER}-curl php${PHPVER}-zip php${PHPVER}-bcmath php${PHPVER}-intl php${PHPVER}-mbstring php${PHPVER}-xml + apt-get update &&\ + apt-get install --no-install-recommends -y git locales libcurl4-openssl-dev libzip-dev libicu-dev libxml2-dev libjpeg62-turbo-dev libpng-dev libmagickwand-dev libpq-dev libxpm-dev libwebp-dev &&\ + apt-get clean all &&\ + rm -rf /var/lib/apt/lists/* + +RUN set -xe;\ + docker-php-ext-configure mbstring --disable-mbregex &&\ + docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm &&\ + docker-php-ext-install -j$(nproc) curl zip bcmath intl mbstring xml pcntl gd mysqli pdo_mysql pdo_pgsql &&\ + pecl install imagick &&\ + pecl install redis &&\ + docker-php-ext-enable imagick redis RUN set -xe;\ curl https://raw.githubusercontent.com/composer/getcomposer.org/0a51b6fe383f7f61cf1d250c742ec655aa044c94/web/installer | php -- --quiet --2.2 &&\ mv composer.phar /usr/local/bin/composer + RUN set -xe;\ cd /var && rm -rf www &&\ git clone https://github.com/pixelfed/pixelfed.git www &&\ @@ -25,18 +36,29 @@ RUN set -xe;\ cp -r storage storage.skel &&\ rm -rf .git tests contrib CHANGELOG.md LICENSE .circleci .dependabot .github CODE_OF_CONDUCT.md .env.docker CONTRIBUTING.md README.md docker-compose.yml .env.testing phpunit.xml .env.example .gitignore .editorconfig .gitattributes .dockerignore -FROM reg.zknt.org/zknt/debian-php:8.1 -ENV PHPVER=8.1 +FROM docker.io/php:8.1-apache-bullseye +ARG DATE + COPY --from=builder /var/www /var/www COPY entrypoint.sh /entrypoint.sh COPY worker-entrypoint.sh /worker-entrypoint.sh COPY websockets-entrypoint.sh /websockets-entrypoint.sh COPY wait-for-db.php /wait-for-db.php -RUN apt-install php${PHPVER}-curl php${PHPVER}-zip php${PHPVER}-bcmath php${PHPVER}-intl php${PHPVER}-mbstring php${PHPVER}-xml optipng pngquant jpegoptim gifsicle ffmpeg php${PHPVER}-imagick php${PHPVER}-gd php${PHPVER}-redis php${PHPVER}-mysql php${PHPVER}-pgsql &&\ +COPY --from=builder /usr/local/lib/php/extensions/no-debug-non-zts-20210902 /usr/local/lib/php/extensions/no-debug-non-zts-20210902 +COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d + +RUN set -xe;\ + apt-get update &&\ + apt-get install --no-install-recommends -y libzip4 libpq5 libmagickwand-6.q16-6 libxpm4 libwebp6 &&\ + apt-get install --no-install-recommends -y optipng pngquant jpegoptim gifsicle ffmpeg locales gosu dumb-init &&\ + apt-get clean all &&\ + rm -rf /var/lib/apt/lists/* + +RUN set -xe;\ a2enmod rewrite &&\ sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf &&\ - sed -i 's/^post_max_size.*/post_max_size = 100M/g' /etc/php/${PHPVER}/apache2/php.ini &&\ - sed -i 's/^upload_max_filesize.*/upload_max_filesize = 100M/g' /etc/php/${PHPVER}/apache2/php.ini + sed -i 's/^post_max_size.*/post_max_size = 100M/g' /usr/local/etc/php/php.ini* &&\ + sed -i 's/^upload_max_filesize.*/upload_max_filesize = 100M/g' /usr/local/etc/php/php.ini* WORKDIR /var/www VOLUME /var/www/storage /var/www/bootstrap ENTRYPOINT /entrypoint.sh diff --git a/Jenkinsfile b/Jenkinsfile index 0d76b9d..664f34d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,41 +2,34 @@ version = "" project = "pixelfed" repo = "zknt" registry = "reg.zknt.org" -registry_credentials = "6ff44976-23cd-4cc2-902c-de8c340e65e5" timeStamp = Calendar.getInstance().getTime().format('YYYY-MM-dd',TimeZone.getTimeZone('UTC')) pipeline { agent any - triggers { - upstream(upstreamProjects: "../debian-php-81/trunk", threshold: hudson.model.Result.SUCCESS) + environment { + ZKNT_CRED = credentials("6ff44976-23cd-4cc2-902c-de8c340e65e5") + IO_CRED = credentials("3deeee3d-6fce-4430-98dd-9b4db56f43f7") + QUAY_CRED = credentials("18fb6f7e-c6bc-4d06-9bf9-08c2af6bfc1a") } stages { stage('Build image') { steps { - withDockerRegistry([ credentialsId: registry_credentials, url: "https://"+registry ]) { - script { - version = timeStamp - def customImage = docker.build(registry+'/'+repo+'/'+project, "--pull --build-arg VERSION=$version --build-arg DATE=$timeStamp .") - customImage.push(version) - customImage.push("latest") - def io_registry_credentials = "3deeee3d-6fce-4430-98dd-9b4db56f43f7" - withDockerRegistry([ credentialsId: io_registry_credentials ]) { - def io_registry_image = repo + '/' + project + ':' + version - sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image - sh "docker push " + io_registry_image - sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + ":latest" - sh "docker push " + io_registry_image.split(/\:/)[0] + ":latest" - } - - def quay_credentials= "18fb6f7e-c6bc-4d06-9bf9-08c2af6bfc1a" - withDockerRegistry([ credentialsId: quay_credentials, url: "https://quay.io" ]) { - def quay_image = 'quay.io/' + repo + '/' + project + ':' + version - sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + quay_image - sh "docker push " + quay_image - sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + quay_image.split(/\:/)[0] + ":latest" - sh "docker push " + quay_image.split(/\:/)[0] + ":latest" - } - } + script { + sh "buildah login -u " + ZKNT_CRED_USR + " -p " + ZKNT_CRED_PSW + " reg.zknt.org" + def image = registry + '/' + repo + '/' + project + sh "buildah bud -f Containerfile --build-arg DATE=$timeStamp -t pixelfed:test" + sh "buildah tag pixelfed:test reg.zknt.org/zknt/pixelfed:test" + sh "buildah push " + image + ':test' + } + script { + sh "buildah login -u $IO_CRED_USR -p $IO_CRED_PSW docker.io" + sh "buildah tag pixelfed:test docker.io/zknt/pixelfed:test" + sh "buildah push docker.io/zknt/pixelfed:test" + } + script { + sh "buildah login -u $QUAY_CRED_USR -p $QUAY_CRED_PSW quay.io" + sh "buildah tag pixelfed:test quay.io/zknt/pixelfed:test" + sh "buildah push quay.io/zknt/pixelfed:test" } } } @@ -44,10 +37,7 @@ pipeline { post { always { - sh """docker container prune -f""" - sh """docker image prune -f""" - sh """docker rmi -f \$(docker images -q $registry/$repo/$project:$version)""" - sh """for image in \$(grep FROM Dockerfile | cut -d ' ' -f 2 | grep -vi -e SCRATCH -e bootstrapped | uniq); do docker rmi -f \$(docker images -q \${image}); done""" + sh """buildah prune -a""" emailext body: 'build finished', subject: '[jenkins] docker '+project+'('+version+'): ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true } } @@ -75,4 +65,4 @@ pipeline { ] ])) } -} \ No newline at end of file +} diff --git a/asset-notes.txt b/asset-notes.txt deleted file mode 100644 index bfdbb05..0000000 --- a/asset-notes.txt +++ /dev/null @@ -1,34 +0,0 @@ -# compile assets - -add to webpack.mix.js: `.js('resources/assets/js/components/**/*.vue', 'public/js').vue()` -oder nur .vue()? - - - composer install --prefer-dist --no-interaction --no-ansi --no-dev --optimize-autoloader - npm install - export PATH=$(pwd)/node_modules/.bin:$PATH - mix --production - - -[webpack-cli] Error: Prevent writing to file that only differs in casing or query string from already written file. -This will lead to a race-condition and corrupted files on case-insensitive file systems. -/pixelfed/public/js/Activity.js -/pixelfed/public/js/activity.js - at checkSimilarFile (/pixelfed/node_modules/webpack/lib/Compiler.js:666:11) - at writeOut (/pixelfed/node_modules/webpack/lib/Compiler.js:848:11) - at /pixelfed/node_modules/webpack/lib/util/fs.js:242:5 - at FSReqCallback.oncomplete (node:fs:189:23) - - -apk add php7 git npm -apk add php7-json php7-phar php7-mbstring php7-openssl php7-dom php7-simplexml php7-xmlreader php7-zip php7-fileinfo php7-curl php7-tokenizer php7-bcmath php7-intl php7-pcntl php7-sodium php7-pdo php7-posix -curl -s https://getcomposer.org/installer | php -mv composer.phar /usr/local/bin/composer -git clone https://github.com/pixelfed/pixelfed.git -cd /pixelfed -composer install --prefer-dist --no-interaction --no-ansi --no-dev --optimize-autoloader -npm install -rm -rf public/js -export PATH=$(pwd)/node_modules/.bin:$PATH -sed -i "s/.extract([/a.vue().extract([/" webpack.mix.js -mix --production diff --git a/entrypoint.sh b/entrypoint.sh index 5f92f49..07d1d9d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -40,4 +40,4 @@ gosu www-data php artisan instance:actor echo "++++ Start apache... ++++" source /etc/apache2/envvars -/usr/local/sbin/dumb-init apache2 -DFOREGROUND +dumb-init apache2 -DFOREGROUND From b5299e8a6f560a04b394431e62484461c707d887 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 7 Jun 2023 04:34:44 +0200 Subject: [PATCH 02/14] compat old buildah --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 664f34d..c9e3069 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,7 +37,7 @@ pipeline { post { always { - sh """buildah prune -a""" + sh """buildah rmi -af""" emailext body: 'build finished', subject: '[jenkins] docker '+project+'('+version+'): ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true } } From 73dde44afee861ff7001f6ea51eb13868bea5e96 Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 9 Jun 2023 19:55:53 +0200 Subject: [PATCH 03/14] clean string interpolation --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c9e3069..7b03b63 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,12 +22,12 @@ pipeline { sh "buildah push " + image + ':test' } script { - sh "buildah login -u $IO_CRED_USR -p $IO_CRED_PSW docker.io" + sh "buildah login -u " + IO_CRED_USR+ " -p " + IO_CRED_PSW + " docker.io" sh "buildah tag pixelfed:test docker.io/zknt/pixelfed:test" sh "buildah push docker.io/zknt/pixelfed:test" } script { - sh "buildah login -u $QUAY_CRED_USR -p $QUAY_CRED_PSW quay.io" + sh "buildah login -u " + QUAY_CRED_USR+ " -p " + QUAY_CRED_PSW + " quay.io" sh "buildah tag pixelfed:test quay.io/zknt/pixelfed:test" sh "buildah push quay.io/zknt/pixelfed:test" } From 343be959f069ef52b70ee9dad10ef923f33e1a8a Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 20 Jun 2023 20:43:15 +0200 Subject: [PATCH 04/14] chown www-data --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index 07d1d9d..a496af4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,6 +7,7 @@ then fi cp -r storage.skel/* storage/ +chown -R www-data:www-data storage/ bootstrap/ php /wait-for-db.php From 5827e9189eb15bce22ba51cdc05c9b4c0445930f Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 20 Jun 2023 20:43:34 +0200 Subject: [PATCH 05/14] enable opcache --- Containerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Containerfile b/Containerfile index aa74750..6fed724 100644 --- a/Containerfile +++ b/Containerfile @@ -15,7 +15,7 @@ RUN set -xe;\ RUN set -xe;\ docker-php-ext-configure mbstring --disable-mbregex &&\ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm &&\ - docker-php-ext-install -j$(nproc) curl zip bcmath intl mbstring xml pcntl gd mysqli pdo_mysql pdo_pgsql &&\ + docker-php-ext-install -j$(nproc) curl zip bcmath intl mbstring xml pcntl gd mysqli pdo_mysql pdo_pgsql opcache &&\ pecl install imagick &&\ pecl install redis &&\ docker-php-ext-enable imagick redis From 03efdb0ba1eb426c314fc2d6680954c25ce6dab8 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 20 Jun 2023 20:43:47 +0200 Subject: [PATCH 06/14] enable prod config --- Containerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Containerfile b/Containerfile index 6fed724..0b76c14 100644 --- a/Containerfile +++ b/Containerfile @@ -57,8 +57,9 @@ RUN set -xe;\ RUN set -xe;\ a2enmod rewrite &&\ sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf &&\ - sed -i 's/^post_max_size.*/post_max_size = 100M/g' /usr/local/etc/php/php.ini* &&\ - sed -i 's/^upload_max_filesize.*/upload_max_filesize = 100M/g' /usr/local/etc/php/php.ini* + sed -i 's/^post_max_size.*/post_max_size = 100M/g' "$PHP_INI_DIR"/php.ini* &&\ + sed -i 's/^upload_max_filesize.*/upload_max_filesize = 100M/g' "$PHP_INI_DIR"/php.ini* &&\ + mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" WORKDIR /var/www VOLUME /var/www/storage /var/www/bootstrap ENTRYPOINT /entrypoint.sh From cd501d26b1fdacabea8c566974ca9fa69ba48fc0 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 17 Jul 2023 10:49:06 +0200 Subject: [PATCH 07/14] integrate beagle patch --- Containerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Containerfile b/Containerfile index 0b76c14..bd5b224 100644 --- a/Containerfile +++ b/Containerfile @@ -5,6 +5,7 @@ ARG DATE ENV IP_PATCH=a665f449bfad129b0e20d3f2b386e30332452b40 ENV DISCOVERY_PATCH=4c82fa3e0a2d0a94417cd6b1637893c92f1b1bd5 ENV GITHUB_PATCH=920b06f6f16c22b32c8e2a14772fc053fbb973bb +ENV BEAGLE_PATCH=1621a5eba09d7a2cf8ccb281db34a9d8064c4f8f RUN set -xe;\ apt-get update &&\ @@ -30,6 +31,7 @@ RUN set -xe;\ curl -L https://github.com/hnrd/pixelfed/commit/${IP_PATCH}.patch | git apply &&\ curl -L https://github.com/hnrd/pixelfed/commit/${DISCOVERY_PATCH}.patch | git apply &&\ curl -L https://github.com/hnrd/pixelfed/commit/${GITHUB_PATCH}.patch | git apply &&\ + curl -L https://github.com/hnrd/pixelfed/commit/${BEAGLE_PATCH}.patch | git apply &&\ composer install --prefer-dist --no-interaction --no-ansi --no-dev --optimize-autoloader &&\ ln -s public html &&\ chown -R www-data:www-data /var/www &&\ From dcdeac6f8c7fabb4792fee3de44ed0cc3f90f02a Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 17 Jul 2023 10:49:42 +0200 Subject: [PATCH 08/14] add timestamp --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7b03b63..d262ba6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,7 +38,7 @@ pipeline { post { always { sh """buildah rmi -af""" - emailext body: 'build finished', subject: '[jenkins] docker '+project+'('+version+'): ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true + emailext body: 'build finished', subject: '[jenkins] docker '+project+'('+timeStamp+'-test): ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true } } options { From 65e3f2e0f2d741a62da66ad409732cf9b44b79e5 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 27 Jul 2023 12:49:45 +0200 Subject: [PATCH 09/14] add username patch --- Containerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Containerfile b/Containerfile index bd5b224..8f05bf5 100644 --- a/Containerfile +++ b/Containerfile @@ -6,6 +6,7 @@ ENV IP_PATCH=a665f449bfad129b0e20d3f2b386e30332452b40 ENV DISCOVERY_PATCH=4c82fa3e0a2d0a94417cd6b1637893c92f1b1bd5 ENV GITHUB_PATCH=920b06f6f16c22b32c8e2a14772fc053fbb973bb ENV BEAGLE_PATCH=1621a5eba09d7a2cf8ccb281db34a9d8064c4f8f +ENV USERNAME_PATCH=8caee238656792ce13178edbb652ca7723a79c0f RUN set -xe;\ apt-get update &&\ @@ -32,6 +33,7 @@ RUN set -xe;\ curl -L https://github.com/hnrd/pixelfed/commit/${DISCOVERY_PATCH}.patch | git apply &&\ curl -L https://github.com/hnrd/pixelfed/commit/${GITHUB_PATCH}.patch | git apply &&\ curl -L https://github.com/hnrd/pixelfed/commit/${BEAGLE_PATCH}.patch | git apply &&\ + curl -L https://github.com/hnrd/pixelfed/commit/${USERNAME_PATCH}.patch | git apply &&\ composer install --prefer-dist --no-interaction --no-ansi --no-dev --optimize-autoloader &&\ ln -s public html &&\ chown -R www-data:www-data /var/www &&\ From a6cbb0683c6021d43c144e747377c285fb191cab Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 1 Aug 2023 09:48:14 +0200 Subject: [PATCH 10/14] port patches --- Containerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Containerfile b/Containerfile index 8f05bf5..10e3dfd 100644 --- a/Containerfile +++ b/Containerfile @@ -2,11 +2,11 @@ FROM docker.io/php:8.1-apache-bullseye as builder ARG DATE -ENV IP_PATCH=a665f449bfad129b0e20d3f2b386e30332452b40 -ENV DISCOVERY_PATCH=4c82fa3e0a2d0a94417cd6b1637893c92f1b1bd5 -ENV GITHUB_PATCH=920b06f6f16c22b32c8e2a14772fc053fbb973bb -ENV BEAGLE_PATCH=1621a5eba09d7a2cf8ccb281db34a9d8064c4f8f -ENV USERNAME_PATCH=8caee238656792ce13178edbb652ca7723a79c0f +ENV IP_PATCH=14cca91255bca69dec195112ce2fbd110e2406ca +ENV DISCOVERY_PATCH=f4a01bc97efeb259fd0c6e2016949c90675cc555 +ENV GITHUB_PATCH=06bcf80133f6c212f1674d280974c669b4524283 +ENV BEAGLE_PATCH=f45a489d5e45de21d648437880ef525a2e957b7b +ENV USERNAME_PATCH=737319bff8697263df19b9b4c0a2ee7cc8055476 RUN set -xe;\ apt-get update &&\ From f7db2ef12f9d962b7aa3f8bf9d60129dab5ce8b1 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 9 Aug 2023 11:13:30 +0200 Subject: [PATCH 11/14] build fpm image --- Containerfile.fpm | 71 +++++++++++++++++++++++++++++++++++++++++++++++ Jenkinsfile | 11 ++++++++ entrypoint.fpm.sh | 42 ++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 Containerfile.fpm create mode 100755 entrypoint.fpm.sh diff --git a/Containerfile.fpm b/Containerfile.fpm new file mode 100644 index 0000000..7bed831 --- /dev/null +++ b/Containerfile.fpm @@ -0,0 +1,71 @@ +FROM docker.io/php:8.1-fpm-bullseye as builder + +ARG DATE + +ENV IP_PATCH=14cca91255bca69dec195112ce2fbd110e2406ca +ENV DISCOVERY_PATCH=f4a01bc97efeb259fd0c6e2016949c90675cc555 +ENV GITHUB_PATCH=06bcf80133f6c212f1674d280974c669b4524283 +ENV BEAGLE_PATCH=f45a489d5e45de21d648437880ef525a2e957b7b +ENV USERNAME_PATCH=737319bff8697263df19b9b4c0a2ee7cc8055476 + +RUN set -xe;\ + apt-get update &&\ + apt-get install --no-install-recommends -y git locales libcurl4-openssl-dev libzip-dev libicu-dev libxml2-dev libjpeg62-turbo-dev libpng-dev libmagickwand-dev libpq-dev libxpm-dev libwebp-dev &&\ + apt-get clean all &&\ + rm -rf /var/lib/apt/lists/* + +RUN set -xe;\ + docker-php-ext-configure mbstring --disable-mbregex &&\ + docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm &&\ + docker-php-ext-install -j$(nproc) curl zip bcmath intl mbstring xml pcntl gd mysqli pdo_mysql pdo_pgsql opcache &&\ + pecl install imagick &&\ + pecl install redis &&\ + docker-php-ext-enable imagick redis +RUN set -xe;\ + curl https://raw.githubusercontent.com/composer/getcomposer.org/0a51b6fe383f7f61cf1d250c742ec655aa044c94/web/installer | php -- --quiet --2.2 &&\ + mv composer.phar /usr/local/bin/composer + +RUN set -xe;\ + cd /var && rm -rf www &&\ + git clone https://github.com/pixelfed/pixelfed.git www &&\ + cd www &&\ + curl -L https://github.com/hnrd/pixelfed/commit/${IP_PATCH}.patch | git apply &&\ + curl -L https://github.com/hnrd/pixelfed/commit/${DISCOVERY_PATCH}.patch | git apply &&\ + curl -L https://github.com/hnrd/pixelfed/commit/${GITHUB_PATCH}.patch | git apply &&\ + curl -L https://github.com/hnrd/pixelfed/commit/${BEAGLE_PATCH}.patch | git apply &&\ + curl -L https://github.com/hnrd/pixelfed/commit/${USERNAME_PATCH}.patch | git apply &&\ + composer install --prefer-dist --no-interaction --no-ansi --no-dev --optimize-autoloader &&\ + ln -s public html &&\ + chown -R www-data:www-data /var/www &&\ + cp -r storage storage.skel &&\ + rm -rf .git tests contrib CHANGELOG.md LICENSE .circleci .dependabot .github CODE_OF_CONDUCT.md .env.docker CONTRIBUTING.md README.md docker-compose.yml .env.testing phpunit.xml .env.example .gitignore .editorconfig .gitattributes .dockerignore + +FROM docker.io/php:8.1-fpm-bullseye +ARG DATE + +COPY --from=builder /var/www /var/www +COPY entrypoint.fpm.sh /entrypoint.sh +COPY worker-entrypoint.sh /worker-entrypoint.sh +COPY websockets-entrypoint.sh /websockets-entrypoint.sh +COPY wait-for-db.php /wait-for-db.php +COPY --from=builder /usr/local/lib/php/extensions/no-debug-non-zts-20210902 /usr/local/lib/php/extensions/no-debug-non-zts-20210902 +COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d + +RUN set -xe;\ + apt-get update &&\ + apt-get install --no-install-recommends -y libzip4 libpq5 libmagickwand-6.q16-6 libxpm4 libwebp6 &&\ + apt-get install --no-install-recommends -y optipng pngquant jpegoptim gifsicle ffmpeg locales gosu dumb-init &&\ + apt-get clean all &&\ + rm -rf /var/lib/apt/lists/* + +RUN set -xe;\ +# a2enmod rewrite &&\ +# sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf &&\ + sed -i 's/^post_max_size.*/post_max_size = 100M/g' "$PHP_INI_DIR"/php.ini* &&\ + sed -i 's/^upload_max_filesize.*/upload_max_filesize = 100M/g' "$PHP_INI_DIR"/php.ini* &&\ + mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" +WORKDIR /var/www +VOLUME /var/www/storage /var/www/bootstrap +ENTRYPOINT /entrypoint.sh + +LABEL build.date=$DATE diff --git a/Jenkinsfile b/Jenkinsfile index d262ba6..43455f1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,18 +18,29 @@ pipeline { sh "buildah login -u " + ZKNT_CRED_USR + " -p " + ZKNT_CRED_PSW + " reg.zknt.org" def image = registry + '/' + repo + '/' + project sh "buildah bud -f Containerfile --build-arg DATE=$timeStamp -t pixelfed:test" + sh "buildah bud -f Containerfile.fpm --build-arg DATE=$timeStamp -t pixelfed:fpm" sh "buildah tag pixelfed:test reg.zknt.org/zknt/pixelfed:test" + sh "buildah tag pixelfed:test reg.zknt.org/zknt/pixelfed:fpm" sh "buildah push " + image + ':test' + sh "buildah push " + image + ':fpm' } script { sh "buildah login -u " + IO_CRED_USR+ " -p " + IO_CRED_PSW + " docker.io" sh "buildah tag pixelfed:test docker.io/zknt/pixelfed:test" + sh "buildah tag pixelfed:fpm docker.io/zknt/pixelfed:fpm" + sh "buildah tag pixelfed:fpm docker.io/zknt/pixelfed:fpm-"+timeStamp sh "buildah push docker.io/zknt/pixelfed:test" + sh "buildah push docker.io/zknt/pixelfed:fpm" + sh "buildah push docker.io/zknt/pixelfed:fpm-"+timeStamp } script { sh "buildah login -u " + QUAY_CRED_USR+ " -p " + QUAY_CRED_PSW + " quay.io" sh "buildah tag pixelfed:test quay.io/zknt/pixelfed:test" + sh "buildah tag pixelfed:fpm quay.io/zknt/pixelfed:fpm" + sh "buildah tag pixelfed:fpm quay.io/zknt/pixelfed:fpm-"+timeStamp sh "buildah push quay.io/zknt/pixelfed:test" + sh "buildah push quay.io/zknt/pixelfed:fpm" + sh "buildah push quay.io/zknt/pixelfed:fpm-"+timeStamp } } } diff --git a/entrypoint.fpm.sh b/entrypoint.fpm.sh new file mode 100755 index 0000000..6cf9677 --- /dev/null +++ b/entrypoint.fpm.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -xeo pipefail + +if [ ! -z $FORCE_HTTPS ] +then + sed -i 's# storage/.docker.init +fi + +gosu www-data php artisan storage:link +gosu www-data php artisan horizon:publish +gosu www-data php artisan config:cache +gosu www-data php artisan cache:clear +gosu www-data php artisan route:cache +gosu www-data php artisan view:cache + +echo "++++ Check for needed migrations... ++++" +# check for migrations +gosu www-data php artisan migrate:status | grep No && migrations=yes || migrations=no +gosu www-data php artisan migrate:status | grep Pending && migrations=yes || migrations=no +if [ $migrations = "yes" ]; +then + gosu www-data php artisan migrate --force +fi + +# create instance actor +gosu www-data php artisan instance:actor + +dumb-init docker-php-entrypoint -F From acfee084c640c5c5ffa0120d9e28ee4f81482640 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 10 Aug 2023 16:47:22 +0200 Subject: [PATCH 12/14] copy public/ to volume --- Containerfile.fpm | 5 +++-- entrypoint.fpm.sh | 9 +++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Containerfile.fpm b/Containerfile.fpm index 7bed831..c126c19 100644 --- a/Containerfile.fpm +++ b/Containerfile.fpm @@ -53,8 +53,9 @@ COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d RUN set -xe;\ apt-get update &&\ + apt-get upgrade -y &&\ apt-get install --no-install-recommends -y libzip4 libpq5 libmagickwand-6.q16-6 libxpm4 libwebp6 &&\ - apt-get install --no-install-recommends -y optipng pngquant jpegoptim gifsicle ffmpeg locales gosu dumb-init &&\ + apt-get install --no-install-recommends -y optipng pngquant jpegoptim gifsicle ffmpeg locales gosu dumb-init rsync &&\ apt-get clean all &&\ rm -rf /var/lib/apt/lists/* @@ -65,7 +66,7 @@ RUN set -xe;\ sed -i 's/^upload_max_filesize.*/upload_max_filesize = 100M/g' "$PHP_INI_DIR"/php.ini* &&\ mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" WORKDIR /var/www -VOLUME /var/www/storage /var/www/bootstrap +VOLUME /var/www/storage /var/www/bootstrap /public ENTRYPOINT /entrypoint.sh LABEL build.date=$DATE diff --git a/entrypoint.fpm.sh b/entrypoint.fpm.sh index 6cf9677..8bcdfff 100755 --- a/entrypoint.fpm.sh +++ b/entrypoint.fpm.sh @@ -1,11 +1,6 @@ #!/usr/bin/env bash set -xeo pipefail -if [ ! -z $FORCE_HTTPS ] -then - sed -i 's# Date: Mon, 18 Sep 2023 18:51:53 +0200 Subject: [PATCH 13/14] move git hosts --- Containerfile | 10 +++++----- Containerfile.fpm | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Containerfile b/Containerfile index 10e3dfd..67595d3 100644 --- a/Containerfile +++ b/Containerfile @@ -29,11 +29,11 @@ RUN set -xe;\ cd /var && rm -rf www &&\ git clone https://github.com/pixelfed/pixelfed.git www &&\ cd www &&\ - curl -L https://github.com/hnrd/pixelfed/commit/${IP_PATCH}.patch | git apply &&\ - curl -L https://github.com/hnrd/pixelfed/commit/${DISCOVERY_PATCH}.patch | git apply &&\ - curl -L https://github.com/hnrd/pixelfed/commit/${GITHUB_PATCH}.patch | git apply &&\ - curl -L https://github.com/hnrd/pixelfed/commit/${BEAGLE_PATCH}.patch | git apply &&\ - curl -L https://github.com/hnrd/pixelfed/commit/${USERNAME_PATCH}.patch | git apply &&\ + curl -L https://git.zknt.org/chris/pixelfed/commit/${IP_PATCH}.patch | git apply &&\ + curl -L https://git.zknt.org/chris/pixelfed/commit/${DISCOVERY_PATCH}.patch | git apply &&\ + curl -L https://git.zknt.org/chris/pixelfed/commit/${GITHUB_PATCH}.patch | git apply &&\ + curl -L https://git.zknt.org/chris/pixelfed/commit/${BEAGLE_PATCH}.patch | git apply &&\ + curl -L https://git.zknt.org/chris/pixelfed/commit/${USERNAME_PATCH}.patch | git apply &&\ composer install --prefer-dist --no-interaction --no-ansi --no-dev --optimize-autoloader &&\ ln -s public html &&\ chown -R www-data:www-data /var/www &&\ diff --git a/Containerfile.fpm b/Containerfile.fpm index c126c19..0d555a6 100644 --- a/Containerfile.fpm +++ b/Containerfile.fpm @@ -29,11 +29,11 @@ RUN set -xe;\ cd /var && rm -rf www &&\ git clone https://github.com/pixelfed/pixelfed.git www &&\ cd www &&\ - curl -L https://github.com/hnrd/pixelfed/commit/${IP_PATCH}.patch | git apply &&\ - curl -L https://github.com/hnrd/pixelfed/commit/${DISCOVERY_PATCH}.patch | git apply &&\ - curl -L https://github.com/hnrd/pixelfed/commit/${GITHUB_PATCH}.patch | git apply &&\ - curl -L https://github.com/hnrd/pixelfed/commit/${BEAGLE_PATCH}.patch | git apply &&\ - curl -L https://github.com/hnrd/pixelfed/commit/${USERNAME_PATCH}.patch | git apply &&\ + curl -L https://git.zknt.org/chris/pixelfed/commit/${IP_PATCH}.patch | git apply &&\ + curl -L https://git.zknt.org/chris/pixelfed/commit/${DISCOVERY_PATCH}.patch | git apply &&\ + curl -L https://git.zknt.org/chris/pixelfed/commit/${GITHUB_PATCH}.patch | git apply &&\ + curl -L https://git.zknt.org/chris/pixelfed/commit/${BEAGLE_PATCH}.patch | git apply &&\ + curl -L https://git.zknt.org/chris/pixelfed/commit/${USERNAME_PATCH}.patch | git apply &&\ composer install --prefer-dist --no-interaction --no-ansi --no-dev --optimize-autoloader &&\ ln -s public html &&\ chown -R www-data:www-data /var/www &&\ From f2ffbf9716b9465e42fdb5d8ff1c33f1fe5c0dc2 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 7 Oct 2023 14:55:37 +0200 Subject: [PATCH 14/14] support building versions --- Containerfile | 6 +++++- Containerfile.fpm | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Containerfile b/Containerfile index 67595d3..4ba0fa9 100644 --- a/Containerfile +++ b/Containerfile @@ -1,5 +1,7 @@ FROM docker.io/php:8.1-apache-bullseye as builder +ARG VERSION=dev + ARG DATE ENV IP_PATCH=14cca91255bca69dec195112ce2fbd110e2406ca @@ -29,6 +31,7 @@ RUN set -xe;\ cd /var && rm -rf www &&\ git clone https://github.com/pixelfed/pixelfed.git www &&\ cd www &&\ + git checkout $VERSION &&\ curl -L https://git.zknt.org/chris/pixelfed/commit/${IP_PATCH}.patch | git apply &&\ curl -L https://git.zknt.org/chris/pixelfed/commit/${DISCOVERY_PATCH}.patch | git apply &&\ curl -L https://git.zknt.org/chris/pixelfed/commit/${GITHUB_PATCH}.patch | git apply &&\ @@ -42,6 +45,7 @@ RUN set -xe;\ FROM docker.io/php:8.1-apache-bullseye ARG DATE +ARG VERSION=dev COPY --from=builder /var/www /var/www COPY entrypoint.sh /entrypoint.sh @@ -68,4 +72,4 @@ WORKDIR /var/www VOLUME /var/www/storage /var/www/bootstrap ENTRYPOINT /entrypoint.sh -LABEL build.date=$DATE +LABEL build.date=$DATE version.pixelfed=$VERSION diff --git a/Containerfile.fpm b/Containerfile.fpm index 0d555a6..213cefb 100644 --- a/Containerfile.fpm +++ b/Containerfile.fpm @@ -1,5 +1,6 @@ FROM docker.io/php:8.1-fpm-bullseye as builder +ARG VERSION=dev ARG DATE ENV IP_PATCH=14cca91255bca69dec195112ce2fbd110e2406ca @@ -29,6 +30,7 @@ RUN set -xe;\ cd /var && rm -rf www &&\ git clone https://github.com/pixelfed/pixelfed.git www &&\ cd www &&\ + git checkout $VERSION &&\ curl -L https://git.zknt.org/chris/pixelfed/commit/${IP_PATCH}.patch | git apply &&\ curl -L https://git.zknt.org/chris/pixelfed/commit/${DISCOVERY_PATCH}.patch | git apply &&\ curl -L https://git.zknt.org/chris/pixelfed/commit/${GITHUB_PATCH}.patch | git apply &&\ @@ -41,6 +43,7 @@ RUN set -xe;\ rm -rf .git tests contrib CHANGELOG.md LICENSE .circleci .dependabot .github CODE_OF_CONDUCT.md .env.docker CONTRIBUTING.md README.md docker-compose.yml .env.testing phpunit.xml .env.example .gitignore .editorconfig .gitattributes .dockerignore FROM docker.io/php:8.1-fpm-bullseye +ARG VERSION=dev ARG DATE COPY --from=builder /var/www /var/www @@ -69,4 +72,4 @@ WORKDIR /var/www VOLUME /var/www/storage /var/www/bootstrap /public ENTRYPOINT /entrypoint.sh -LABEL build.date=$DATE +LABEL build.date=$DATE version.pixelfev=$VERSION