static-builder.Dockerfile 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. COPY 0001-fix-musl-crash.patch .
  70. RUN git checkout "$(go env GOVERSION)" && \
  71. git apply 0001-fix-musl-crash.patch
  72. WORKDIR /goroot/src
  73. ENV GOHOSTARCH="$TARGETARCH"
  74. RUN ./make.bash
  75. ENV PATH="/goroot/bin:$PATH"
  76. RUN go version
  77. # https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
  78. ENV COMPOSER_ALLOW_SUPERUSER=1
  79. COPY --from=composer/composer:2-bin /composer /usr/bin/composer
  80. WORKDIR /go/src/app
  81. COPY go.mod go.sum ./
  82. RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
  83. WORKDIR /go/src/app/caddy
  84. COPY caddy/go.mod caddy/go.sum ./
  85. RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
  86. WORKDIR /go/src/app
  87. COPY *.* ./
  88. COPY caddy caddy
  89. RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \
  90. rm -Rf dist/static-php-cli/source/*