Skip to content

Commit

Permalink
Ajout de fichiers de configuration et de test, mise à jour de la conf…
Browse files Browse the repository at this point in the history
…iguration Nginx et Caddy, et suppression de Dockerfile obsolète
  • Loading branch information
arnaud-ritti committed Dec 2, 2024
1 parent 2950b47 commit 272d845
Show file tree
Hide file tree
Showing 19 changed files with 691 additions and 1,030 deletions.
499 changes: 130 additions & 369 deletions .github/workflows/build_php.yml

Large diffs are not rendered by default.

76 changes: 72 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,28 @@ endif
--file $(DOCKERFILE) $(IMAGE) \
--cache-from=type=registry,ref=$(REGISTRY)$(IMAGE_NAME):$(VERSION)-$(VARIATION)

build-local: ## Build the container
$(eval DOCKERFILE := $(IMAGE)/Dockerfile-$(VERSION).$(VARIATION))
ifeq ("$(wildcard $(DOCKERFILE))","")
$(eval DOCKERFILE := $(IMAGE)/Dockerfile.$(VARIATION))
endif
docker buildx create --use
docker buildx build \
--load \
--platform linux/amd64 \
--tag $(IMAGE_NAME):$(VERSION)-$(VARIATION) \
--build-arg PHP_VERSION=$(VERSION) \
--file $(DOCKERFILE) $(IMAGE)

# Run containers
run: stop ## Run container
docker run -i -t --rm --name="$(IMAGE_NAME)" $(IMAGE_NAME)
@docker run -i -t --rm --name="$(IMAGE_NAME)" $(IMAGE_NAME)

stop: ## Stop running containers
docker stop $(IMAGE_NAME)
@docker stop $(IMAGE_NAME)

rm: stop ## Stop and remove running containers
docker rm $(IMAGE_NAME)
@docker rm $(IMAGE_NAME)

# Docker release - build, tag and push the container
release: build-nc publish ## Make a release by building and publishing the tagged container
Expand All @@ -65,4 +78,59 @@ publish: tag ## publish the taged container
# Docker tagging
tag: ## Generate container tag
@echo 'create tag $(VERSION)-$(VARIATION)'
docker tag $(IMAGE_NAME) $(REGISTRY)$(IMAGE_NAME):$(VERSION)-$(VARIATION)
docker tag $(IMAGE_NAME) $(REGISTRY)$(IMAGE_NAME):$(VERSION)-$(VARIATION)

[email protected]:
IMAGE=php VERSION=8.4 VARIATION=fpm $(MAKE) build-local

[email protected]:
IMAGE=php VERSION=8.2 VARIATION=caddy $(MAKE) build-local

[email protected]:
IMAGE=php VERSION=8.2 VARIATION=apache $(MAKE) build-local

[email protected]:
IMAGE=php VERSION=8.2 VARIATION=nginx $(MAKE) build-local

[email protected]:
IMAGE=php VERSION=8.2 VARIATION=frankenphp $(MAKE) build-local

[email protected]:
$(eval IMAGE := php)
$(eval VERSION := 8.2)
$(eval VARIATION := caddy)
$(eval IMAGE_NAME := $(IMAGE_PREFIX)/$(IMAGE):$(VERSION)-$(VARIATION))
@docker stop $(IMAGE)_$(VERSION)-$(VARIATION) || true
@docker run -i -t --rm -p 1234:80 -v ./test/:/var/www/html/ --name="$(IMAGE)_$(VERSION)-$(VARIATION)" $(IMAGE_NAME)

[email protected]:
$(eval IMAGE := php)
$(eval VERSION := 8.2)
$(eval VARIATION := apache)
$(eval IMAGE_NAME := $(IMAGE_PREFIX)/$(IMAGE):$(VERSION)-$(VARIATION))
@docker stop $(IMAGE)_$(VERSION)-$(VARIATION) || true
@docker run -i -t --rm -p 1234:80 -v ./test/:/var/www/html/ --name="$(IMAGE)_$(VERSION)-$(VARIATION)" $(IMAGE_NAME)

[email protected]:
$(eval IMAGE := php)
$(eval VERSION := 8.2)
$(eval VARIATION := nginx)
$(eval IMAGE_NAME := $(IMAGE_PREFIX)/$(IMAGE):$(VERSION)-$(VARIATION))
@docker stop $(IMAGE)_$(VERSION)-$(VARIATION) || true
@docker run -i -t --rm -p 1234:80 -v ./test/:/var/www/html/ --name="$(IMAGE)_$(VERSION)-$(VARIATION)" $(IMAGE_NAME)

[email protected]:
$(eval IMAGE := php)
$(eval VERSION := 8.2)
$(eval VARIATION := frankenphp)
$(eval IMAGE_NAME := $(IMAGE_PREFIX)/$(IMAGE):$(VERSION)-$(VARIATION))
@docker stop $(IMAGE)_$(VERSION)-$(VARIATION) || true
@docker run -i -t --rm -p 1234:80 -v ./test/:/var/www/html/ --name="$(IMAGE)_$(VERSION)-$(VARIATION)" $(IMAGE_NAME)

[email protected]:
$(eval IMAGE := php)
$(eval VERSION := 8.2)
$(eval VARIATION := frankenphp)
$(eval IMAGE_NAME := $(IMAGE_PREFIX)/$(IMAGE):$(VERSION)-$(VARIATION))
@docker stop $(IMAGE)_$(VERSION)-$(VARIATION) || true
@docker run -i -t --rm -p 1234:80 -v ./test/:/var/www/html/ -e FRANKENPHP_CONFIG="worker /var/www/html/index.php" -e FRANKENPHP_WORKER=true --name="$(IMAGE)_$(VERSION)-$(VARIATION)" $(IMAGE_NAME)
12 changes: 8 additions & 4 deletions php/Dockerfile.caddy
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ RUN set -eux; \

COPY --from=caddy-builder /usr/bin/caddy /usr/bin/caddy

RUN apk --update add --no-cache supervisor \
ca-certificates \
mailcap \
RUN set -x \
&& apk --update add --no-cache supervisor \
ca-certificates \
mailcap \
nss-tools \
&& rm -rf /tmp/* /var/cache/apk/*

ENV XDG_CONFIG_HOME="/config"
ENV XDG_DATA_HOME="/data"

ENV SERVER_NAME=":80"
ENV DOCUMENT_ROOT="/var/www/html/"

EXPOSE 80
EXPOSE 443
EXPOSE 443/udp
EXPOSE 2019
EXPOSE 2021

WORKDIR /var/www/html/
VOLUME ["/etc/caddy", "/config/caddy", "/data/caddy", "/var/www/html"]
Expand Down
12 changes: 8 additions & 4 deletions php/Dockerfile.caddy-wkhtmltopdf
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ RUN set -eux; \

COPY --from=caddy-builder /usr/bin/caddy /usr/bin/caddy

RUN apk --update add --no-cache supervisor \
ca-certificates \
mailcap \
RUN set -x \
&& apk --update add --no-cache supervisor \
ca-certificates \
mailcap \
nss-tools \
&& rm -rf /tmp/* /var/cache/apk/*

ENV XDG_CONFIG_HOME="/config"
ENV XDG_DATA_HOME="/data"

ENV SERVER_NAME=":80"
ENV DOCUMENT_ROOT="/var/www/html/"

EXPOSE 80
EXPOSE 443
EXPOSE 443/udp
EXPOSE 2019
EXPOSE 2021

WORKDIR /var/www/html/
VOLUME ["/etc/caddy", "/config/caddy", "/data/caddy", "/var/www/html"]
Expand Down
7 changes: 4 additions & 3 deletions php/Dockerfile.fpm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ENV XDEBUG_MODE='off'

WORKDIR /var/www/html

RUN apk add --upgrade --no-cache \
RUN apk add --upgrade --no-cache \
acl \
bash \
rsync \
Expand All @@ -60,7 +60,7 @@ RUN apk add --upgrade --no-cache \
openssl \
zip \
unzip \
;
&& rm -rf /tmp/* /var/cache/apk/*

# persistent / runtime deps
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
Expand All @@ -76,7 +76,8 @@ COPY config/fpm/pool.d /usr/local/etc/pool.d
RUN echo "expose_php = Off" > /usr/local/etc/php/conf.d/expose_php.ini

# Install extensions
RUN install-php-extensions opcache sysvsem soap intl gettext ldap swoole zip amqp redis mysqli pgsql pdo_mysql pdo_pgsql gd exif xdebug
RUN install-php-extensions opcache intl gettext zip redis mysqli pgsql pdo_mysql pdo_pgsql gd exif xdebug
RUN install-php-extensions sysvsem soap ldap amqp

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

Expand Down
94 changes: 94 additions & 0 deletions php/Dockerfile.frankenphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# syntax=docker/dockerfile:1
ARG PHP_VERSION
FROM dunglas/frankenphp:php${PHP_VERSION}

ENV COMPOSER_ALLOW_SUPERUSER='1'
ENV COMPOSER_MEMORY_LIMIT='-1'
ENV PHP_INI_MEMORY_LIMIT='-1'

ENV PHP_INI_DATE_TIMEZONE='UTC'
ENV PHP_INI_CGI_FIX_PATHINFO='0'

ENV PHP_INI_UPLOAD_MAX_FILESIZE='16M'
ENV PHP_INI_POST_MAX_SIZE='16M'

ENV PHP_INI_ERROR_REPORTING='E_ALL & ~E_DEPRECATED & ~E_STRICT'
ENV PHP_INI_DISPLAY_ERRORS='Off'
ENV PHP_INI_DISPLAY_STARTUP_ERRORS='Off'

ENV PHP_INI_REALPATH_CACHE_SIZE='4096k'
ENV PHP_INI_REALPATH_CACHE_TTL='120'

ENV PHP_INI_OPCACHE_MEMORY_CONSUMPTION='128'
ENV PHP_INI_OPCACHE_INTERNED_STRINGS_BUFFER='8'
ENV PHP_INI_OPCACHE_MAX_ACCELERATED_FILES='4000'
ENV PHP_INI_OPCACHE_REVALIDATE_FREQ='60'
ENV PHP_INI_OPCACHE_VALIDATE_TIMESTAMPS='1'
ENV PHP_INI_OPCACHE_FAST_SHUTDOWN='1'
ENV PHP_INI_OPCACHE_ENABLE_CLI='1'
ENV PHP_INI_OPCACHE_ENABLE='1'
ENV PHP_INI_OPCACHE_PRELOAD=''
ENV PHP_INI_OPCACHE_PRELOAD_USER=''

ENV PHP_INI_SOAP_WSDL_CACHE_ENABLED='1'

ENV PHP_INI_MAX_EXECUTION_TIME='30'
ENV PHP_INI_MAX_INPUT_TIME='60'

ENV PHP_INI_SENDMAIL_PATH='sendmail -t -i'

ENV XDEBUG_REMOTE_AUTOSTART='1'
ENV XDEBUG_REMOTE_PORT='9003'
ENV XDEBUG_START_WITH_REQUEST='trigger'
ENV XDEBUG_MODE='off'

RUN set -x \
&& apt-get update && apt-get install -y supervisor \
ca-certificates \
mime-support \
libnss3-tools \
imagemagick \
jpegoptim \
optipng \
webp \
pngquant \
ffmpeg \
libavif-dev \
mysql-client \
postgresql-client \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

ENV XDG_CONFIG_HOME="/config"
ENV XDG_DATA_HOME="/data"

ENV SERVER_NAME=":80"
ENV DOCUMENT_ROOT="/var/www/html/"

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions

WORKDIR /var/www/html

EXPOSE 80
EXPOSE 443
EXPOSE 443/udp
EXPOSE 2019

# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

COPY config/php.ini /usr/local/etc/php/conf.d/000-php.ini

RUN echo "expose_php = Off" > /usr/local/etc/php/conf.d/expose_php.ini

# Install extensions
RUN set -x \
install-php-extensions opcache intl gettext zip redis mysqli pgsql pdo_mysql pdo_pgsql gd exif xdebug pcntl

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

COPY config/frankenphp/Caddyfile /etc/caddy/

STOPSIGNAL SIGQUIT

CMD ["--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
93 changes: 93 additions & 0 deletions php/Dockerfile.frankenphp-wkhtmltopdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# syntax=docker/dockerfile:1
ARG PHP_VERSION
FROM dunglas/frankenphp:php${PHP_VERSION}

ENV COMPOSER_ALLOW_SUPERUSER='1'
ENV COMPOSER_MEMORY_LIMIT='-1'
ENV PHP_INI_MEMORY_LIMIT='-1'

ENV PHP_INI_DATE_TIMEZONE='UTC'
ENV PHP_INI_CGI_FIX_PATHINFO='0'

ENV PHP_INI_UPLOAD_MAX_FILESIZE='16M'
ENV PHP_INI_POST_MAX_SIZE='16M'

ENV PHP_INI_ERROR_REPORTING='E_ALL & ~E_DEPRECATED & ~E_STRICT'
ENV PHP_INI_DISPLAY_ERRORS='Off'
ENV PHP_INI_DISPLAY_STARTUP_ERRORS='Off'

ENV PHP_INI_REALPATH_CACHE_SIZE='4096k'
ENV PHP_INI_REALPATH_CACHE_TTL='120'

ENV PHP_INI_OPCACHE_MEMORY_CONSUMPTION='128'
ENV PHP_INI_OPCACHE_INTERNED_STRINGS_BUFFER='8'
ENV PHP_INI_OPCACHE_MAX_ACCELERATED_FILES='4000'
ENV PHP_INI_OPCACHE_REVALIDATE_FREQ='60'
ENV PHP_INI_OPCACHE_VALIDATE_TIMESTAMPS='1'
ENV PHP_INI_OPCACHE_FAST_SHUTDOWN='1'
ENV PHP_INI_OPCACHE_ENABLE_CLI='1'
ENV PHP_INI_OPCACHE_ENABLE='1'
ENV PHP_INI_OPCACHE_PRELOAD=''
ENV PHP_INI_OPCACHE_PRELOAD_USER=''

ENV PHP_INI_SOAP_WSDL_CACHE_ENABLED='1'

ENV PHP_INI_MAX_EXECUTION_TIME='30'
ENV PHP_INI_MAX_INPUT_TIME='60'

ENV PHP_INI_SENDMAIL_PATH='sendmail -t -i'

ENV XDEBUG_REMOTE_AUTOSTART='1'
ENV XDEBUG_REMOTE_PORT='9003'
ENV XDEBUG_START_WITH_REQUEST='trigger'
ENV XDEBUG_MODE='off'

RUN set -x \
&& apt-get update && apt-get install -y supervisor \
ca-certificates \
mime-support \
libnss3-tools \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

ENV XDG_CONFIG_HOME="/config"
ENV XDG_DATA_HOME="/data"

ENV SERVER_NAME=":80"
ENV DOCUMENT_ROOT="/var/www/html/"

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions

WORKDIR /var/www/html

EXPOSE 80
EXPOSE 443
EXPOSE 443/udp
EXPOSE 2019

# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

COPY config/php.ini /usr/local/etc/php/conf.d/000-php.ini

RUN echo "expose_php = Off" > /usr/local/etc/php/conf.d/expose_php.ini

# Install extensions
RUN set -x \
install-php-extensions opcache intl gettext zip redis mysqli pgsql pdo_mysql pdo_pgsql gd exif xdebug pcntl

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

COPY config/frankenphp/Caddyfile /etc/caddy/

RUN set -x \
&& apt-get update \
&& apt-get install -y \
wkhtmltopdf \
imagemagick \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

STOPSIGNAL SIGQUIT

CMD ["--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
Loading

0 comments on commit 272d845

Please sign in to comment.