Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded to php84 and some pipeline improvementes #38

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:

if [[ $GITHUB_REF == refs/tags/* ]]; then
TAGS="$TAGS,${GITHUB_REPOSITORY}:latest"
elif [[ $VERSION == "master" ]]; then
elif [[ $VERSION == "main" ]]; then
TAGS="$TAGS,${GITHUB_REPOSITORY}:beta"
fi

GHCR_TAGS="${GHCR_IMAGE}:${VERSION}"
if [[ $GITHUB_REF == refs/tags/* ]]; then
GHCR_TAGS="$GHCR_TAGS,${GHCR_IMAGE}:latest"
elif [[ $VERSION == "master" ]]; then
elif [[ $VERSION == "main" ]]; then
GHCR_TAGS="$GHCR_TAGS,${GHCR_IMAGE}:beta"
fi

Expand Down Expand Up @@ -76,18 +76,19 @@ jobs:
docker compose version
docker compose --file docker-compose.test.yml up --exit-code-from sut --timeout 10 --build

# Step 8: Build and Push (if not a PR)
# Step 8: Build and Push to DockerHub
- name: Build and push
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ${{ steps.prepare.outputs.tags }}
platforms: ${{ steps.prepare.outputs.platforms }}

# Step 9: Push to GitHub Container Registry
- name: Push to GHCR
if: github.event_name != 'pull_request'
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
uses: docker/build-push-action@v6
with:
context: .
Expand Down
58 changes: 29 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ LABEL Maintainer="Ernesto Serrano <[email protected]>" \

# Install packages
RUN apk --no-cache add \
php83 \
php83-ctype \
php83-curl \
php83-dom \
php83-exif \
php83-fileinfo \
php83-fpm \
php83-gd \
php83-iconv \
php83-intl \
php83-json \
php83-mbstring \
php83-mysqli \
php83-opcache \
php83-openssl \
php83-pecl-apcu \
php83-pdo \
php83-pdo_mysql \
php83-pgsql \
php83-phar \
php83-session \
php83-simplexml \
php83-soap \
php83-sodium \
php83-tokenizer \
php83-xml \
php83-xmlreader \
php83-zip \
php83-zlib \
php84 \
php84-ctype \
php84-curl \
php84-dom \
php84-exif \
php84-fileinfo \
php84-fpm \
php84-gd \
php84-iconv \
php84-intl \
php84-json \
php84-mbstring \
php84-mysqli \
php84-opcache \
php84-openssl \
php84-pecl-apcu \
php84-pdo \
php84-pdo_mysql \
php84-pgsql \
php84-phar \
php84-session \
php84-simplexml \
php84-soap \
php84-sodium \
php84-tokenizer \
php84-xml \
php84-xmlreader \
php84-zip \
Comment on lines +9 to +36
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Warning: PHP 8.4 packages not yet available in Alpine repositories

The verification reveals critical issues with the proposed changes:

  1. While Alpine 3.21 repository exists, PHP 8.4 packages are not yet available in Alpine repositories (neither in stable 3.21 nor in edge).
  2. This is expected as PHP 8.4 is still in development and not yet released for production use.

Recommendation:

  • Continue using PHP 8.3 packages until PHP 8.4 is officially released and available in Alpine repositories
  • Revert the version changes from php84-* back to php83-*
🔗 Analysis chain

Verify PHP 8.4 extensions availability and compatibility

The PHP version upgrade looks comprehensive, covering all necessary extensions. However, let's verify:

  1. All listed extensions are available for PHP 8.4 in Alpine 3.21
  2. No new PHP 8.4 specific extensions are missing

Let me try a different approach to verify the PHP packages since the previous attempt had issues with binary data.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify PHP 8.4 packages in Alpine 3.21

# Check availability of all PHP 8.4 packages
echo "Verifying PHP 8.4 packages in Alpine 3.21:"
packages=($(rg -o 'php84-\w+' Dockerfile | sort -u))
for pkg in "${packages[@]}"; do
    echo "Checking $pkg:"
    curl -s https://dl-cdn.alpinelinux.org/alpine/v3.21/community/x86_64/APKINDEX.tar.gz | tar -xz -O | grep -A1 "^P:$pkg$"
done

# Check for any new PHP 8.4 specific extensions
echo "Checking for new PHP 8.4 specific extensions:"
curl -s https://dl-cdn.alpinelinux.org/alpine/v3.21/community/x86_64/APKINDEX.tar.gz | tar -xz -O | grep "^P:php84-" | sort

Length of output: 7526


Script:

#!/bin/bash
# Use apk command to check package availability
echo "Checking PHP 8.4 packages in Alpine edge repository:"
packages=(
    php84 php84-ctype php84-curl php84-dom php84-exif php84-fileinfo php84-fpm 
    php84-gd php84-iconv php84-intl php84-json php84-mbstring php84-mysqli 
    php84-opcache php84-openssl php84-pecl-apcu php84-pdo php84-pdo_mysql 
    php84-pgsql php84-phar php84-session php84-simplexml php84-soap 
    php84-sodium php84-tokenizer php84-xml php84-xmlreader php84-zip
)

# Check if Alpine 3.21 exists in the repository
echo "Verifying Alpine 3.21 availability:"
curl -s -I https://dl-cdn.alpinelinux.org/alpine/v3.21/main/ | head -n 1

# Check package list from community repository
echo -e "\nListing available PHP 8.4 packages:"
curl -s https://dl-cdn.alpinelinux.org/alpine/edge/community/ | grep -o 'php84[^"]*' || echo "No PHP 8.4 packages found"

Length of output: 876

php84-zlib \
nginx \
runit \
curl \
Expand Down
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
# Docker PHP-FPM 8.3 & Nginx 1.26 on Alpine Linux 3.20
# Docker PHP-FPM 8.4 & Nginx 1.26 on Alpine Linux 3.21

[![Docker Pulls](https://img.shields.io/docker/pulls/erseco/alpine-php-webserver.svg)](https://hub.docker.com/r/erseco/alpine-php-webserver/)
![Docker Image Size](https://img.shields.io/docker/image-size/erseco/alpine-php-webserver)
![alpine 3.20](https://img.shields.io/badge/alpine-3.20-brightgreen.svg)
![nginx 1.26.0](https://img.shields.io/badge/nginx-1.26-brightgreen.svg)
![php 8.3](https://img.shields.io/badge/php-8.3-brightgreen.svg)
![alpine 3.21](https://img.shields.io/badge/alpine-3.21-brightgreen.svg)
![nginx 1.26.2-r3](https://img.shields.io/badge/nginx-1.26.2-r3-brightgreen.svg)
![php 8.4](https://img.shields.io/badge/php-8.4-brightgreen.svg)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the Nginx version badge formatting

The Nginx badge URL is malformed due to incorrect version formatting. The -r3 suffix should be part of the version string in the URL.

Apply this change:

-![nginx 1.26.2-r3](https://img.shields.io/badge/nginx-1.26.2-r3-brightgreen.svg)
+![nginx 1.26.2-r3](https://img.shields.io/badge/nginx-1.26.2--r3-brightgreen.svg)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
![nginx 1.26.2-r3](https://img.shields.io/badge/nginx-1.26.2-r3-brightgreen.svg)
![nginx 1.26.2-r3](https://img.shields.io/badge/nginx-1.26.2--r3-brightgreen.svg)

![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)

Example PHP-FPM 8.3 & Nginx 1.26 setup for Docker, build on [Alpine Linux](https://www.alpinelinux.org/).
Example PHP-FPM 8.4 & Nginx 1.26 setup for Docker, build on [Alpine Linux](https://www.alpinelinux.org/).
The image is only +/- 25MB large.

Repository: https://github.com/erseco/alpine-php-webserver

* Built on the lightweight and secure Alpine Linux distribution
* Very small Docker image size (+/-25MB)
* Uses PHP 8.3 for better performance, lower cpu usage & memory footprint
* Uses PHP 8.4 for better performance, lower cpu usage & memory footprint
* Multi-arch support: 386, amd64, arm/v6, arm/v7, arm64, ppc64le, s390x
* Optimized for 100 concurrent users
* Optimized to only use resources when there's traffic (by using PHP-FPM's ondemand PM)
* Use of runit instead of supervisord to reduce memory footprint
* The servers Nginx, PHP-FPM run under a non-privileged user (nobody) to make it more secure
* The logs of all the services are redirected to the output of the Docker container (visible with `docker logs -f <container name>`)
* Follows the KISS principle (Keep It Simple, Stupid) to make it easy to understand and adjust the image to your needs
* Also availabe in Apache flavour: `erseco/alpine-php-webserver:apache`


## Usage

Expand All @@ -46,8 +44,6 @@ Easily serve your local PHP files using Docker Compose. This setup mounts your `
Here's a simple `docker-compose.yml` example to get you started:

```yaml
version: '3.8'

services:
webserver:
image: erseco/alpine-php-webserver
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: '3.5'
---
services:
app:
build: .
sut:
image: alpine:3.21
image: alpine:latest
depends_on:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid using 'latest' tag for test environment

Using alpine:latest could lead to non-reproducible tests and unexpected failures. Instead, pin to a specific version that matches your production environment.

-    image: alpine:latest
+    image: alpine:3.21

Rationale:

  • Ensures consistent test environment
  • Prevents unexpected breaks from Alpine updates
  • Maintains parity with production environment
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
image: alpine:latest
image: alpine:3.21

- app
command: /tmp/run_tests.sh
Expand Down
8 changes: 4 additions & 4 deletions rootfs/bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ mv "$tmpfile" /etc/nginx/nginx.conf

# Replace ENV vars in php configuration files
tmpfile=$(mktemp)
cat /etc/php83/conf.d/custom.ini | envsubst "$(env | cut -d= -f1 | sed -e 's/^/$/')" | tee "$tmpfile" > /dev/null
mv "$tmpfile" /etc/php83/conf.d/custom.ini
cat /etc/php84/conf.d/custom.ini | envsubst "$(env | cut -d= -f1 | sed -e 's/^/$/')" | tee "$tmpfile" > /dev/null
mv "$tmpfile" /etc/php84/conf.d/custom.ini

tmpfile=$(mktemp)
cat /etc/php83/php-fpm.d/www.conf | envsubst "$(env | cut -d= -f1 | sed -e 's/^/$/')" | tee "$tmpfile" > /dev/null
mv "$tmpfile" /etc/php83/php-fpm.d/www.conf
cat /etc/php84/php-fpm.d/www.conf | envsubst "$(env | cut -d= -f1 | sed -e 's/^/$/')" | tee "$tmpfile" > /dev/null
mv "$tmpfile" /etc/php84/php-fpm.d/www.conf

echo "Starting startup scripts in /docker-entrypoint-init.d ..."
for script in $(find /docker-entrypoint-init.d/ -executable -type f | sort); do
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion rootfs/etc/service/php/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# pipe stderr to stdout and run php-fpm
exec 2>&1
exec php-fpm83 -F
exec php-fpm84 -F
2 changes: 1 addition & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env sh
apk --no-cache add curl
curl --silent --fail http://app:8080 | grep 'PHP 8.3'
curl --silent --fail http://app:8080 | grep 'PHP 8.4'
Loading