diff --git a/Dockerfile b/Dockerfile index 0713a55..7c98dee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,10 @@ FROM nginx:1.27-alpine RUN rm -rf /usr/share/nginx/html/* -# Static files COPY index.html /usr/share/nginx/html/index.html 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 RUN chmod +x /docker-entrypoint.sh diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 4623df3..6f66b3d 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,20 +1,15 @@ #!/bin/sh set -e -TEMPLATE=/usr/share/nginx/html/index.html.template -TARGET=/usr/share/nginx/html/index.html +# If LAB_LINKS is not set, use an empty array +LAB_LINKS_JSON=${LAB_LINKS:-[]} -# שומרים טמפלייט פעם אחת -if [ ! -f "$TEMPLATE" ]; then - cp "$TARGET" "$TEMPLATE" -fi +# Escape / and & for sed +ESCAPED_JSON=$(printf '%s' "$LAB_LINKS_JSON" | sed -e 's/[\/&]/\\&/g') -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 -if [ -n "$LAB_LINKS" ]; then - # משתמש ב-| כדי לא להסתבך עם / ב-URL - sed -i "s|__LAB_LINKS__|$LAB_LINKS|g" "$TARGET" -fi - -nginx -g 'daemon off;' +# Run nginx +exec nginx -g 'daemon off;'