Skip to content

Commit 2d7fe88

Browse files
committed
doi apache2
1 parent 34834ca commit 2d7fe88

File tree

2 files changed

+273
-0
lines changed

2 files changed

+273
-0
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: 'docker: DOI + PHP + Apache2'
2+
3+
on:
4+
#push:
5+
# branches:
6+
# - 'main'
7+
# - 'master'
8+
# paths:
9+
# - 'doi.debian.apache.wsc.Dockerfile'
10+
# - '.github/workflows/build_docker-doi_apache.yml'
11+
workflow_dispatch:
12+
schedule:
13+
- cron: '45 4 25 * *' # At 02:45 on day-of-month 25.
14+
15+
defaults:
16+
run:
17+
shell: bash
18+
19+
jobs:
20+
21+
# --------------------------------------------------
22+
# JOB: PREPARE (Variables)
23+
# --------------------------------------------------
24+
prepare:
25+
name: Prepare build variables
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
#- name: Checkout
30+
# uses: actions/checkout@v6
31+
32+
- name: Define PHP matrix
33+
id: matrix
34+
shell: bash
35+
run: |
36+
echo 'php_matrix=["8.3","8.4","8.5"]' >> "$GITHUB_OUTPUT"
37+
38+
- name: Generate build variables
39+
id: vars
40+
shell: bash
41+
run: |
42+
BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
43+
BUILD_DATE_NUMERIC="${BUILD_DATE//[^[:digit:]]/}"
44+
#COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
45+
COMMIT_HASH=${GITHUB_SHA::7}
46+
GIT_URL=$(echo "${GITHUB_SERVER_URL}" | awk -F/ '{print $3}' | sed 's/\/*$//')
47+
GIT_URL=$(echo "$GIT_URL" | sed 's/github\.com/ghcr\.io/g') # GIT_URL switch to ghcr.io registry for GitHub
48+
GIT_REPO=${GITHUB_REPOSITORY,,}
49+
GIT_REPO_SHORT=${GIT_REPO#*/}
50+
GIT_REPO_SHORT=${GIT_REPO_SHORT#"docker-"}
51+
DOCKER_REPO=${{ vars.DOCKER_USERNAME }}/${GIT_REPO_SHORT}
52+
REDHAT_QUAY_REPO=${{ vars.REDHAT_QUAY_USERNAME }}/${GIT_REPO_SHORT}
53+
54+
#echo "ENVs: BUILD_DATE=${BUILD_DATE}, BUILD_DATE_NUMERIC=${BUILD_DATE_NUMERIC}, COMMIT_HASH=${COMMIT_HASH}, GIT_URL=${GIT_URL}, GIT_REPO=${GIT_REPO}, DOCKER_REPO=${DOCKER_REPO}, REDHAT_QUAY_REPO=${REDHAT_QUAY_REPO}"
55+
56+
# Set output parameters to action.
57+
echo "build_date=${BUILD_DATE}" >> "$GITHUB_OUTPUT"
58+
echo "build_date_numeric=${BUILD_DATE_NUMERIC}" >> "$GITHUB_OUTPUT"
59+
echo "commit_hash=${COMMIT_HASH}" >> "$GITHUB_OUTPUT"
60+
echo "git_url=${GIT_URL}" >> "$GITHUB_OUTPUT"
61+
echo "git_repo=${GIT_REPO}" >> "$GITHUB_OUTPUT"
62+
echo "git_repo_short=${GIT_REPO_SHORT}" >> "$GITHUB_OUTPUT"
63+
echo "docker_repo=${DOCKER_REPO}" >> "$GITHUB_OUTPUT"
64+
echo "redhat_quay_repo=${REDHAT_QUAY_REPO}" >> "$GITHUB_OUTPUT"
65+
66+
outputs:
67+
build_date: ${{ steps.vars.outputs.build_date }}
68+
build_date_numeric: ${{ steps.vars.outputs.build_date_numeric }}
69+
commit_hash: ${{ steps.vars.outputs.commit_hash }}
70+
git_url: ${{ steps.vars.outputs.git_url }}
71+
git_repo: ${{ steps.vars.outputs.git_repo }}
72+
git_repo_short: ${{ steps.vars.outputs.git_repo_short }}
73+
docker_repo: ${{ steps.vars.outputs.docker_repo }}
74+
quay_repo: ${{ steps.vars.outputs.redhat_quay_repo }}
75+
php_matrix: ${{ steps.matrix.outputs.php_matrix }}
76+
77+
78+
# --------------------------------------------------
79+
# JOB: DOI Debian PHP+Apache2 WSC
80+
# --------------------------------------------------
81+
build-doi-debian-fpm-wsc:
82+
name: Build doi Debian Apache2 WSC (PHP ${{ matrix.php }})
83+
runs-on: ubuntu-latest
84+
needs: prepare
85+
86+
strategy:
87+
fail-fast: false
88+
matrix:
89+
php: ${{ fromJson(needs.prepare.outputs.php_matrix) }}
90+
91+
env:
92+
BUILD_DATE: ${{ needs.prepare.outputs.build_date }}
93+
BUILD_DATE_NUMERIC: ${{ needs.prepare.outputs.build_date_numeric}}
94+
COMMIT_HASH: ${{ needs.prepare.outputs.commit_hash }}
95+
GIT_URL: ${{ needs.prepare.outputs.git_url }}
96+
GIT_REPO: ${{ needs.prepare.outputs.git_repo }}
97+
GIT_REPO_SHORT: ${{ needs.prepare.outputs.git_repo_short }}
98+
DOCKER_REPO: ${{ needs.prepare.outputs.docker_repo }}
99+
QUAY_REPO: ${{ needs.prepare.outputs.quay_repo }}
100+
PHP_VERSION: ${{ matrix.php }}
101+
102+
steps:
103+
- name: Checkout
104+
uses: actions/checkout@v6
105+
106+
- name: Debug Variables
107+
run: |
108+
echo "BUILD_DATE=${BUILD_DATE}"
109+
echo "BUILD_DATE_NUMERIC=${BUILD_DATE_NUMERIC}"
110+
echo "COMMIT_HASH=${COMMIT_HASH}"
111+
echo "GIT_URL=${GIT_URL}"
112+
echo "GIT_REPO=${GIT_REPO}"
113+
echo "GIT_REPO_SHORT=${GIT_REPO_SHORT}"
114+
echo "DOCKER_REPO=${DOCKER_REPO}"
115+
echo "QUAY_REPO=${QUAY_REPO}"
116+
echo "PHP_VERSION=${PHP_VERSION}"
117+
118+
- name: Execute Docker Setup
119+
id: docker-setup
120+
uses: ./.github/actions/docker-setup
121+
#uses: tob1as/docker-build-example/.github/actions/docker-setup@main
122+
with:
123+
git_url: ${{ env.GIT_URL }}
124+
git_username: ${{ github.repository_owner }}
125+
git_token: ${{ secrets.GITHUB_TOKEN }}
126+
docker_username: ${{ vars.DOCKER_USERNAME }}
127+
docker_password: ${{ secrets.DOCKER_PASSWORD }}
128+
quay_username: ${{ vars.REDHAT_QUAY_USERNAME }}
129+
quay_password: ${{ secrets.REDHAT_QUAY_PASSWORD }}
130+
131+
- name: Build
132+
uses: docker/build-push-action@v6
133+
with:
134+
builder: ${{ steps.docker-setup.outputs.builder_name }}
135+
context: .
136+
file: ./doi.debian.apache.wsc.Dockerfile
137+
platforms: linux/amd64,linux/arm64,linux/arm/v7
138+
pull: true
139+
push: true
140+
#target: production
141+
build-args: |
142+
BUILD_DATE=${{ env.BUILD_DATE }}
143+
VCS_REF=${{ env.COMMIT_HASH }}
144+
PHP_VERSION=${{ env.PHP_VERSION }}
145+
tags: |
146+
docker.io/${{env.DOCKER_REPO}}:${{env.PHP_VERSION}}-doi-apache-debian-wsc
147+
docker.io/${{env.DOCKER_REPO}}:${{env.PHP_VERSION}}-doi-apache-debian-wsc-${{env.COMMIT_HASH}}
148+
quay.io/${{env.QUAY_REPO}}:${{env.PHP_VERSION}}-doi-apache-debian-wsc
149+
quay.io/${{env.QUAY_REPO}}:${{env.PHP_VERSION}}-doi-apache-debian-wsc-${{env.COMMIT_HASH}}
150+
# ${{env.GIT_URL}}/${{env.GIT_REPO}}:${{env.PHP_VERSION}}-doi-apache-debian-wsc
151+
# ${{env.GIT_URL}}/${{env.GIT_REPO}}:${{env.PHP_VERSION}}-doi-apache-debian-wsc-${{env.COMMIT_HASH}}

doi.debian.apache.wsc.Dockerfile

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# build: docker build --no-cache --progress=plain --build-arg PHP_VERSION=8.4 -t docker.io/tobi312/php:8.4-doi-apache-debian-wsc -f doi.debian.apache.wsc.Dockerfile .
2+
# check: docker run --rm --name phpcheck -it docker.io/tobi312/php:8.4-doi-apache-debian-wsc -m
3+
# https://github.com/Tob1as/docker-php
4+
#
5+
# https://github.com/docker-library/php
6+
# https://hub.docker.com/_/php/
7+
#
8+
# WSC = WoltLab Suite Core <https://www.woltlab.com/en/>
9+
# PHP Extensions Requirements:
10+
# - https://manual.woltlab.com/en/requirements/#php-extensions
11+
# - https://manual.woltlab.com/en/elasticsearch/#system-requirements
12+
# - https://manual.woltlab.com/en/ldap/#system-requirements
13+
# Note: Some PHP Extensions/Modules are installed by default:
14+
# ctype curl dom libxml mbstring openssl opcache PDO zlib
15+
# These are still needed: exif gd gmp imagick intl ldap pdo_mysql redis
16+
#
17+
ARG PHP_VERSION=8.4
18+
ARG BUILD_PHP_VERSION=${PHP_VERSION}
19+
FROM php:${BUILD_PHP_VERSION}-apache
20+
ARG BUILD_PHP_VERSION
21+
22+
ARG VCS_REF
23+
ARG BUILD_DATE
24+
25+
LABEL org.opencontainers.image.authors="Tobias Hargesheimer <docker@ison.ws>" \
26+
org.opencontainers.image.title="DOI PHP+Apache2 for WSC" \
27+
org.opencontainers.image.description="DOI (Docker Official Images): Debian with PHP ${BUILD_PHP_VERSION} and Apache2 for WSC (WoltLab Suite Core)" \
28+
org.opencontainers.image.created="${BUILD_DATE}" \
29+
org.opencontainers.image.revision="${VCS_REF}" \
30+
org.opencontainers.image.licenses="MIT" \
31+
org.opencontainers.image.url="https://hub.docker.com/r/tobi312/php" \
32+
org.opencontainers.image.source="https://github.com/Tob1as/docker-php"
33+
34+
# persistent dependencies
35+
RUN set -eux; \
36+
apt-get update; \
37+
apt-get install -y --no-install-recommends \
38+
wget \
39+
netcat-openbsd \
40+
libfcgi-bin \
41+
; \
42+
rm -rf /var/lib/apt/lists/* ; \
43+
cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
44+
45+
46+
# install the PHP extensions we need (https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions)
47+
RUN set -ex; \
48+
\
49+
savedAptMark="$(apt-mark showmanual)"; \
50+
\
51+
apt-get update; \
52+
apt-get install -y --no-install-recommends \
53+
# gd
54+
#libavif-dev \
55+
libfreetype6-dev \
56+
libjpeg-dev \
57+
libpng-dev \
58+
libwebp-dev \
59+
#libxpm-dev \
60+
# gmp
61+
libgmp-dev \
62+
# intl
63+
libicu-dev \
64+
# ldap
65+
libldap2-dev \
66+
# imagick
67+
libmagickwand-dev \
68+
; \
69+
\
70+
docker-php-ext-configure gd \
71+
#--with-avif \
72+
--with-freetype \
73+
--with-jpeg \
74+
--with-webp \
75+
#--with-xpm \
76+
; \
77+
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
78+
docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \
79+
docker-php-ext-install -j "$(nproc)" \
80+
exif \
81+
gd \
82+
gmp \
83+
intl \
84+
ldap \
85+
pdo_mysql \
86+
; \
87+
\
88+
pecl install imagick; \
89+
pecl install redis; \
90+
docker-php-ext-enable \
91+
imagick \
92+
redis \
93+
; \
94+
rm -r /tmp/pear; \
95+
\
96+
# some misbehaving extensions end up outputting to stdout
97+
out="$(php -r 'exit(0);')"; \
98+
[ -z "$out" ]; \
99+
err="$(php -r 'exit(0);' 3>&1 1>&2 2>&3)"; \
100+
[ -z "$err" ]; \
101+
\
102+
extDir="$(php -r 'echo ini_get("extension_dir");')"; \
103+
[ -d "$extDir" ]; \
104+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
105+
apt-mark auto '.*' > /dev/null; \
106+
apt-mark manual $savedAptMark; \
107+
ldd "$extDir"/*.so \
108+
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \
109+
| sort -u \
110+
| xargs -r dpkg-query --search \
111+
| cut -d: -f1 \
112+
| sort -u \
113+
| xargs -rt apt-mark manual; \
114+
\
115+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
116+
rm -rf /var/lib/apt/lists/*; \
117+
\
118+
! { ldd "$extDir"/*.so | grep 'not found'; }; \
119+
# check for output like "PHP Warning: PHP Startup: Unable to load dynamic library 'foo' (tried: ...)
120+
err="$(php --version 3>&1 1>&2 2>&3)"; \
121+
[ -z "$err" ] ; \
122+
php -m

0 commit comments

Comments
 (0)