chore: Dockerfile and README
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
This commit is contained in:
1 parent
d71ba850e8
commit
c98c6da2ab
3 files changed
+68
No files matched your search
@@ -0,0 +1,7 @@
|
||||
.git
|
||||
.superpowers
|
||||
.playwright-cli
|
||||
data
|
||||
docs
|
||||
node_modules
|
||||
*.db
|
||||
+10
@@ -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"]
|
||||
@@ -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 <pod>:/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.
|
||||
Reference in new issue
Block a user