Skip to content

Commit

Permalink
chore(docker): download mlocati/docker-php-extension-installer (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas authored Oct 18, 2024
1 parent aa98b8c commit 5601cc9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ RUN set -eux; \
echo '<?php phpinfo();' > /app/public/index.php

COPY --link caddy/frankenphp/Caddyfile /etc/caddy/Caddyfile
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN curl -sSLf \
-o /usr/local/bin/install-php-extensions \
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
chmod +x /usr/local/bin/install-php-extensions

CMD ["--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
HEALTHCHECK CMD curl -f http://localhost:2019/metrics || exit 1
Expand Down
5 changes: 4 additions & 1 deletion alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ RUN set -eux; \
echo '<?php phpinfo();' > /app/public/index.php

COPY --link caddy/frankenphp/Caddyfile /etc/caddy/Caddyfile
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN curl -sSLf \
-o /usr/local/bin/install-php-extensions \
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
chmod +x /usr/local/bin/install-php-extensions

CMD ["--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
HEALTHCHECK CMD curl -f http://localhost:2019/metrics || exit 1
Expand Down
38 changes: 19 additions & 19 deletions docs/cn/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ FROM dunglas/frankenphp

# 在此处添加其他扩展:
RUN install-php-extensions \
pdo_mysql \
gd \
intl \
zip \
opcache
pdo_mysql \
gd \
intl \
zip \
opcache
```

## 如何安装更多 Caddy 模块
Expand All @@ -52,14 +52,14 @@ COPY --from=caddy:builder /usr/bin/xcaddy /usr/bin/xcaddy
# 必须启用 CGO 才能构建 FrankenPHP
ENV CGO_ENABLED=1 XCADDY_SETCAP=1 XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s'"
RUN xcaddy build \
--output /usr/local/bin/frankenphp \
--with github.com/dunglas/frankenphp=./ \
--with github.com/dunglas/frankenphp/caddy=./caddy/ \
--with github.com/dunglas/caddy-cbrotli \
# Mercure 和 Vulcain 包含在官方版本中,如果不需要你可以删除它们
--with github.com/dunglas/mercure/caddy \
--with github.com/dunglas/vulcain/caddy
# 在此处添加额外的 Caddy 模块
--output /usr/local/bin/frankenphp \
--with github.com/dunglas/frankenphp=./ \
--with github.com/dunglas/frankenphp/caddy=./caddy/ \
--with github.com/dunglas/caddy-cbrotli \
# Mercure 和 Vulcain 包含在官方版本中,如果不需要你可以删除它们
--with github.com/dunglas/mercure/caddy \
--with github.com/dunglas/vulcain/caddy
# 在此处添加额外的 Caddy 模块

FROM dunglas/frankenphp AS runner

Expand Down Expand Up @@ -140,12 +140,12 @@ FROM dunglas/frankenphp
ARG USER=www-data

RUN \
# 在基于 alpine 的发行版使用 "adduser -D ${USER}"
useradd -D ${USER}; \
# 需要开放80和443端口的权限
setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp; \
# 需要 /data/caddy 和 /config/caddy 目录的写入权限
chown -R ${USER}:${USER} /data/caddy && chown -R ${USER}:${USER} /config/caddy;
# 在基于 alpine 的发行版使用 "adduser -D ${USER}"
useradd -D ${USER}; \
# 需要开放80和443端口的权限
setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp; \
# 需要 /data/caddy 和 /config/caddy 目录的写入权限
chown -R ${USER}:${USER} /data/caddy && chown -R ${USER}:${USER} /config/caddy;

USER ${USER}
```
Expand Down
22 changes: 11 additions & 11 deletions docs/fr/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ FROM dunglas/frankenphp

# ajoutez des extensions supplémentaires ici :
RUN install-php-extensions \
pdo_mysql \
gd \
intl \
zip \
opcache
pdo_mysql \
gd \
intl \
zip \
opcache
```

## Comment installer plus de modules Caddy
Expand Down Expand Up @@ -141,12 +141,12 @@ FROM dunglas/frankenphp
ARG USER=www-data
RUN \
# Utilisez "adduser -D ${USER}" pour les distributions basées sur Alpine
useradd -D ${USER}; \
# Ajouter la capacité supplémentaire de se lier aux ports 80 et 443
setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp; \
# Donner l'accès en écriture à /data/caddy et /config/caddy
chown -R ${USER}:${USER} /data/caddy && chown -R ${USER}:${USER} /config/caddy
# Utilisez "adduser -D ${USER}" pour les distributions basées sur Alpine
useradd -D ${USER}; \
# Ajouter la capacité supplémentaire de se lier aux ports 80 et 443
setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp; \
# Donner l'accès en écriture à /data/caddy et /config/caddy
chown -R ${USER}:${USER} /data/caddy && chown -R ${USER}:${USER} /config/caddy
USER ${USER}
```
Expand Down

0 comments on commit 5601cc9

Please sign in to comment.