diff --git a/.astro/content.db b/.astro/content.db new file mode 100644 index 0000000..e69de29 diff --git a/.astro/integrations/astro_db/db.d.ts b/.astro/integrations/astro_db/db.d.ts new file mode 100644 index 0000000..7caf589 --- /dev/null +++ b/.astro/integrations/astro_db/db.d.ts @@ -0,0 +1,4 @@ +// This file is generated by Astro DB +declare module 'astro:db' { + +} diff --git a/Dockerfile b/Dockerfile index 0307142..eca022a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,24 @@ -FROM node:20-alpine AS build +FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ -RUN npm install +RUN npm ci COPY . . -RUN npm run build +RUN mkdir -p ./data && ASTRO_DB_REMOTE_URL=file:./data/consent.db npx astro build --remote + +FROM node:20-alpine +WORKDIR /app +COPY package*.json ./ +RUN npm install --production +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/data ./data + +RUN apk add --no-cache sqlite-libs -FROM nginx:alpine AS runtime -COPY --from=build /app/dist /usr/share/nginx/html EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] + +ENV NODE_ENV=production +ENV ASTRO_DB_REMOTE_URL=file:/app/data/consent.db +ENV HOST=0.0.0.0 +ENV PORT=80 + +CMD ["node", "dist/server/entry.mjs"] \ No newline at end of file diff --git a/astro.config.mjs b/astro.config.mjs index 57d4397..9a2a38d 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,9 +1,14 @@ +// @ts-check import { defineConfig } from 'astro/config'; import tailwind from '@astrojs/tailwind'; import sitemap from '@astrojs/sitemap'; +import node from '@astrojs/node'; export default defineConfig({ site: 'https://dealplustech.co.th', + adapter: node({ + mode: 'standalone' + }), integrations: [ tailwind({ applyBaseStyles: true, @@ -28,4 +33,4 @@ export default defineConfig({ cssMinify: true, }, }, -}); +}); \ No newline at end of file diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/admin/consent-logs.astro b/src/pages/admin/consent-logs.astro new file mode 100644 index 0000000..f0be6e6 --- /dev/null +++ b/src/pages/admin/consent-logs.astro @@ -0,0 +1,238 @@ +--- +import BaseLayout from '@/layouts/BaseLayout.astro'; + +export const prerender = false; + +const ADMIN_PASSWORD = import.meta.env.ADMIN_PASSWORD || 'Coolm@n1234mo'; +--- + + +
+
+
+

Admin Dashboard - Consent Logs

+

จัดการบันทึกความยินยอมคุกกี้

+
+
+ +
+
+
+

เข้าสู่ระบบ Admin

+
+
+ + +
+ + +
+
+
+ + +
+
+ + +
\ No newline at end of file diff --git a/src/pages/admin/consent-logs/index.astro b/src/pages/admin/consent-logs/index.astro deleted file mode 100644 index bd3859d..0000000 --- a/src/pages/admin/consent-logs/index.astro +++ /dev/null @@ -1,84 +0,0 @@ ---- -import BaseLayout from '@/layouts/BaseLayout.astro'; -import Header from '@/components/common/Header.astro'; -import Footer from '@/components/common/Footer.astro'; - -const adminPassword = import.meta.env.ADMIN_PASSWORD || 'Coolm@n1234mo'; -const password = Astro.url.searchParams.get('password') || ''; -const isAuthorized = password === adminPassword; ---- - - -
- -
-
-
- {isAuthorized ? ( -
-

Consent Logs - Docker Logs

- -
-

วิธีดู Consent Logs

-
    -
  • Consent data ถูก log ไปที่ Docker logs โดยตรง
  • -
  • ดู logs ด้วยคำสั่ง: docker logs <container_name>
  • -
  • หรือใช้: docker logs -f <container_name> | grep Consent
  • -
  • Logs จะมี format: [Consent Log] {{sessionId, essential, analytics, marketing, ...}}
  • -
-
- -
-

ตัวอย่าง Log Entry

-
[Consent Log] {"sessionId":"abc123","essential":true,"analytics":true,"marketing":false,"timestamp":"2024-03-01T12:00:00.000Z","ip":"127.0.0.1"}
-
- -
-

Production Setup แนะนำ

-
    -
  • ตั้งค่า Docker logging driver เป็น json-file และ limit log size
  • -
  • ใช้ log aggregation service เช่น Datadog, CloudWatch, หรือ ELK Stack
  • -
  • หรือเพิ่ม @astrojs/db พร้อม Turso SQLite สำหรับ persistent storage
  • -
-
- - -
- ) : ( -
-
-

เข้าสู่ระบบ Admin

- -
-
- - -
- - -
-
-
- )} -
-
-
- -