static-builder.Dockerfile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 golang-base
  6. ARG TARGETARCH
  7. ARG FRANKENPHP_VERSION=''
  8. ENV FRANKENPHP_VERSION=${FRANKENPHP_VERSION}
  9. ARG PHP_VERSION=''
  10. ENV PHP_VERSION=${PHP_VERSION}
  11. ARG PHP_EXTENSIONS=''
  12. ARG PHP_EXTENSION_LIBS=''
  13. ARG XCADDY_ARGS=''
  14. ARG CLEAN=''
  15. ARG EMBED=''
  16. ARG DEBUG_SYMBOLS=''
  17. ARG MIMALLOC=''
  18. ARG NO_COMPRESS=''
  19. SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
  20. LABEL org.opencontainers.image.title=FrankenPHP
  21. LABEL org.opencontainers.image.description="The modern PHP app server"
  22. LABEL org.opencontainers.image.url=https://frankenphp.dev
  23. LABEL org.opencontainers.image.source=https://github.com/dunglas/frankenphp
  24. LABEL org.opencontainers.image.licenses=MIT
  25. LABEL org.opencontainers.image.vendor="Kévin Dunglas"
  26. RUN apk update; \
  27. apk add --no-cache \
  28. alpine-sdk \
  29. autoconf \
  30. automake \
  31. bash \
  32. binutils \
  33. bison \
  34. build-base \
  35. cmake \
  36. curl \
  37. file \
  38. flex \
  39. g++ \
  40. gcc \
  41. git \
  42. jq \
  43. libgcc \
  44. libstdc++ \
  45. libtool \
  46. linux-headers \
  47. m4 \
  48. make \
  49. pkgconfig \
  50. php83 \
  51. php83-common \
  52. php83-ctype \
  53. php83-curl \
  54. php83-dom \
  55. php83-mbstring \
  56. php83-openssl \
  57. php83-pcntl \
  58. php83-phar \
  59. php83-posix \
  60. php83-session \
  61. php83-sodium \
  62. php83-tokenizer \
  63. php83-xml \
  64. php83-xmlwriter \
  65. upx \
  66. wget \
  67. xz ; \
  68. ln -sf /usr/bin/php83 /usr/bin/php
  69. # FIXME: temporary workaround for https://github.com/golang/go/issues/68285
  70. WORKDIR /
  71. RUN git clone https://go.googlesource.com/go goroot
  72. WORKDIR /goroot
  73. # Revert https://github.com/golang/go/commit/3560cf0afb3c29300a6c88ccd98256949ca7a6f6 to prevent the crash with musl
  74. RUN git config --global user.email "build@example.com" && \
  75. git config --global user.name "Build" && \
  76. git checkout "$(go env GOVERSION)" && \
  77. git revert 3560cf0afb3c29300a6c88ccd98256949ca7a6f6
  78. WORKDIR /goroot/src
  79. ENV GOHOSTARCH="$TARGETARCH"
  80. RUN ./make.bash
  81. ENV PATH="/goroot/bin:$PATH"
  82. RUN go version && \
  83. go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
  84. # https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
  85. ENV COMPOSER_ALLOW_SUPERUSER=1
  86. COPY --from=composer/composer:2-bin /composer /usr/bin/composer
  87. WORKDIR /go/src/app
  88. COPY go.mod go.sum ./
  89. RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
  90. WORKDIR /go/src/app/caddy
  91. COPY caddy/go.mod caddy/go.sum ./
  92. RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
  93. WORKDIR /go/src/app
  94. COPY --link *.* ./
  95. COPY --link caddy caddy
  96. COPY --link internal internal
  97. RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \
  98. rm -Rf dist/static-php-cli/source/*