chore: update Dockerfile to use Supervisor and improve static file organization

This commit is contained in:
Greg 2025-05-29 16:01:22 +02:00
parent b9d5e29207
commit ff0799603a

View File

@ -38,22 +38,27 @@ RUN htpasswd -cb /etc/nginx/.htpasswd ${AUTH_USERNAME} ${AUTH_PASSWORD} \
&& chown nginx:nginx /etc/nginx/.htpasswd \ && chown nginx:nginx /etc/nginx/.htpasswd \
&& chmod 600 /etc/nginx/.htpasswd && chmod 600 /etc/nginx/.htpasswd
# Copy application files # Copy Supervisor configuration
COPY --from=builder /app/data-api.js \ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
/usr/share/nginx/html/data-api.js \
/usr/share/nginx/html/auth-middleware.js \
/usr/share/nginx/html/backup-s3.js \
/usr/share/nginx/html/package.json \
/usr/share/nginx/html/package-lock.json \
/usr/share/nginx/html/node_modules \
/usr/share/nginx/html/.git \
/usr/share/nginx/html/.github \
/usr/share/nginx/html/.vscode \
/usr/share/nginx/html/README.md
# Expose port 80 for HTTP traffic # Copy static website content (HTML, CSS, JS for the frontend)
COPY index.html /usr/share/nginx/html/
COPY js/ /usr/share/nginx/html/js/
COPY css/ /usr/share/nginx/html/css/
# Add other static asset directories if they exist (e.g., images, fonts, libs)
# COPY images/ /usr/share/nginx/html/images/
# Create app directory for Node.js API and copy from builder stage
WORKDIR /app # Make sure this WORKDIR is set before copying to /app
COPY --from=builder /app .
# Create data directory (volume will be mounted here by docker-compose)
# Ensure Nginx (and Node.js if it needs to write logs/pid here) has permissions
RUN mkdir -p /data && chown nginx:nginx /data # Or appropriate user for Node.js if it writes here
VOLUME /data
# Expose port 80 for Nginx (which handles auth and proxies to API)
EXPOSE 80 EXPOSE 80
# Command to start Nginx in the foreground # Start Supervisor when the container launches
# This ensures the container keeps running CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
CMD ["nginx", "-g", "daemon off;"]