alpine.Dockerfile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. coreutils \
  43. curl-dev \
  44. gnu-libiconv-dev \
  45. libsodium-dev \
  46. libxml2-dev \
  47. linux-headers \
  48. oniguruma-dev \
  49. openssl-dev \
  50. readline-dev \
  51. sqlite-dev
  52. WORKDIR /go/src/app
  53. COPY --link go.mod go.sum ./
  54. RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
  55. WORKDIR /go/src/app/caddy
  56. COPY caddy/go.mod caddy/go.sum ./
  57. RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
  58. WORKDIR /go/src/app
  59. COPY --link *.* ./
  60. COPY --link caddy caddy
  61. COPY --link C-Thread-Pool C-Thread-Pool
  62. COPY --link internal internal
  63. COPY --link testdata testdata
  64. # todo: automate this?
  65. # see https://github.com/docker-library/php/blob/master/8.2/bookworm/zts/Dockerfile#L57-L59 for php values
  66. ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS" CGO_CPPFLAGS=$PHP_CPPFLAGS
  67. WORKDIR /go/src/app/caddy/frankenphp
  68. 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'" && \
  69. setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
  70. frankenphp version
  71. WORKDIR /go/src/app
  72. FROM common AS runner
  73. ENV GODEBUG=cgocheck=0
  74. COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
  75. RUN setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
  76. frankenphp version