Skip to content
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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.github
.idea
.steiner
*.md
19 changes: 16 additions & 3 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ jobs:
strategy:
matrix:
php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
include:
# Ubuntu base image per PHP version
- { php: '8.1', ubuntu: 'jammy' }
- { php: '8.2', ubuntu: 'jammy' }
- { php: '8.3', ubuntu: 'jammy' }
- { php: '8.4', ubuntu: 'noble' }
- { php: '8.5', ubuntu: 'noble' }

steps:
- name: Checkout
Expand All @@ -44,7 +51,10 @@ jobs:
- name: PHP CLI container
uses: docker/build-push-action@v6
with:
context: php/${{ matrix.php }}
context: .
build-args: |
PHP_VERSION=${{ matrix.php }}
UBUNTU=${{ matrix.ubuntu }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.ref == 'refs/heads/master' }}
pull: true
Expand All @@ -54,14 +64,17 @@ jobs:
tags: phpdockerio/php:${{ matrix.php }}-cli
target: cli

# FPM is built on top of the CLI stage, so it reuses its layers from the cache above
- name: PHP FPM container
uses: docker/build-push-action@v6
with:
context: php/${{ matrix.php }}
context: .
build-args: |
PHP_VERSION=${{ matrix.php }}
UBUNTU=${{ matrix.ubuntu }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.ref == 'refs/heads/master' }}
pull: true
# Enable BuildKit cache restore/save across workflow runs
cache-from: type=gha,scope=php-${{ matrix.php }}
cache-to: type=gha,mode=max,scope=php-${{ matrix.php }}
tags: phpdockerio/php:${{ matrix.php }}-fpm
Expand Down
74 changes: 74 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
##########################################
# PHPDocker.io PHP CLI and FPM image #
# Build with --build-arg PHP_VERSION=8.x #
##########################################

# Ubuntu release the image is based on, also used to pick the Ondrej PPA suite
ARG UBUNTU=noble

### CLI ###

FROM ubuntu:${UBUNTU} AS cli

ARG UBUNTU
ARG PHP_VERSION

# Fixes some weird terminal issues such as broken clear / CTRL+L
ENV TERM=linux

# Ensure apt doesn't ask questions when installing stuff
ENV DEBIAN_FRONTEND=noninteractive

# Install Ondrej repos for Ubuntu, PHP, composer and selected extensions - better selection than
# the distro's packages
#
# From PHP 8.5 opcache is built into the PHP runtime and there is no separate package for it.
RUN test -n "${PHP_VERSION}" || { echo "PHP_VERSION build arg is required" >&2; exit 1; } \
&& OPCACHE="" \
&& if dpkg --compare-versions "${PHP_VERSION}" lt 8.5; then OPCACHE="php${PHP_VERSION}-opcache"; fi \
&& apt-get update \
&& apt-get install -y --no-install-recommends gnupg \
&& echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu ${UBUNTU} main" > /etc/apt/sources.list.d/ondrej-php.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \
&& apt-get update \
&& apt-get -y --no-install-recommends install \
ca-certificates \
curl \
unzip \
php${PHP_VERSION}-apcu \
php${PHP_VERSION}-cli \
php${PHP_VERSION}-curl \
php${PHP_VERSION}-mbstring \
${OPCACHE} \
php${PHP_VERSION}-readline \
php${PHP_VERSION}-xml \
php${PHP_VERSION}-zip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ~/.composer

COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

CMD ["php", "-a"]

### FPM ###

FROM cli AS fpm

ARG PHP_VERSION

# Install FPM. The version-independent symlink lets CMD (exec form, no ARG expansion) avoid the version.
RUN apt-get update \
&& apt-get -y --no-install-recommends install php${PHP_VERSION}-fpm \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \
&& ln -s /usr/sbin/php-fpm${PHP_VERSION} /usr/sbin/php-fpm

STOPSIGNAL SIGQUIT

# PHP-FPM packages need a nudge to make them docker-friendly
COPY overrides.conf /etc/php/${PHP_VERSION}/fpm/pool.d/z-overrides.conf

CMD ["/usr/sbin/php-fpm", "-O" ]

# Open up fcgi port
EXPOSE 9000
File renamed without changes.
60 changes: 0 additions & 60 deletions php/8.1/Dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions php/8.1/README.md

This file was deleted.

27 changes: 0 additions & 27 deletions php/8.1/overrides.conf

This file was deleted.

59 changes: 0 additions & 59 deletions php/8.2/Dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions php/8.2/README.md

This file was deleted.

59 changes: 0 additions & 59 deletions php/8.3/Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions php/8.3/README.md

This file was deleted.

27 changes: 0 additions & 27 deletions php/8.3/overrides.conf

This file was deleted.

Loading
Loading