Dockerfile 3.0 KB

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