-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
91 lines (68 loc) · 2.89 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
ARG UNIT_VERSION=1.29.0
ARG PHP_VERSION=8.2
ARG PHP_ALPINE_VERSION=3.19
################################################
# NGINX UNIT DOWNLOADER - Stage #1 #
################################################
FROM alpine:3.20 AS nginx-unit-downloader
ARG UNIT_VERSION
WORKDIR "/tmp/unit"
ADD ["https://codeload.github.com/nginx/unit/tar.gz/refs/tags/${UNIT_VERSION}", "/tmp/unit.tar.gz"]
RUN tar zxvf /tmp/unit.tar.gz --strip=1 -C "/tmp/unit"
################################################
# NGINX UNIT BUILDER - Stage #2 #
################################################
ARG PHP_VERSION
ARG PHP_ALPINE_VERSION
FROM php:${PHP_VERSION}-zts-alpine${PHP_ALPINE_VERSION} AS nginx-unit-builder
RUN set -eux \
&& apk add --update --no-cache alpine-sdk curl openssl-dev pcre-dev
COPY --from=nginx-unit-downloader ["/tmp/unit", "/build/unit/"]
ENV DESTDIR /opt/unit/
WORKDIR "/build/unit/"
ARG PHP_VERSION
RUN set -eux \
&& ./configure --log=/var/log/unitd.log \
&& ./configure php --module="php${PHP_VERSION//./}" \
&& make -j "$(nproc)" \
&& make -j "$(nproc)" install \
&& make clean
################################################
# Root FS builder / docker overlay - Stage #3 #
################################################
FROM alpine:3.20 AS rootfs
COPY --from=nginx-unit-builder ["/opt/unit/", "/opt/unit/"]
COPY --from=ghcr.io/n0rthernl1ghts/s6-rootfs:3.1.6.2 ["/", "/rootfs-build"]
# Rootfs
COPY ["./rootfs", "/rootfs-build"]
# Prepare unit
COPY --chmod=0775 ["./src/setup-unit.sh", "/tmp/setup-unit.sh"]
RUN set -eux \
&& apk add --update --no-cache bash rsync \
&& /tmp/setup-unit.sh
# Download init-docker-secrets service script from gist
ADD --chmod=0777 ["https://gist.githubusercontent.com/xZero707/bd8dd4795b8266d9639ed0cdd9d81f82/raw/13d3134880a2ce16c00b9b33450c05c34d0e0619/run.sh", "/rootfs-build/etc/s6-overlay/s6-rc.d/init-docker-secrets/run"]
################################################
# Final stage #
################################################
ARG PHP_VERSION
ARG PHP_ALPINE_VERSION
FROM php:${PHP_VERSION}-zts-alpine${PHP_ALPINE_VERSION}
RUN set -eux \
&& apk add --update --no-cache bash pcre-dev socat
COPY --from=rootfs ["/rootfs-build/", "/"]
ARG UNIT_VERSION
ENV UNIT_VERSION=${UNIT_VERSION}
ENV UNIT_SOCKET="/run/control.unit.sock"
ENV UNIT_CONFIGURATION_FILE="/etc/unit/config.json"
ENV S6_KEEP_ENV=1
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2
ENV S6_SERVICES_GRACETIME=6000
ENV S6_VERBOSITY=5
ENV S6_CMD_RECEIVE_SIGNALS=1
LABEL maintainer="Aleksandar Puharic <[email protected]>" \
org.opencontainers.image.source="https://github.com/N0rthernL1ghts/unit-php" \
org.opencontainers.image.description="NGINX Unit ${UNIT_VERSION} - Alpine Build ${TARGETPLATFORM}" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.version="${UNIT_VERSION}"
ENTRYPOINT ["/init"]