Files
mitsu-chaiyaporn/Dockerfile
kunthawat 9460be8c0e Rebuild as Astro static site (output identical to original)
- Move all 39 cloned pages + assets into public/ (Astro copies verbatim to dist/)
  -> dist/ is byte-identical to www.mitsuthailand.com (home 143633 bytes exact)
- Add Astro project: astro.config.mjs, package.json, src/layouts/Base.astro,
  src/pages/example.astro (sample Astro component page, builds to /example/)
- Multi-stage Dockerfile: pnpm build -> nginx serve + env-injecting entrypoint
- Env-configurable: GA_ID, FORM_EMAIL, GMAP_LAT/LNG/.env.example
- Remove Python crawl tooling and old nginx-static site/ layout
- Verified: astro build -> 39 pages + example; all routes serve 200 via preview
2026-08-06 14:41:36 +07:00

49 lines
1.4 KiB
Docker

# =============================================================================
# มิตซูชัยพร สมุทรสาคร — Astro static site
# Multi-stage: 1) build with node/pnpm 2) serve dist with nginx.
#
# Env vars (GA_ID, FORM_EMAIL, GMAP_LAT/LNG) are injected into HTML by
# entrypoint.sh at container startup (see .env.example).
# Host on EasyPanel as a Dockerfile service, port 80.
# =============================================================================
# ---------- Stage 1: build Astro ----------
FROM node:22-alpine AS build
WORKDIR /app
# pnpm
RUN npm install -g pnpm@9
# Install deps (uses pnpm-lock.yaml)
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile
# Copy source + content
COPY astro.config.mjs tsconfig.json ./
COPY src/ src/
COPY public/ public/
# Build -> dist/
RUN pnpm build
# ---------- Stage 2: serve with nginx ----------
FROM nginx:1.27-alpine
# Remove default site
RUN rm -rf /usr/share/nginx/html/*
# Copy built site
COPY --from=build /app/dist/ /usr/share/nginx/html/
# nginx config + env-injecting entrypoint
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
CMD wget -q -O /dev/null http://localhost/ || exit 1
ENTRYPOINT ["/entrypoint.sh"]