From c98c6da2ab5c0197e24c0c3542a326e953d18611 Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 10:38:38 +0800 Subject: [PATCH] chore: Dockerfile and README Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf --- .dockerignore | 7 +++++++ Dockerfile | 10 ++++++++++ README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 README.md diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..85c5429 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git +.superpowers +.playwright-cli +data +docs +node_modules +*.db diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c1ba532 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:22-alpine +WORKDIR /app +ENV NODE_ENV=production PORT=3000 DB_PATH=/data/leads.db +COPY package.json server.js ./ +COPY public ./public +RUN mkdir -p /data && chown node:node /data +USER node +VOLUME /data +EXPOSE 3000 +CMD ["node", "--disable-warning=ExperimentalWarning", "server.js"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..aebc05c --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# INS Landing Page + +Single landing page for Infinity Networks Security with a lead form. Leads are stored in a SQLite file; there is no admin UI, leads are exported manually. + +- `public/index.html`: the page (content from infinitynetworks.com.my) +- `server.js`: serves the page and `POST /api/leads`, Node 22 built-ins only, no npm dependencies + +## Run locally + +Requires Node 22.13 or newer. + +```bash +npm start # http://localhost:3000, database at ./data/leads.db +npm test +``` + +Environment: `PORT` (default `3000`), `DB_PATH` (default `./data/leads.db`). + +## Docker + +```bash +docker build -t ins-landing-page . +docker run -p 3000:3000 -v ins-leads:/data ins-landing-page +``` + +## Deploying to Kubernetes + +- Mount a PersistentVolumeClaim at `/data`. Without it, leads are lost when the pod restarts. +- Run exactly **1 replica** (SQLite file, single writer). Use `strategy: Recreate` so two pods never hold the volume at once during a rollout. +- The container runs as user `node` (uid 1000); set `securityContext.fsGroup: 1000` so it can write to the volume. +- Health check: `GET /` returns 200. + +## Exporting leads + +To CSV, from the running pod: + +```bash +kubectl exec deploy/ins-landing-page -- node --disable-warning=ExperimentalWarning -e " +const {DatabaseSync}=require('node:sqlite'); +const rows=new DatabaseSync(process.env.DB_PATH,{readOnly:true}).prepare('SELECT * FROM leads ORDER BY id').all(); +const q=v=>v==null?'':'\"'+String(v).replace(/^[=+\-@]/,\"'\$&\").replace(/\"/g,'\"\"')+'\"'; +if(rows.length)console.log(Object.keys(rows[0]).join(',')); +for(const r of rows)console.log(Object.values(r).map(q).join(',')); +" > leads.csv +``` + +Or copy the whole database file: `kubectl cp :/data/leads.db ./leads.db`. + +Columns: `id, created_at (UTC), name, email, phone, company, industry, message, referrer, utm_source, utm_medium, utm_campaign`. + +Leads contain personal data (PDPA). Keep exported files out of shared drives and delete them when done.