FROM nginx:alpine

# Remove default nginx site config and static assets
RUN rm -rf /usr/share/nginx/html/* /etc/nginx/conf.d/default.conf

# Copy the site (all apps + landing page) into nginx's web root
COPY . /usr/share/nginx/html/

# Netlify's _headers file isn't used by nginx — remove it from the served
# output and rely on nginx.conf below for the equivalent headers instead
RUN rm -f /usr/share/nginx/html/_headers /usr/share/nginx/html/dev-server.command

# Custom nginx config: correct MIME type for .wasm, CSP for the
# test-pattern-generator app (needed for its self-hosted FFmpeg.wasm encoder)
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

HEALTHCHECK --interval=30s --timeout=3s \
  CMD wget --quiet --tries=1 --spider http://localhost/ || exit 1

CMD ["nginx", "-g", "daemon off;"]
