Skip to content

Commit

Permalink
add php 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
troyxmccall committed Nov 22, 2024
1 parent 0c91422 commit 7e1bf99
Show file tree
Hide file tree
Showing 13 changed files with 425 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3','8.4']
type: ['cli', 'fpm']
steps:
- name: Checkout repository
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cross platform alpine-based php 7.1 - 8.3 images
# cross platform alpine-based php 7.1 - 8.4 images

## Container Runtimes

Expand All @@ -15,7 +15,7 @@ docker pull mxmd/php:<VERSION>-<TYPE>
```

Where:
- `<VERSION>` is the desired PHP major version with the latest minor release (e.g., `7.4`), or you can specify a minor version (e.g., `7.1.33`, `8.0.30`).
- `<VERSION>` is the desired PHP major version with the latest minor release (e.g., `7.4`), or you can specify a minor version (e.g., `7.1.33`, `8.1.13`).
- `<TYPE>` is either `cli` or `fpm`.

For example, to pull the PHP 7.4.33 FPM image:
Expand All @@ -34,6 +34,8 @@ Available versions of our images along with their Docker Hub links:
- [8.1-cli](https://hub.docker.com/r/mxmd/php/tags?page=1&name=8.1-cli), [8.1-fpm](https://hub.docker.com/r/mxmd/php/tags?page=1&name=8.1-fpm)
- [8.2-cli](https://hub.docker.com/r/mxmd/php/tags?page=1&name=8.2-cli), [8.2-fpm](https://hub.docker.com/r/mxmd/php/tags?page=1&name=8.2-fpm)
- [8.3-cli](https://hub.docker.com/r/mxmd/php/tags?page=1&name=8.3-cli), [8.3-fpm](https://hub.docker.com/r/mxmd/php/tags?page=1&name=8.3-fpm)
- [8.4-cli](https://hub.docker.com/r/mxmd/php/tags?page=1&name=8.4-cli), [8.4-fpm](https://hub.docker.com/r/mxmd/php/tags?page=1&name=8.4-fpm)


#### Usage with Docker Compose

Expand Down
2 changes: 1 addition & 1 deletion buildx-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ docker buildx create --use builder

# Variables
TYPES=("cli" "fpm")
PHP_VERSIONS=("7.1" "7.2" "7.3" "7.4" "8.0" "8.1" "8.2" "8.3")
PHP_VERSIONS=("7.1" "7.2" "7.3" "7.4" "8.0" "8.1" "8.2" "8.3" "8.4")

TARGET_PHP_VERSIONS=("${PHP_VERSIONS[@]}")
TARGET_TYPES=("${TYPES[@]}")
Expand Down
4 changes: 4 additions & 0 deletions cli/8.4/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PLATFORM=linux/amd64
PHP_VERSION=8.4.1
PHP_VERSION_MAJOR=8.4
ALPINE_VERSION=3.20
102 changes: 102 additions & 0 deletions cli/8.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Load the PHP version and Alpine version from the .env file
ARG PHP_VERSION=${PHP_VERSION}
ARG ALPINE_VERSION=${ALPINE_VERSION}

# Pull the PHP image with the specified version and Alpine version
FROM --platform=$TARGETPLATFORM php:${PHP_VERSION}-cli-alpine${ALPINE_VERSION}

# Redefine the ARGs after FROM

ARG PHP_VERSION
ARG ALPINE_VERSION

# Add Repositories
RUN rm -f /etc/apk/repositories &&\
echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/main" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community" >> /etc/apk/repositories

# upgrade
RUN apk update && \
apk upgrade

# Add Build Dependencies
RUN apk add --no-cache --virtual .build-deps \
zlib-dev \
libjpeg-turbo-dev \
libpng-dev \
libxml2-dev \
bzip2-dev \
zip \
libwebp-dev \
openssl-dev


# Add App Dependencies
RUN apk add --update --no-cache \
jpegoptim \
pngquant \
optipng \
vim \
mysql-client \
bash \
shared-mime-info \
zip \
git \
curl \
wget \
gcompat \
icu-dev \
freetype-dev \
libzip-dev \
bzip2 \
libwebp \
libpng \
fcgi \
su-exec \
shadow \
rsync \
linux-headers

# Configure & Install Extension
RUN docker-php-ext-configure gd --with-jpeg=/usr/include/ --with-freetype=/usr/include/ --with-webp=/usr/include/ && \
docker-php-ext-install \
bcmath \
bz2 \
gd \
intl \
mysqli \
pcntl \
pdo_mysql \
sockets \
zip \
&& apk del -f .build-deps

ARG HOST_USER_GID
ARG HOST_USER_UID

LABEL afterapk="php-cli-alpine-$PHP_VERSION"

ARG HOST_ENV=development



# Install Composer with the filename 'composer2'
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2

# Create a symbolic link named 'composer' that points to 'composer2'
RUN ln -s /usr/local/bin/composer2 /usr/local/bin/composer

ENV COMPOSER_ALLOW_SUPERUSER=1
ENV PATH="./vendor/bin:$PATH"

# Setup Working Dir to model BH
WORKDIR /

# Copy entrypoint script
COPY _shared/entrypoint.sh /usr/local/bin/entrypoint

# Set permissions for the entrypoint script
RUN chmod +x /usr/local/bin/entrypoint

# Set entrypoint
ENTRYPOINT ["entrypoint"]
78 changes: 78 additions & 0 deletions cli/8.4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# cross platform alpine-based php* images



### required ENV

make sure these ENV varaiables exist on your host-machine

```
HOST_USER_GID
HOST_USER_UID
```
#### set these env vars

ie on `macOS` in `~/.extra` or `~/.bash_profile`

get `HOST_USER_UID`

```
id -u
```


get `HOST_USER_GID`
```
id -g
```


### run
```
echo "export HOST_USER_GID=$(id -g)" >> ~/.bash_profile && echo "export HOST_USER_UID=$(id -u)" >> ~/.bash_profile && echo "export DOCKER_USER=$(id -u):$(id -g)" >> ~/.bash_profile
```


### optional ENV

this will enable opcache and php.ini production settings

```ini
HOST_ENV=production
```


docker-compose.yml
```yaml
php80:
image: mxmb/php:8.4-cli
# optional: disable if you're running behind a proxy like traefik
ports:
- "9000:9000"
volumes:
# real time sync for app php files
- .:/app
# cache laravel libraries dir
- ./vendor:/app/vendor:cached
# logs and sessions should be authorative inside docker
- ./storage:/app/storage:delegated
# cache static assets bc cli doesn't need to update css or js
- ./public:/app/public:cached
# additional php config REQUIRED
- ./docker-conf/php-ini:/usr/local/etc/php/custom.d
env_file:
- .env
environment:
# note that apline has dif dir structures: /user/local/etc - conf.d need to be scanned here for all modules from image
- PHP_INI_SCAN_DIR=/usr/local/etc/php/conf.d/:/usr/local/etc/php/custom.d
# composer settings
- COMPOSER_AUTH=${COMPOSER_AUTH}
- COMPOSER_ALLOW_SUPERUSER=1
# these are CRITICAL
- HOST_USER_UID=${HOST_USER_UID:-1000}
- HOST_USER_GID=${HOST_USER_GID:-1000}
# enables opache in prod
- HOST_ENV=${HOST_ENV:-production}
# this should only be used in troubleshooting
- EXEC_AS_ROOT=0
```
16 changes: 16 additions & 0 deletions cli/8.4/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.8'

services:
php83-alpine:
build:
context: .
dockerfile: Dockerfile
args:
PLATFORM: ${PLATFORM}
PHP_VERSION: ${PHP_VERSION}
ALPINE_VERSION: ${ALPINE_VERSION}
image: madebymode/php83-cli-alpine:latest
environment:
HOST_ENV: development
HOST_USER_UID: 1000
HOST_USER_GID: 1000
2 changes: 1 addition & 1 deletion fpm/8.3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ HOST_ENV=production
docker-compose.yml
```yaml
php80:
image: mxmb/php:8.2-fpm
image: mxmb/php:8.3-fpm
# optional: disable if you're running behind a proxy like traefik
ports:
- "9000:9000"
Expand Down
4 changes: 4 additions & 0 deletions fpm/8.4/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PLATFORM=linux/amd64
PHP_VERSION=8.4.1
PHP_VERSION_MAJOR=8.4
ALPINE_VERSION=3.20
119 changes: 119 additions & 0 deletions fpm/8.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Load the PHP version and Alpine version from the .env file
ARG PHP_VERSION=${PHP_VERSION}
ARG ALPINE_VERSION=${ALPINE_VERSION}

# Pull the PHP image with the specified version and Alpine version
FROM --platform=$TARGETPLATFORM php:${PHP_VERSION}-fpm-alpine${ALPINE_VERSION}

# Redefine the ARGs after FROM

ARG PHP_VERSION
ARG ALPINE_VERSION
ENV DISABLE_HEALTHCHECK=false

# Add Repositories
RUN rm -f /etc/apk/repositories &&\
echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/main" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community" >> /etc/apk/repositories

# upgrade
RUN apk update && \
apk upgrade

# Add Build Dependencies
RUN apk add --no-cache --virtual .build-deps \
zlib-dev \
libjpeg-turbo-dev \
libpng-dev \
libxml2-dev \
bzip2-dev \
zip \
libwebp-dev \
openssl-dev


# Add App Dependencies
RUN apk add --update --no-cache \
jpegoptim \
pngquant \
optipng \
vim \
mysql-client \
bash \
shared-mime-info \
zip \
git \
curl \
wget \
gcompat \
icu-dev \
freetype-dev \
libzip-dev \
bzip2 \
libwebp \
libpng \
fcgi \
su-exec \
shadow \
rsync \
linux-headers

# Configure & Install Extension
RUN docker-php-ext-configure gd --with-jpeg=/usr/include/ --with-freetype=/usr/include/ --with-webp=/usr/include/ && \
docker-php-ext-install \
bcmath \
bz2 \
gd \
intl \
mysqli \
pcntl \
pdo_mysql \
sockets \
zip \
opcache \
&& apk del -f .build-deps

ARG HOST_USER_GID
ARG HOST_USER_UID

LABEL afterapk="php-fpm-alpine-$PHP_VERSION"

ARG HOST_ENV=development

# Create and configure status.conf for PHP-FPM status page
RUN echo '[www]' > /usr/local/etc/php-fpm.d/status.conf && \
echo 'pm.status_path = /status' >> /usr/local/etc/php-fpm.d/status.conf

# Health check script
COPY _shared/php-fpm-healthcheck /usr/local/bin/
RUN chmod +x /usr/local/bin/php-fpm-healthcheck



# Install Composer with the filename 'composer2'
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2

# Create a symbolic link named 'composer' that points to 'composer2'
RUN ln -s /usr/local/bin/composer2 /usr/local/bin/composer

ENV COMPOSER_ALLOW_SUPERUSER=1
ENV PATH="./vendor/bin:$PATH"

# Setup Working Dir to model BH
WORKDIR /

# Add a condition for the health check
HEALTHCHECK --interval=5s --timeout=1s \
CMD if [ -z "$DISABLE_HEALTHCHECK" ]; then php-fpm-healthcheck || exit 1; else exit 0; fi

# Copy entrypoint script
COPY _shared/entrypoint.sh /usr/local/bin/entrypoint

# Set permissions for the entrypoint script
RUN chmod +x /usr/local/bin/entrypoint

# Set entrypoint
ENTRYPOINT ["entrypoint"]

# Set default command
CMD ["php-fpm", "-F"]
Loading

0 comments on commit 7e1bf99

Please sign in to comment.