This commit is contained in:
2026-05-28 16:24:47 +07:00
parent 1359817b4b
commit 7dde30748c
7 changed files with 138 additions and 2 deletions

7
.dockerignore Normal file
View File

@@ -0,0 +1,7 @@
*
!nginx.conf
!docker-build-site.mjs
!www.mewedding.vn/
!www.mewedding.vn/**
!w.ladicdn.com/
!w.ladicdn.com/**

9
.env Normal file
View File

@@ -0,0 +1,9 @@
COMPOSE_PROJECT_NAME=wd-hn
IMAGE_NAME=toiiiiday/wd-hn-wedding
IMAGE_TAG=1.0.0
CONTAINER_NAME=wd-hn-wedding
HOST_PORT=6070
PUBLIC_DOMAIN=hiepnhan.weddinghappy.asia
SERVER_IP=172.20.235.176

17
Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
FROM node:alpine AS site
WORKDIR /src
COPY docker-build-site.mjs .
COPY www.mewedding.vn ./www.mewedding.vn
COPY w.ladicdn.com ./w.ladicdn.com
RUN node docker-build-site.mjs
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=site /site/ /usr/share/nginx/html/
EXPOSE 6070
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://127.0.0.1:6070/ >/dev/null || exit 1

56
docker-build-site.mjs Normal file
View File

@@ -0,0 +1,56 @@
import fs from "node:fs/promises";
import path from "node:path";
const outDir = "/site";
const indexPath = "www.mewedding.vn/index.html";
const sourceDir = "www.mewedding.vn/source";
function decodeLocalAsset(rawUrl) {
let url = rawUrl.split("?")[0];
url = url.replaceAll("\\ ", " ");
url = url.replace(/^\.\.\//, "");
url = url.replace(/^\/+/, "");
try {
return decodeURIComponent(url);
} catch {
return url;
}
}
async function copyFilePreservingPath(relativePath) {
const source = path.resolve(relativePath);
const target = path.join(outDir, relativePath);
await fs.mkdir(path.dirname(target), { recursive: true });
await fs.copyFile(source, target);
}
const html = await fs.readFile(indexPath, "utf8");
await fs.rm(outDir, { recursive: true, force: true });
await copyFilePreservingPath(indexPath);
await fs.cp(sourceDir, path.join(outDir, sourceDir), { recursive: true });
const assetPattern =
/(?:url\(["']?|src=["']|href=["']|"(?:dC|dw)"\s*:\s*")((?:\.\.\/|\/)w\.ladicdn\.com\/[^"')]+)/g;
const assets = new Set();
for (const match of html.matchAll(assetPattern)) {
assets.add(decodeLocalAsset(match[1]));
}
const missing = [];
for (const asset of assets) {
try {
await fs.access(asset);
await copyFilePreservingPath(asset);
} catch {
missing.push(asset);
}
}
if (missing.length > 0) {
console.error("Missing local assets:");
for (const asset of missing) console.error(`- ${asset}`);
process.exit(1);
}
console.log(`Prepared static site with ${assets.size} local assets.`);

8
docker-compose.yml Normal file
View File

@@ -0,0 +1,8 @@
services:
wedding-web:
build: .
image: ${IMAGE_NAME}:${IMAGE_TAG}
container_name: ${CONTAINER_NAME}
restart: unless-stopped
ports:
- "${HOST_PORT}:6070"

38
nginx.conf Normal file
View File

@@ -0,0 +1,38 @@
server {
listen 6070;
server_name _;
root /usr/share/nginx/html;
index index.html;
charset utf-8;
add_header X-Content-Type-Options "nosniff" always;
location = / {
try_files /www.mewedding.vn/index.html =404;
}
location = /index.html {
try_files /www.mewedding.vn/index.html =404;
}
location /w.ladicdn.com/ {
try_files $uri =404;
expires 30d;
add_header Cache-Control "public, max-age=2592000, immutable";
}
location /www.mewedding.vn/source/ {
try_files $uri =404;
expires 30d;
add_header Cache-Control "public, max-age=2592000, immutable";
}
location /www.mewedding.vn/ {
try_files $uri $uri/ /www.mewedding.vn/index.html;
}
location / {
try_files $uri $uri/ /www.mewedding.vn/index.html;
}
}

View File

@@ -5,6 +5,7 @@
<meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
<base href="/">
<meta charset="UTF-8">
<title>THƯ MỜI THAM DỰ ĐÁM CƯỚI MINH HIỆP VÀ THANH NHÀN</title>
<meta http-equiv="Cache-Control" content="no-cache">
@@ -15,7 +16,7 @@
<meta property="og:title" content="Thiệp mời Hiệp & Nhàn" />
<meta property="og:description"
content="Trân trọng kính mời bạn đến dự lễ cưới của Hiệp & Nhàn — lúc 17:00 ngày 06/06/2026. Nhấn để xem chi tiết!" />
<meta property="og:url" content="https://minhhiep.weddinghappy.asia/" />
<meta property="og:url" content="https://hiepnhan.weddinghappy.asia/" />
<link rel="dns-prefetch">
<link rel="preconnect" href="https://fonts.googleapis.com/" crossorigin>
<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
@@ -10865,4 +10866,4 @@
</body>
</html><!--Publish time: Fri, 18 Jul 2025 10:12:40 GMT--><!--LadiPage build time: Thu, 17 Jul 2025 10:00:19 GMT-->
</html><!--Publish time: Fri, 18 Jul 2025 10:12:40 GMT--><!--LadiPage build time: Thu, 17 Jul 2025 10:00:19 GMT-->