2023-06-28 21:37:02 +00:00
|
|
|
FROM php:8.2-zts-bookworm AS php-base
|
|
|
|
|
|
|
|
FROM golang:1.20-bookworm AS golang-base
|
2023-03-05 14:47:20 +00:00
|
|
|
|
|
|
|
FROM php-base AS builder
|
2022-10-19 05:40:31 +00:00
|
|
|
|
2023-06-28 21:37:02 +00:00
|
|
|
COPY --from=golang-base /usr/local/go/bin/go /usr/local/bin/go
|
|
|
|
COPY --from=golang-base /usr/local/go /usr/local/go
|
2021-09-24 16:52:20 +00:00
|
|
|
|
2023-03-05 14:47:20 +00:00
|
|
|
# This is required to link the FrankenPHP binary to the PHP binary
|
2022-10-31 10:13:17 +00:00
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get -y --no-install-recommends install \
|
|
|
|
libargon2-dev \
|
|
|
|
libcurl4-openssl-dev \
|
|
|
|
libonig-dev \
|
|
|
|
libreadline-dev \
|
|
|
|
libsodium-dev \
|
|
|
|
libsqlite3-dev \
|
|
|
|
libssl-dev \
|
|
|
|
libxml2-dev \
|
|
|
|
zlib1g-dev \
|
|
|
|
&& \
|
|
|
|
apt-get clean
|
|
|
|
|
2021-09-24 16:52:20 +00:00
|
|
|
WORKDIR /go/src/app
|
|
|
|
|
2022-10-13 16:05:22 +00:00
|
|
|
COPY go.mod go.sum ./
|
2022-10-19 22:08:11 +00:00
|
|
|
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
|
2022-10-13 16:05:22 +00:00
|
|
|
|
|
|
|
RUN mkdir caddy && cd caddy
|
2022-10-19 22:08:11 +00:00
|
|
|
COPY caddy/go.mod caddy/go.sum ./caddy/
|
2022-10-13 16:05:22 +00:00
|
|
|
|
2022-10-19 22:08:11 +00:00
|
|
|
RUN cd caddy && go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
|
2022-10-13 16:05:22 +00:00
|
|
|
|
2022-10-20 20:56:20 +00:00
|
|
|
COPY *.* ./
|
2022-10-19 22:08:11 +00:00
|
|
|
COPY caddy caddy
|
|
|
|
COPY C-Thread-Pool C-Thread-Pool
|
|
|
|
COPY internal internal
|
|
|
|
COPY testdata testdata
|
2021-09-24 16:52:20 +00:00
|
|
|
|
2022-10-19 05:40:31 +00:00
|
|
|
# todo: automate this?
|
2023-06-28 21:37:02 +00:00
|
|
|
# see https://github.com/docker-library/php/blob/master/8.2/bookworm/zts/Dockerfile#L57-L59 for PHP values
|
2022-10-19 05:40:31 +00:00
|
|
|
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS=$PHP_CFLAGS CGO_CPPFLAGS=$PHP_CPPFLAGS
|
|
|
|
|
2022-10-13 16:05:22 +00:00
|
|
|
RUN cd caddy/frankenphp && \
|
|
|
|
go build && \
|
|
|
|
cp frankenphp /usr/local/bin && \
|
2022-10-19 05:40:31 +00:00
|
|
|
cp /go/src/app/caddy/frankenphp/Caddyfile /etc/Caddyfile
|
|
|
|
|
2022-10-19 22:08:11 +00:00
|
|
|
ENTRYPOINT ["/bin/bash","-c"]
|
|
|
|
|
2023-06-26 12:34:03 +00:00
|
|
|
FROM php-base AS final
|
2022-10-19 05:40:31 +00:00
|
|
|
|
|
|
|
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
2022-10-13 16:05:22 +00:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
RUN mkdir -p /app/public
|
|
|
|
RUN echo '<?php phpinfo();' > /app/public/index.php
|
|
|
|
|
2022-10-19 05:40:31 +00:00
|
|
|
COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
|
|
|
|
COPY --from=builder /etc/Caddyfile /etc/Caddyfile
|
|
|
|
|
2023-03-05 14:47:20 +00:00
|
|
|
COPY --from=php-base /usr/local/include/php/ /usr/local/include/php
|
|
|
|
COPY --from=php-base /usr/local/lib/libphp.* /usr/local/lib
|
|
|
|
COPY --from=php-base /usr/local/lib/php/ /usr/local/lib/php
|
|
|
|
COPY --from=php-base /usr/local/php/ /usr/local/php
|
|
|
|
COPY --from=php-base /usr/local/bin/ /usr/local/bin
|
|
|
|
COPY --from=php-base /usr/src /usr/src
|
|
|
|
|
2022-10-19 05:40:31 +00:00
|
|
|
RUN sed -i 's/php/frankenphp run/g' /usr/local/bin/docker-php-entrypoint
|
|
|
|
|
|
|
|
CMD [ "--config", "/etc/Caddyfile" ]
|