static-builder.Dockerfile 2.4 KB

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