File size: 2,694 Bytes
55896b1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | # ============================================
# Premium Valentine Website - Docker Image
# Production-Grade Multi-Stage Build
# ============================================
# Stage 1: Build Stage (Optional - for future minification)
FROM node:18-alpine AS builder
WORKDIR /app
# Copy source files
COPY index.html .
COPY style.css .
COPY script.js .
COPY README.md .
# Install minification tools (optional)
# RUN npm install -g cssnano-cli terser html-minifier
# Minify assets (uncomment when ready for production)
# RUN cssnano style.css style.min.css
# RUN terser script.js -o script.min.js -c -m
# RUN html-minifier --collapse-whitespace --remove-comments index.html -o index.min.html
# Stage 2: Production Stage
FROM nginx:1.25-alpine
# Install security updates
RUN apk update && \
apk upgrade && \
apk add --no-cache \
ca-certificates \
tzdata && \
rm -rf /var/cache/apk/*
# Set timezone
ENV TZ=UTC
# Remove default nginx config and website
RUN rm -rf /etc/nginx/conf.d/default.conf && \
rm -rf /usr/share/nginx/html/*
# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
COPY nginx-site.conf /etc/nginx/conf.d/default.conf
# Copy application files from builder stage
COPY --from=builder /app/index.html /usr/share/nginx/html/
COPY --from=builder /app/style.css /usr/share/nginx/html/
COPY --from=builder /app/script.js /usr/share/nginx/html/
COPY --from=builder /app/README.md /usr/share/nginx/html/
# Create non-root user for security
RUN addgroup -g 1001 -S nginx-app && \
adduser -S -D -H -u 1001 -h /usr/share/nginx/html -s /sbin/nologin -G nginx-app -g nginx-app nginx-app
# Set proper permissions
RUN chown -R nginx-app:nginx-app /usr/share/nginx/html && \
chown -R nginx-app:nginx-app /var/cache/nginx && \
chown -R nginx-app:nginx-app /var/log/nginx && \
chown -R nginx-app:nginx-app /etc/nginx/conf.d && \
touch /var/run/nginx.pid && \
chown -R nginx-app:nginx-app /var/run/nginx.pid
# Switch to non-root user
USER nginx-app
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:8080/ || exit 1
# Labels for metadata
LABEL maintainer="Valentine Experience Team" \
version="3.0.0" \
description="Premium Valentine's Day Interactive Experience" \
org.opencontainers.image.title="Valentine Experience" \
org.opencontainers.image.description="Corporate-grade Valentine's Day web application" \
org.opencontainers.image.version="3.0.0" \
org.opencontainers.image.vendor="Valentine Experience Team"
# Start nginx
CMD ["nginx", "-g", "daemon off;"]
|