Dockerfile
AI-generated
Packages the app as one container: an official slim base image with security updates applied, an unprivileged user, and the app listening on 0.0.0.0.
FROM --platform=linux/amd64 public.ecr.aws/nginx/nginx:stable-alpine
# Update OS packages and allow non-root nginx to bind port 80.
RUN apk upgrade --no-cache \
&& apk add --no-cache libcap \
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx
# Keep runtime files in locations writable by the non-root user.
RUN printf '%s\n' \
'worker_processes auto;' \
'pid /tmp/nginx.pid;' \
'error_log /dev/stderr warn;' \
'events { worker_connections 1024; }' \
'http {' \
' include /etc/nginx/mime.types;' \
' default_type application/octet-stream;' \
' access_log /dev/stdout;' \
' client_body_temp_path /tmp/client_temp;' \
' proxy_temp_path /tmp/proxy_temp;' \
' fastcgi_temp_path /tmp/fastcgi_temp;' \
' uwsgi_temp_path /tmp/uwsgi_temp;' \
' scgi_temp_path /tmp/scgi_temp;' \
' server {' \
' listen 0.0.0.0:80;' \
' server_name _;' \
' root /usr/share/nginx/html;' \
' index index.html;' \
' location = /health { default_type application/json; return 200 "{\"status\":\"ok\"}"; }' \
' location / { try_files $uri $uri/ =404; }' \
' }' \
'}' > /etc/nginx/nginx.conf \
&& rm -rf /usr/share/nginx/html/*
COPY . /usr/share/nginx/html/
USER nginx
EXPOSE 80
ENTRYPOINT ["nginx"]
CMD ["-g", "daemon off;"]