-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
82 lines (65 loc) · 3.23 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
FROM --platform=$TARGETPLATFORM yiniot/openresty-base:latest
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ARG S6_OVERLAY_VERSION=3.1.6.2
EXPOSE 80 443
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && apt install -y --no-install-recommends wget xz-utils logrotate && rm -rf /var/lib/apt/lists/*
# s6-overlay
RUN case "${TARGETARCH}/${TARGETVARIANT}" in \
"amd64/"*) S6_ARCH="x86_64" ;; \
"arm64/"*) S6_ARCH="aarch64" ;; \
*) echo "Unsupported arch: ${TARGETARCH}/${TARGETVARIANT}" && exit 1 ;; \
esac && \
wget -O /tmp/s6-overlay-noarch.tar.xz https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz && \
tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz && \
wget -O /tmp/s6-overlay-${S6_ARCH}.tar.xz https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz && \
tar -C / -Jxpf /tmp/s6-overlay-${S6_ARCH}.tar.xz && \
wget -O /tmp/s6-overlay-noarch.tar.xz https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz && \
tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
COPY docker-entrypoint.sh /docker-entrypoint.sh
COPY init /init
# register nginx service
COPY nginx /etc/s6-overlay/s6-rc.d/nginx/run
RUN echo 'longrun' > /etc/s6-overlay/s6-rc.d/nginx/type && touch /etc/s6-overlay/s6-rc.d/user/contents.d/nginx
RUN mkdir -p /usr/local/etc \
&& mkdir -p /etc/nginx/sites-available \
&& mkdir -p /etc/nginx/sites-enabled \
&& mkdir -p /etc/nginx/streams-available \
&& mkdir -p /etc/nginx/streams-enabled \
&& mkdir -p /etc/nginx-ui/ \
&& mkdir -p /var/log/nginx/ \
&& cp -r /etc/nginx /usr/local/etc/nginx
# init config
COPY init-config.up /etc/s6-overlay/s6-rc.d/init-config/up
COPY init-config.sh /etc/s6-overlay/s6-rc.d/init-config/init-config.sh
RUN chmod +x /etc/s6-overlay/s6-rc.d/init-config/init-config.sh && \
echo 'oneshot' > /etc/s6-overlay/s6-rc.d/init-config/type && \
touch /etc/s6-overlay/s6-rc.d/user/contents.d/init-config && \
mkdir -p /etc/s6-overlay/s6-rc.d/nginx/dependencies.d && \
touch /etc/s6-overlay/s6-rc.d/nginx/dependencies.d/init-config
ENTRYPOINT ["/init"]
#### nginx-ui dockerfile ####
ENV NGINX_UI_OFFICIAL_DOCKER=true
ENV NGINX_UI_SERVER_RUN_MODE=release
# register nginx-ui service
COPY resources/docker/nginx-ui.run /etc/s6-overlay/s6-rc.d/nginx-ui/run
RUN echo 'longrun' > /etc/s6-overlay/s6-rc.d/nginx-ui/type && \
touch /etc/s6-overlay/s6-rc.d/user/contents.d/nginx-ui
# copy nginx config
COPY resources/docker/nginx.conf /usr/local/etc/nginx/nginx.conf
COPY resources/docker/nginx-ui.conf /usr/local/etc/nginx/conf.d/nginx-ui.conf
# copy nginx-ui executable binary
COPY nginx-ui-$TARGETOS-$TARGETARCH$TARGETVARIANT/nginx-ui /usr/local/bin/nginx-ui
# remove default nginx config
RUN rm -f /etc/nginx/conf.d/default.conf \
&& rm -f /usr/local/etc/nginx/conf.d/default.conf
# recreate access.log and error.log
RUN rm -f /var/log/nginx/access.log && \
touch /var/log/nginx/access.log && \
rm -f /var/log/nginx/error.log && \
touch /var/log/nginx/error.log && \
chmod 755 /usr/local/bin/nginx-ui && \
chmod 755 /init && \
chmod 755 /docker-entrypoint.sh