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/*
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
@ -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;'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user