Dockerfile 3.0 KB

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