FROM nginx:stable-alpine # Create a non-root user and group RUN addgroup -S appgroup && adduser -S appuser -G appgroup # Copy your application files (assuming they are already built) COPY build /usr/share/nginx/html # Set permissions for the non-root user RUN chown -R appuser:appgroup /usr/share/nginx/html # Switch to the non-root user USER appuser # Define a health check for monitoring container status HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl --fail http://localhost/ || exit 1 EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]