Implement moreminimore-style consent backend with better-sqlite3
- Add @astrojs/node adapter for hybrid SSR mode - Replace console logging with better-sqlite3 database storage - Create data/ directory for consent.db persistence - Full consent API: POST (log), GET (fetch), DELETE (remove) - Admin dashboard at /admin/consent-logs.astro with: - Password auth via sessionStorage - Stats cards (total, analytics accepted, rejected, rate %) - 100 latest logs table - Export to CSV functionality - Delete individual records - New Dockerfile: node:20-alpine + sqlite-libs runtime - Admin password: Coolm@n1234mo Note: Static pages remain prerendered, only API/admin routes are SSR.
This commit is contained in:
25
Dockerfile
25
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"]
|
||||
Reference in New Issue
Block a user