Fix Dockerfile
This commit is contained in:
parent
7157516d94
commit
a3655fac5d
@ -2,12 +2,10 @@ FROM nginx:1.27-alpine
|
|||||||
|
|
||||||
RUN rm -rf /usr/share/nginx/html/*
|
RUN rm -rf /usr/share/nginx/html/*
|
||||||
|
|
||||||
# Static files
|
|
||||||
COPY index.html /usr/share/nginx/html/index.html
|
COPY index.html /usr/share/nginx/html/index.html
|
||||||
COPY favicon.svg /usr/share/nginx/html/favicon.svg
|
COPY favicon.svg /usr/share/nginx/html/favicon.svg
|
||||||
COPY dvirlabs-logo.png /usr/share/nginx/html/dvirlabs-logo.png
|
COPY dvirlabs-logo-2.png /usr/share/nginx/html/dvirlabs-logo-2.png
|
||||||
|
|
||||||
# Entrypoint that injects LAB_LINKS into __LAB_LINKS__
|
|
||||||
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
RUN chmod +x /docker-entrypoint.sh
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
|
|
||||||
|
|||||||
@ -1,20 +1,15 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
TEMPLATE=/usr/share/nginx/html/index.html.template
|
# If LAB_LINKS is not set, use an empty array
|
||||||
TARGET=/usr/share/nginx/html/index.html
|
LAB_LINKS_JSON=${LAB_LINKS:-[]}
|
||||||
|
|
||||||
# שומרים טמפלייט פעם אחת
|
# Escape / and & for sed
|
||||||
if [ ! -f "$TEMPLATE" ]; then
|
ESCAPED_JSON=$(printf '%s' "$LAB_LINKS_JSON" | sed -e 's/[\/&]/\\&/g')
|
||||||
cp "$TARGET" "$TEMPLATE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp "$TEMPLATE" "$TARGET"
|
# Replace placeholder in index.html
|
||||||
|
sed "s/__LAB_LINKS__/$ESCAPED_JSON/" /usr/share/nginx/html/index.html > /tmp/index.html
|
||||||
|
mv /tmp/index.html /usr/share/nginx/html/index.html
|
||||||
|
|
||||||
# מחליף את placeholder של הלינקים ב-JSON מה-ENV
|
# Run nginx
|
||||||
if [ -n "$LAB_LINKS" ]; then
|
exec nginx -g 'daemon off;'
|
||||||
# משתמש ב-| כדי לא להסתבך עם / ב-URL
|
|
||||||
sed -i "s|__LAB_LINKS__|$LAB_LINKS|g" "$TARGET"
|
|
||||||
fi
|
|
||||||
|
|
||||||
nginx -g 'daemon off;'
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user