File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Required
2+ BASIC_AUTH_USER =
3+ BASIC_AUTH_PASS =
Original file line number Diff line number Diff line change @@ -9,7 +9,14 @@ RUN npm ci
99COPY . .
1010RUN npm run build
1111
12- # ---- Production image: serves the prebuilt static site via nginx ----
12+ # ---- Production image: serves the prebuilt static site via nginx, behind basic auth ----
1313FROM nginxinc/nginx-unprivileged:1.27-alpine AS prod
14+ USER root
15+ RUN apk add --no-cache apache2-utils
1416COPY --from=build /app/build /usr/share/nginx/html
17+ COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
18+ COPY docker/start.sh /usr/local/bin/start.sh
19+ RUN chmod +x /usr/local/bin/start.sh
20+ USER nginx
1521EXPOSE 8080
22+ CMD ["/usr/local/bin/start.sh" ]
Original file line number Diff line number Diff line change @@ -2,5 +2,8 @@ services:
22 docs-prod :
33 build :
44 context : .
5+ environment :
6+ BASIC_AUTH_USER : ${BASIC_AUTH_USER:?BASIC_AUTH_USER is required}
7+ BASIC_AUTH_PASS : ${BASIC_AUTH_PASS:?BASIC_AUTH_PASS is required}
58 ports :
69 - ' 3000:8080'
Original file line number Diff line number Diff line change 1+ server {
2+ listen 8080 ;
3+ server_name _;
4+
5+ root /usr/share/nginx/html;
6+ index index .html;
7+
8+ auth_basic "Docs Preview" ;
9+ auth_basic_user_file /tmp/.htpasswd;
10+
11+ location = /health {
12+ auth_basic off;
13+ access_log off;
14+ default_type text/plain;
15+ return 200 "ok" ;
16+ }
17+
18+ location / {
19+ try_files $uri $uri / $uri .html =404 ;
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -eu
3+
4+ # Source vault-injected secrets if present (K8s openbao/vault agent)
5+ [ -f /vault/secrets/auth ] && . /vault/secrets/auth
6+
7+ : " ${BASIC_AUTH_USER:? BASIC_AUTH_USER env var is required} "
8+ : " ${BASIC_AUTH_PASS:? BASIC_AUTH_PASS env var is required} "
9+
10+ htpasswd -bc /tmp/.htpasswd " $BASIC_AUTH_USER " " $BASIC_AUTH_PASS "
11+
12+ exec nginx -g ' daemon off;'
You can’t perform that action at this time.
0 commit comments