Skip to content

Commit

Permalink
PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Daynnnnn committed Nov 7, 2024
1 parent 166bbd9 commit e6040b0
Show file tree
Hide file tree
Showing 12 changed files with 548 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,37 @@ jobs:
env:
SHA: ${{ steps.short-sha.outputs.sha }}
BRANCH: ${{ steps.extract_branch.outputs.branch }}

php84:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 6

- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build the Docker image
run: ./build/build-8.4.sh
env:
SHA: ${{ steps.short-sha.outputs.sha }}
BRANCH: ${{ steps.extract_branch.outputs.branch }}
6 changes: 6 additions & 0 deletions build/build-8.4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
docker buildx build --push --platform=linux/arm64/v8,linux/amd64 -t prlx/k8s-openresty-php-php:build-$SHA-php-8.4 -f php/Dockerfile-8.4 .

if [ "$BRANCH" == 'master' ]; then
docker buildx build --push --platform=linux/arm64/v8,linux/amd64 -t prlx/k8s-openresty-php-php:release-php-8.4-latest -f php/Dockerfile-8.4 .
fi
5 changes: 5 additions & 0 deletions build/build-test-image-8.4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
BUILDNUMBER=$bamboo_buildNumber

sed -i -e "s#{{ BUILDNUMBER }}#$BUILDNUMBER#g" test/Dockerfile-8.4
docker build -t prlx/k8s-openresty-php-php:build-$BUILDNUMBER-php-8.4-test -f test/Dockerfile-8.4 .
7 changes: 7 additions & 0 deletions build/deploy-8.4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# Apply to Kubernetes
kubectl --kubeconfig=$KUBERNETESCONFIG apply -f yaml-deploy/namespace.yaml
kubectl --kubeconfig=$KUBERNETESCONFIG apply -f yaml-deploy/deployment-8.4.yaml
kubectl --kubeconfig=$KUBERNETESCONFIG apply -f yaml-deploy/service-8.4.yaml
kubectl --kubeconfig=$KUBERNETESCONFIG apply -f yaml-deploy/ingress-8.4.yaml
kubectl --kubeconfig=$KUBERNETESCONFIG apply -f yaml-deploy/certificate-8.4.yaml
199 changes: 199 additions & 0 deletions php/Dockerfile-8.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
FROM alpine:edge

ARG BLACKFIRE_ENABLED=FALSE
ARG ATATUS_ENABLED=FALSE
ARG ATATUS_VERSION=1.15.1

ENV \
# When using Composer, disable the warning about running commands as root/super user
COMPOSER_ALLOW_SUPERUSER=1 \
# Persistent runtime dependencies
DEPS="php84 \
php84-common \
php84-curl \
php84-dom \
php84-exif \
php84-fileinfo \
php84-ftp \
php84-gd \
php84-iconv \
php84-mysqli \
php84-openssl \
php84-pdo \
php84-posix \
php84-soap \
php84-zip \
php84-ldap \
php84-bcmath \
php84-calendar \
php84-gettext \
php84-mbstring \
php84-pcntl \
php84-phar \
php84-simplexml \
php84-sockets \
php84-tokenizer \
php84-xmlreader \
php84-zip \
php84-zlib \
php84-xsl \
php84-opcache \
php84-ctype \
php84-pdo_mysql \
php84-pdo_sqlite \
php84-sqlite3 \
php84-intl \
php84-fpm \
php84-mysqli \
php84-sodium \
curl \
ca-certificates \
supervisor \
bash \
tzdata \
openssl \
wget \
curl \
bash"

RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories

# Install deps
RUN apk add --no-cache \
curl \
ca-certificates \
supervisor \
bash \
tzdata \
openssl \
wget \
curl \
bash \
fcgi \
nano \
tidyhtml \
php84 \
php84-pecl-apcu \
php84-bz2 \
php84-common \
php84-curl \
php84-dom \
php84-exif \
php84-fileinfo \
php84-ftp \
php84-gd \
php84-iconv \
php84-pecl-imagick \
php84-mbstring \
php84-mysqli \
php84-openssl \
php84-pdo \
php84-posix \
php84-soap \
php84-session \
php84-pecl-redis \
php84-zip \
php84-ldap \
php84-bcmath \
php84-calendar \
php84-gettext \
php84-pcntl \
php84-phar \
php84-simplexml \
php84-shmop \
php84-sysvmsg \
php84-sysvsem \
php84-sysvshm \
php84-sockets \
php84-tidy \
php84-tokenizer \
php84-xmlreader \
php84-zip \
php84-zlib \
php84-xsl \
php84-xml \
php84-xmlwriter \
php84-opcache \
php84-ctype \
php84-pdo_mysql \
php84-pdo_sqlite \
php84-sqlite3 \
php84-intl \
php84-fpm \
php84-mysqli \
php84-sodium && \

ln -snf /usr/bin/php84 /usr/bin/php && \
ln -snf /usr/sbin/php-fpm84 /usr/sbin/php-fpm && \

# Symlink current version
mkdir /etc/php && \
ln -snf /etc/php84 /etc/php/current;

# Composer
RUN EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)" && \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" && \
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; \
then \
>&2 echo 'ERROR: Invalid installer signature' \
rm composer-setup.php \
exit 1; \
fi && \
php composer-setup.php --quiet --install-dir=/usr/local/bin --filename=composer && \
RESULT=$? && \
rm composer-setup.php && \
exit $RESULT

RUN if [ "$BLACKFIRE_ENABLED" == "TRUE" ]; then \
version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
&& architecture=$(case $(uname -m) in i386 | i686 | x86) echo "i386" ;; x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/alpine/$architecture/$version \
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz; \
fi

RUN if [ "$ATATUS_ENABLED" == "TRUE" ]; then \
# Atatus
architecture=$(case $(uname -m) in i386 | i686 | x86) echo "i386" ;; x86_64 | amd64) echo "x64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "x64" ;; esac) && \
wget https://s3.amazonaws.com/atatus-artifacts/atatus-php/downloads/atatus-php-$ATATUS_VERSION-$architecture-musl.tar.gz && tar -xzvf atatus-php-$ATATUS_VERSION-$architecture-musl.tar.gz && cd atatus-php-$ATATUS_VERSION-$architecture-musl && ./install.sh && rm -f /atatus-php-$ATATUS_VERSION-$architecture-musl.tar.gz && rm -rf /atatus-php-$ATATUS_VERSION-$architecture-musl && \
sed -i -e 's#atatus.trace.response_time = 2000#atatus.trace.response_time = 1500#g' /etc/php/current/conf.d/atatus.ini && \
sed -i -e 's#atatus.collector.pidfile = "/var/run/atatus-php-collector.pid"#atatus.collector.pidfile = "/run/atatus-php-collector.pid"#g' /etc/php/current/conf.d/atatus.ini && \
sed -i -e 's#atatus.collector.connection = "/tmp/.atatus.sock"#atatus.collector.connection = "/run/atatus.sock"#g' /etc/php/current/conf.d/atatus.ini && \
# Write log files to stdout
rm -f /var/log/atatus/agent.log && rm -f /var/log/atatus/collector.log && rm -f /var/log/atatus/debug.txt && ln -sf /dev/null /var/log/atatus/agent.log && ln -sf /dev/null /var/log/atatus/collector.log && ln -sf /dev/null /var/log/atatus/debug.txt; \
fi

# PHP Config
ADD /php/conf/php-fpm.conf /etc/php/current/php-fpm.conf
ADD /php/conf/php.ini /etc/php/current/php.ini
ADD /php/conf/php-www.conf /etc/php/current/php-fpm.d/www.conf

# Clear out garbage
RUN unset DEPS && rm -rf /run/php && rm -rf /run/php-fpm8.4

# Start script
ADD /php/scripts/start.sh /start.sh
RUN chmod +x /start.sh

# Start cron script
ADD /php/scripts/start-cron.sh /start-cron.sh
RUN chmod +x /start-cron.sh

# Start worker script
ADD /php/scripts/start-worker.sh /start-worker.sh
RUN chmod +x /start-worker.sh

# Configure script
ADD /php/scripts/configure.sh /configure.sh
RUN chmod +x /configure.sh

# Healthcheck script
ADD /php/scripts/healthcheck.sh /healthcheck.sh
RUN chmod +x /healthcheck.sh

CMD ["/start.sh"]
3 changes: 3 additions & 0 deletions test/Dockerfile-8.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM prlx/k8s-openresty-php-php:build-{{ BUILDNUMBER }}-php-8.4

ADD test/public /src/public
111 changes: 111 additions & 0 deletions yaml-deploy/deployment-8.4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
labels:
app: 'k8s-openresty-php-8.4'
name: 'k8s-openresty-php-8.4'
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 1
selector:
matchLabels:
app: 'k8s-openresty-php-8.4'
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
labels:
app: 'k8s-openresty-php-8.4'
spec:
volumes:
- name: shared-files
emptyDir: {}
- name: run
emptyDir: {}
containers:
- name: openresty
image: '{{ OPENRESTYIMAGEHERE }}'
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: nginx
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: nginx
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 5
successThreshold: 2
timeoutSeconds: 2
ports:
- containerPort: 80
name: openresty
protocol: TCP
resources:
limits:
cpu: "1"
memory: 1100Mi
requests:
cpu: 50m
memory: 64Mi
volumeMounts:
- name: shared-files
mountPath: /src-shared
- name: run
mountPath: /run
- name: php
image: 'lawrencedudley/k8s-openresty-php-php:-8.4'
imagePullPolicy: IfNotPresent
#livenessProbe:
# failureThreshold: 3
# httpGet:
# path: /healthz
# port: nginx
# scheme: HTTP
# initialDelaySeconds: 10
# periodSeconds: 10
# successThreshold: 1
# timeoutSeconds: 1
#readinessProbe:
# failureThreshold: 3
# httpGet:
# path: /healthz
# port: nginx
# scheme: HTTP
# initialDelaySeconds: 10
# periodSeconds: 5
# successThreshold: 2
# timeoutSeconds: 2
resources:
limits:
cpu: "1"
memory: 1100Mi
requests:
cpu: 50m
memory: 64Mi
volumeMounts:
- name: shared-files
mountPath: /src-shared
- name: run
mountPath: /run
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 20
15 changes: 15 additions & 0 deletions yaml-deploy/service-8.4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: 'openresty-8.4'
namespace: default
spec:
ports:
- name: openresty
port: 80
protocol: TCP
targetPort: 80
selector:
app: 'k8s-openresty-php-8.4'
sessionAffinity: None
type: NodePort
Loading

0 comments on commit e6040b0

Please sign in to comment.