alpine.Dockerfile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # syntax=docker/dockerfile:1
  2. FROM php-base AS common
  3. WORKDIR /app
  4. RUN apk add --no-cache \
  5. ca-certificates \
  6. libcap \
  7. mailcap
  8. RUN set -eux; \
  9. mkdir -p \
  10. /app/public \
  11. /config/caddy \
  12. /data/caddy \
  13. /etc/caddy; \
  14. sed -i 's/php/frankenphp run/g' /usr/local/bin/docker-php-entrypoint; \
  15. echo '<?php phpinfo();' > /app/public/index.php
  16. COPY --link caddy/frankenphp/Caddyfile /etc/caddy/Caddyfile
  17. COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
  18. CMD ["--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
  19. HEALTHCHECK CMD curl -f http://localhost:2019/metrics || exit 1
  20. # See https://caddyserver.com/docs/conventions#file-locations for details
  21. ENV XDG_CONFIG_HOME /config
  22. ENV XDG_DATA_HOME /data
  23. EXPOSE 80
  24. EXPOSE 443
  25. EXPOSE 443/udp
  26. EXPOSE 2019
  27. LABEL org.opencontainers.image.title=FrankenPHP
  28. LABEL org.opencontainers.image.description="The modern PHP app server"
  29. LABEL org.opencontainers.image.url=https://frankenphp.dev
  30. LABEL org.opencontainers.image.source=https://github.com/dunglas/frankenphp
  31. LABEL org.opencontainers.image.licenses=MIT
  32. LABEL org.opencontainers.image.vendor="Kévin Dunglas"
  33. FROM common AS builder
  34. ARG FRANKENPHP_VERSION='dev'
  35. SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
  36. COPY --link --from=golang-base /usr/local/go /usr/local/go
  37. ENV PATH /usr/local/go/bin:$PATH
  38. # hadolint ignore=SC2086
  39. RUN apk add --no-cache --virtual .build-deps \
  40. $PHPIZE_DEPS \
  41. argon2-dev \
  42. brotli-dev \
  43. coreutils \
  44. curl-dev \
  45. gnu-libiconv-dev \
  46. libsodium-dev \
  47. libxml2-dev \
  48. linux-headers \
  49. oniguruma-dev \
  50. openssl-dev \
  51. readline-dev \
  52. sqlite-dev
  53. WORKDIR /go/src/app
  54. COPY --link go.mod go.sum ./
  55. RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
  56. WORKDIR /go/src/app/caddy
  57. COPY caddy/go.mod caddy/go.sum ./
  58. RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
  59. WORKDIR /go/src/app
  60. COPY --link *.* ./
  61. COPY --link caddy caddy
  62. COPY --link C-Thread-Pool C-Thread-Pool
  63. COPY --link internal internal
  64. COPY --link testdata testdata
  65. # todo: automate this?
  66. # see https://github.com/docker-library/php/blob/master/8.2/bookworm/zts/Dockerfile#L57-L59 for php values
  67. ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS" CGO_CPPFLAGS=$PHP_CPPFLAGS
  68. WORKDIR /go/src/app/caddy/frankenphp
  69. RUN GOBIN=/usr/local/bin go install -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" && \
  70. setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
  71. frankenphp version
  72. WORKDIR /go/src/app
  73. FROM common AS runner
  74. ENV GODEBUG=cgocheck=0
  75. COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
  76. RUN setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
  77. frankenphp version