forked from xsc/nginx-sidecar-basic-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
43 lines (39 loc) · 1.34 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
FROM nginx:alpine
# --------------------
# METADATA
# --------------------
EXPOSE 8087
ENV NGINX_VERSION=1.21.6 \
DOCKERIZE_VERSION=v0.6.1 \
PORT=8087 \
FORWARD_HOST=localhost \
FORWARD_PORT=8080 \
BASIC_AUTH_USERNAME=admin \
BASIC_AUTH_PASSWORD=admin \
PROXY_READ_TIMEOUT=60s \
PROXY_SEND_TIMEOUT=60s \
CLIENT_MAX_BODY_SIZE=1m \
PROXY_REQUEST_BUFFERING=on \
PROXY_BUFFERING=on \
ALLOW_ACME_HTTP_CHALLENGES=true
# --------------------
# DEPENDENCIES
# --------------------
RUN wget -O dockerize.tar.gz https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize.tar.gz \
&& apk add --update --no-cache --virtual entrypoint apache2-utils \
&& rm dockerize.tar.gz /etc/nginx/conf.d/default.conf /etc/nginx/nginx.conf \
&& mkdir /templates \
&& chmod g+rw /etc/nginx /etc/nginx/conf.d /templates
# --------------------
# TEMPLATES
# --------------------
COPY default.conf.tpl nginx.conf.tpl /templates/
# --------------------
# FILL TEMPLATES & GO
# --------------------
CMD htpasswd -Bbn "$BASIC_AUTH_USERNAME" "$BASIC_AUTH_PASSWORD" > /etc/nginx/auth.htpasswd && \
dockerize \
-template /templates/default.conf.tpl:/etc/nginx/conf.d/default.conf \
-template /templates/nginx.conf.tpl:/etc/nginx/nginx.conf \
nginx