feat(docker): nginx static-export image + Dokploy compose with env-driven PORT/origin
- Dockerfile: nginx:1.27-alpine serving the exported site, PORT from env, /healthz healthcheck, origin rewrite hook in docker-entrypoint.d - docker/default.conf.template: envsubst PORT, clean URLs without trailing-slash redirect, long cache for hashed assets, no-cache for HTML/sw.js/manifest, 301 http->https via X-Forwarded-Proto, gzip - docker/security-headers.conf: single include so add_header survives per location - docker-compose.yml (Dokploy, no host ports) + docker-compose.override.yml (local) - bake canonical/OG/sitemap/robots origin to https://alterflixhub.hobbypj.com (was the export-time 127.0.0.1:8090), overridable via PUBLIC_ORIGIN - docs/deploy-dokploy.md
This commit is contained in:
1 parent
f6b5ba112b
commit
ae34597847
44 files changed
+416
-136
No files matched your search
+34
@@ -0,0 +1,34 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# AlterFlixHub — static export (ไฟล์ prerender อยู่ที่ราก repo, ไม่มี build step)
|
||||
# runtime = nginx alpine · ฟังพอร์ตจาก env PORT (บน Dokploy ตั้ง PORT=30004)
|
||||
#
|
||||
# env ที่ใช้
|
||||
# PORT พอร์ตที่ nginx ฟังในคอนเทนเนอร์ (default 30004)
|
||||
# PUBLIC_ORIGIN โดเมนจริงที่เขียนลง canonical/OG/JSON-LD/sitemap/robots (default = โดเมน production)
|
||||
# BAKED_ORIGIN origin ที่อบมากับไฟล์ export — ใช้เป็นต้นทางของการแทนที่ตอน start
|
||||
# TZ timezone ของ log
|
||||
|
||||
FROM nginx:1.27-alpine
|
||||
|
||||
ENV PORT=30004 \
|
||||
PUBLIC_ORIGIN=https://alterflixhub.hobbypj.com \
|
||||
BAKED_ORIGIN=https://alterflixhub.hobbypj.com \
|
||||
TZ=Asia/Bangkok
|
||||
|
||||
# nginx config เป็น template → official entrypoint แทนค่า ${PORT} ให้เองตอน start
|
||||
COPY docker/default.conf.template /etc/nginx/templates/default.conf.template
|
||||
# ชุด header ความปลอดภัยที่ทุก location include (nginx ทิ้ง add_header ของ parent เมื่อ location มี add_header เอง)
|
||||
COPY docker/security-headers.conf /etc/nginx/snippets/security-headers.conf
|
||||
# สคริปต์แทน origin ในไฟล์ HTML/XML/TXT ถ้า PUBLIC_ORIGIN ไม่ตรงกับที่อบไว้
|
||||
COPY docker/30-origin.sh /docker-entrypoint.d/30-origin.sh
|
||||
RUN chmod +x /docker-entrypoint.d/30-origin.sh
|
||||
|
||||
# ไฟล์เว็บทั้งหมด (static export) — ไฟล์ของ docker/ ไม่ถูกคัดออกด้วย .dockerignore
|
||||
COPY . /usr/share/nginx/html
|
||||
|
||||
EXPOSE 30004
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=4s --start-period=5s --retries=3 \
|
||||
CMD wget -qO- "http://127.0.0.1:${PORT}/healthz" >/dev/null 2>&1 || exit 1
|
||||
|
||||
# ใช้ entrypoint/cmd เดิมของอิมเมจ (รัน /docker-entrypoint.d/*.sh แล้วค่อย start nginx)
|
||||
Reference in new issue
Block a user