Skip to content

Commit

Permalink
Update to PHP8.3 for Docker, reorganize layers
Browse files Browse the repository at this point in the history
  • Loading branch information
tchapi committed May 31, 2024
1 parent 7f4cb3f commit 11325f7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
33 changes: 23 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
FROM php:8.2-fpm-alpine

# Initial PHP image is available here:
# https://github.com/docker-library/php/blob/master/8.2/alpine3.18/fpm/Dockerfile#L33
ARG fpm_user=82:82
ENV FPM_USER=${fpm_user}

ENV PHP_OPCACHE_MEMORY_CONSUMPTION="256" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"

LABEL org.opencontainers.image.authors="tchap@tchap.me"
LABEL org.opencontainers.image.url="https://github.com/tchapi/davis/pkgs/container/davis"
LABEL org.opencontainers.image.description="A simple, fully translatable admin interface for sabre/dav based on Symfony 5 and Bootstrap 4"
# Base image, used to build extensions and the final image ———————————————————————
FROM php:8.3-fpm-alpine as base-image

# Run update, and gets basic packages and packages for runtime
RUN apk --no-progress --update add --no-cache \
Expand All @@ -27,6 +21,9 @@ RUN apk --no-progress --update add --no-cache \
# This is for PostgreSQL
libpq

# Build all extensions in a separate image ———————————————————————————————————————
FROM base-image AS extension-builder

# Intl support
RUN apk --update --virtual build-deps-intl add --no-cache icu-dev \
&& docker-php-ext-install intl \
Expand Down Expand Up @@ -70,6 +67,22 @@ RUN apk --update --virtual build-deps-imap add --no-cache imap-dev openssl-dev k
RUN docker-php-ext-install opcache
COPY ./docker/configurations/opcache.ini /usr/local/etc/php/conf.d/opcache.ini

# Final image ————————————————————————————————————————————————————————————————————
FROM base-image

ENV FPM_USER=${fpm_user}

ENV PHP_OPCACHE_MEMORY_CONSUMPTION="256" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"

LABEL org.opencontainers.image.authors="tchap@tchap.me"
LABEL org.opencontainers.image.url="https://github.com/tchapi/davis/pkgs/container/davis"
LABEL org.opencontainers.image.description="A simple, fully translatable admin interface for sabre/dav based on Symfony 5 and Bootstrap 5"

# Rapatriate built extensions
COPY --from=extension-builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d/
COPY --from=extension-builder /usr/local/lib/php/extensions /usr/local/lib/php/extensions/

# PHP-FPM healthcheck
RUN set -xe && echo "pm.status_path = /status" >> /usr/local/etc/php-fpm.d/zz-docker.conf
RUN curl https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/v0.5.0/php-fpm-healthcheck \
Expand All @@ -85,7 +98,7 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
RUN APP_ENV=prod COMPOSER_ALLOW_SUPERUSER=1 composer install --no-ansi --no-dev --no-interaction --no-progress --optimize-autoloader

# Cleanup (only useful when using --squash)
RUN docker-php-source delete && rm -rf /var/www/davis/docker
RUN rm -rf /var/www/davis/docker

USER $FPM_USER

Expand Down
28 changes: 21 additions & 7 deletions docker/Dockerfile-standalone
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
FROM php:8.2-fpm-alpine
# Initial PHP image is available here:
# https://github.com/docker-library/php/blob/master/8.2/alpine3.18/fpm/Dockerfile#L33

ENV PHP_OPCACHE_MEMORY_CONSUMPTION="256" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"

LABEL org.opencontainers.image.authors="tchap@tchap.me"
LABEL org.opencontainers.image.url="https://github.com/tchapi/davis/pkgs/container/davis-standalone"
LABEL org.opencontainers.image.description="A simple, fully translatable admin interface for sabre/dav based on Symfony 5 and Bootstrap 4 (Standalone version with reverse-proxy)"
# Base image, used to build extensions and the final image ———————————————————————
FROM php:8.3-fpm-alpine as base-image

# Run update, and gets basic packages and packages for runtime
RUN apk --no-progress --update add --no-cache \
Expand All @@ -25,6 +22,9 @@ RUN apk --no-progress --update add --no-cache \
# For the webserver and process manager
caddy supervisor

# Build all extensions in a separate image ———————————————————————————————————————
FROM base-image AS extension-builder

# Intl support
RUN apk --update --virtual build-deps-intl add --no-cache icu-dev \
&& docker-php-ext-install intl \
Expand Down Expand Up @@ -68,6 +68,20 @@ RUN apk --update --virtual build-deps-imap add --no-cache imap-dev openssl-dev k
RUN docker-php-ext-install opcache
COPY ./docker/configurations/opcache.ini /usr/local/etc/php/conf.d/opcache.ini

# Final image ————————————————————————————————————————————————————————————————————
FROM base-image

ENV PHP_OPCACHE_MEMORY_CONSUMPTION="256" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"

LABEL org.opencontainers.image.authors="tchap@tchap.me"
LABEL org.opencontainers.image.url="https://github.com/tchapi/davis/pkgs/container/davis-standalone"
LABEL org.opencontainers.image.description="A simple, fully translatable admin interface for sabre/dav based on Symfony 5 and Bootstrap 5 (Standalone version with reverse-proxy)"

# Rapatriate built extensions
COPY --from=extension-builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d/
COPY --from=extension-builder /usr/local/lib/php/extensions /usr/local/lib/php/extensions/

# Davis source
# The app folder needs to be owned by www-data so PHP-fpm can execute files
ADD --chown=www-data:www-data . /var/www/davis
Expand Down

0 comments on commit 11325f7

Please sign in to comment.