static-builder.Dockerfile 2.5 KB

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