diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4bda08738..1057315d7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,30 +8,30 @@ jobs: buildx: runs-on: ubuntu-latest steps: + # Step 1: Checkout the code - name: Checkout uses: actions/checkout@v4 + # Step 2: Prepare variables for building and tagging the image - name: Prepare id: prepare run: | GHCR_IMAGE=ghcr.io/${GITHUB_REPOSITORY} DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x - VERSION=${GITHUB_REF#refs/*/} + VERSION=$(echo ${GITHUB_REF#refs/*/} | sed 's/\//-/g') # Replace / with - in tag name TAGS="${GITHUB_REPOSITORY}:${VERSION}" if [[ $GITHUB_REF == refs/tags/* ]]; then TAGS="$TAGS,${GITHUB_REPOSITORY}:latest" - fi - if [[ $VERSION == "master" ]]; then + elif [[ $VERSION == "master" ]]; 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" - fi - if [[ $VERSION == "master" ]]; then + elif [[ $VERSION == "master" ]]; then GHCR_TAGS="$GHCR_TAGS,${GHCR_IMAGE}:beta" fi @@ -39,6 +39,7 @@ jobs: echo "tags=${TAGS}" >> $GITHUB_OUTPUT echo "ghcr-tags=${GHCR_TAGS}" >> $GITHUB_OUTPUT + # Step 3: Set up QEMU for multi-platform builds - name: Set up QEMU id: qemu uses: docker/setup-qemu-action@v3 @@ -46,12 +47,12 @@ jobs: image: tonistiigi/binfmt:latest platforms: all + # Step 4: Set up Docker Buildx - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 id: buildx - # with: - # install: true + # Step 5: Login to DockerHub - name: Login to DockerHub if: github.event_name != 'pull_request' uses: docker/login-action@v3 @@ -59,15 +60,23 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build + # Step 5.5: Login to GitHub Container Registry + - name: Login to GHCR + if: github.event_name != 'pull_request' + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + # Step 6: Debug Build + - name: Debug Build on PR run: | - docker buildx build . + docker buildx build --load . + # Step 7: Test the built image - name: Test run: | 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) - name: Build and push uses: docker/build-push-action@v5 with: @@ -76,10 +85,21 @@ jobs: 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' + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.prepare.outputs.ghcr-tags }} + platforms: ${{ steps.prepare.outputs.platforms }} + + # Step 10: Update Docker Hub Description - name: Docker Hub Description + if: startsWith(github.ref, 'refs/tags/') uses: peter-evans/dockerhub-description@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} short-description: ${{ github.event.repository.description }} - diff --git a/Dockerfile b/Dockerfile index 2ce206853..8be0bd08c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,31 +6,31 @@ LABEL Maintainer="Ernesto Serrano " \ # Install packages RUN apk --no-cache add \ - php81 \ - php81-fpm \ - php81-opcache \ - php81-pecl-apcu \ - php81-mysqli \ - php81-pgsql \ - php81-json \ - php81-openssl \ - php81-curl \ - php81-zlib \ - php81-soap \ - php81-xml \ - php81-fileinfo \ - php81-phar \ - php81-intl \ - php81-dom \ - php81-xmlreader \ - php81-ctype \ - php81-session \ - php81-iconv \ - php81-tokenizer \ - php81-zip \ - php81-simplexml \ - php81-mbstring \ - php81-gd \ + php82 \ + php82-fpm \ + php82-opcache \ + php82-pecl-apcu \ + php82-mysqli \ + php82-pgsql \ + php82-json \ + php82-openssl \ + php82-curl \ + php82-zlib \ + php82-soap \ + php82-xml \ + php82-fileinfo \ + php82-phar \ + php82-intl \ + php82-dom \ + php82-xmlreader \ + php82-ctype \ + php82-session \ + php82-iconv \ + php82-tokenizer \ + php82-zip \ + php82-simplexml \ + php82-mbstring \ + php82-gd \ nginx \ runit \ curl \ diff --git a/README.md b/README.md index 35d81fef8..5fef0bfa4 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# Docker PHP-FPM 8.1 & Nginx 1.24 on Alpine Linux +# Docker PHP-FPM 8.2 & Nginx 1.24 on Alpine Linux [![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) ![nginx 1.24.0](https://img.shields.io/badge/nginx-1.18-brightgreen.svg) -![php 8.1](https://img.shields.io/badge/php-8.1-brightgreen.svg) +![php 8.2](https://img.shields.io/badge/php-8.2-brightgreen.svg) ![License MIT](https://img.shields.io/badge/license-MIT-blue.svg) -Example PHP-FPM 8.1 & Nginx 1.24 setup for Docker, build on [Alpine Linux](https://www.alpinelinux.org/). +Example PHP-FPM 8.2 & Nginx 1.24 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.1 for better performance, lower cpu usage & memory footprint +* Uses PHP 8.2 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) diff --git a/rootfs/etc/php81/conf.d/custom.ini b/rootfs/etc/php82/conf.d/custom.ini similarity index 100% rename from rootfs/etc/php81/conf.d/custom.ini rename to rootfs/etc/php82/conf.d/custom.ini diff --git a/rootfs/etc/php81/php-fpm.d/www.conf b/rootfs/etc/php82/php-fpm.d/www.conf similarity index 100% rename from rootfs/etc/php81/php-fpm.d/www.conf rename to rootfs/etc/php82/php-fpm.d/www.conf diff --git a/rootfs/etc/service/php/run b/rootfs/etc/service/php/run index 4a404ff0e..3d006649e 100755 --- a/rootfs/etc/service/php/run +++ b/rootfs/etc/service/php/run @@ -2,13 +2,13 @@ # Replace ENV vars in configuration files tmpfile=$(mktemp) -cat /etc/php81/conf.d/custom.ini | envsubst "$(env | cut -d= -f1 | sed -e 's/^/$/')" | tee "$tmpfile" > /dev/null -mv "$tmpfile" /etc/php81/conf.d/custom.ini +cat /etc/php82/conf.d/custom.ini | envsubst "$(env | cut -d= -f1 | sed -e 's/^/$/')" | tee "$tmpfile" > /dev/null +mv "$tmpfile" /etc/php82/conf.d/custom.ini tmpfile=$(mktemp) -cat /etc/php81/php-fpm.d/www.conf | envsubst "$(env | cut -d= -f1 | sed -e 's/^/$/')" | tee "$tmpfile" > /dev/null -mv "$tmpfile" /etc/php81/php-fpm.d/www.conf +cat /etc/php82/php-fpm.d/www.conf | envsubst "$(env | cut -d= -f1 | sed -e 's/^/$/')" | tee "$tmpfile" > /dev/null +mv "$tmpfile" /etc/php82/php-fpm.d/www.conf # pipe stderr to stdout and run php-fpm exec 2>&1 -exec php-fpm81 -F \ No newline at end of file +exec php-fpm82 -F \ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh index b925ce274..cb5d2278f 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,3 +1,3 @@ #!/usr/bin/env sh apk --no-cache add curl -curl --silent --fail http://app:8080 | grep 'PHP 8.1' \ No newline at end of file +curl --silent --fail http://app:8080 | grep 'PHP 8.2' \ No newline at end of file