# Static mirror of www.mitsuthailand.com (บริษัท มิตซูชัยพร จำกัด ศูนย์มิตซูบิชิ สมุทรสาคร)
# Serves the mirrored static site with nginx. All URLs are relative (domain-agnostic).
# Env vars (GA_ID, FORM_EMAIL, GMAP_LAT/LNG) are injected into HTML at startup.
# Host on EasyPanel: create a Dockerfile service, port 80.

FROM nginx:1.27-alpine

# Remove default site content
RUN rm -rf /usr/share/nginx/html/*

# Copy the mirrored static site
COPY site/ /usr/share/nginx/html/

# Custom nginx config: clean URLs via directory/index.html + caching
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Entrypoint injects env vars (GA, form email, google map) into HTML before serving.
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Ship example env as defaults (real secrets should be provided via EasyPanel env,
# overriding these at runtime — see .env.example for keys).
COPY .env.example /etc/mitsu/.env.example

EXPOSE 80

HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
  CMD wget -q -O /dev/null http://localhost/ || exit 1

# Run the entrypoint (injects env) then nginx in foreground
ENTRYPOINT ["/entrypoint.sh"]
