diff options
| -rw-r--r-- | Dockerfile | 10 | ||||
| -rw-r--r-- | docker-entrypoint.sh | 21 |
2 files changed, 30 insertions, 1 deletions
@@ -1,10 +1,18 @@ -FROM nginx:alpine as adelie +FROM nginx:alpine +# Copy static assets COPY static/ /usr/share/nginx/html/ +# Copy nginx configuration COPY nginx.conf /etc/nginx/nginx.conf +# Copy entrypoint script +COPY docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh + EXPOSE 80 HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget --quiet --tries=1 --spider http://localhost/ || exit 1 + +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..55e2b6c --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +# If HOST is set, replace /static/ URLs in CSS and JS files +if [ ! -z "$HOST" ]; then + # Escape special characters for sed + ESCAPED_HOST=$(echo "$HOST" | sed 's/[\/&]/\\&/g') + + # Replace /static/ paths in all CSS files + find /usr/share/nginx/html -name "*.css" -type f -exec sed -i "s|/static/|${ESCAPED_HOST}/static/|g" {} \; + + # Replace /static/ paths in all JS files + find /usr/share/nginx/html -name "*.js" -type f -exec sed -i "s|/static/|${ESCAPED_HOST}/static/|g" {} \; + + echo "✓ Updated static URLs to use HOST: $HOST" +else + echo "✓ Serving static assets from /static/ (local, no HOST set)" +fi + +# Start nginx in foreground +exec nginx -g "daemon off;" |
