feat(track-1): PVC manifests, Kustomize staging/prod overlays, and standardized container build
Build and Push Docker Images / build (api) (push) Successful in 2m41s Details
Build and Push Docker Images / build (nextgen) (push) Failing after 9s Details
Build and Push Docker Images / build (web) (push) Failing after 12s Details
Build and Push Docker Images / build (musicseerr) (push) Successful in 8m4s Details
Build and Push Docker Images / build (worker) (push) Successful in 14m50s Details
Build and Push Docker Images / deploy (push) Has been skipped Details

This commit is contained in:
fchinembiri 2026-07-28 09:11:10 +02:00
parent 1ba2621f5b
commit 10b105fa01
10 changed files with 166 additions and 63 deletions

View File

@ -1,10 +1,28 @@
node_modules **/node_modules
dist client/dist
.env data/
uploads/
server/uploads/
*.db *.db
*.db-shm *.db-shm
*.db-wal *.db-wal
*.sqlite *.sqlite
.mavis *.log
outputs .git
.DS_Store .gitea
.harness
.claude
.opencode
.worktrees
.env
docs/
evidence/
demo/
sql/
scripts/
*.md
tea.exe
client/test-results
client/playwright-report
client/blob-report

View File

@ -1,31 +1,49 @@
# Stage 1: Build the client # syntax=docker/dockerfile:1
# ---------- Stage 1: build the React/Vite client ----------
FROM node:20-alpine AS client-build FROM node:20-alpine AS client-build
WORKDIR /app/client WORKDIR /app/client
COPY client/package*.json ./ COPY client/package*.json ./
RUN npm install RUN npm ci
COPY client/ ./ COPY client/ .
RUN npm run build RUN npm run build
# Stage 2: Setup server and production image # ---------- Stage 2: install production server deps ----------
FROM node:20-alpine FROM node:20-slim AS server-deps
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app/server
COPY server/package*.json ./
RUN npm ci --omit=dev
# ---------- Stage 3: runtime image ----------
FROM node:20-slim
RUN apt-get update && apt-get install -y --no-install-recommends tini && rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
RUN apk add --no-cache python3 make g++ ENV NODE_ENV=production \
PORT=3001 \
DB_PATH=/app/data/school.db
# Copy server code # Server source + production node_modules
COPY server/package*.json ./server/ COPY server/ ./server/
WORKDIR /app/server COPY --from=server-deps /app/server/node_modules ./server/node_modules
RUN npm install --production
COPY server/ ./
# Copy built client # Built client, served statically by Express server
COPY --from=client-build /app/client/dist /app/client/dist COPY --from=client-build /app/client/dist ./client/dist
COPY docker-entrypoint.sh ./docker-entrypoint.sh
RUN chmod +x docker-entrypoint.sh \
&& mkdir -p /app/data /app/server/uploads \
&& groupadd -g 1001 appgroup && useradd -u 1001 -g appgroup -s /bin/sh -m appuser \
&& chown -R appuser:appgroup /app
USER appuser
# Expose port (using 3001 as that's what the server defaults to)
EXPOSE 3001 EXPOSE 3001
# The server listens on 3001 by default, or PORT env HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
ENV PORT=3001 CMD node -e "require('http').get('http://localhost:3001/api/health',r=>{process.exit(r.statusCode===200?0:1)}).on('error',()=>process.exit(1))"
ENV NODE_ENV=production
CMD ["sh", "-c", "mkdir -p ../data && node src/database/init.js && node src/index.js"] ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["./docker-entrypoint.sh"]

View File

@ -2,24 +2,27 @@ version: '3.8'
services: services:
app: app:
image: node:20-alpine build: .
working_dir: /app image: nextgen-school:latest
ports: ports:
- "3000:3000"
- "3001:3001" - "3001:3001"
environment:
NODE_ENV: production
PORT: 3001
DB_PATH: /app/data/school.db
JWT_SECRET: ${JWT_SECRET:-africa-alert-production-secret-2024}
ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-https://next-gen.techarvest.co.zw,http://localhost:3001}
ALLOW_CLIENT_OFFLINE_MINT: ${ALLOW_CLIENT_OFFLINE_MINT:-false}
env_file:
- path: .env
required: false
volumes: volumes:
- .:/app
- ./data:/app/data - ./data:/app/data
- ./uploads:/app/server/uploads - ./uploads:/app/server/uploads
environment: restart: unless-stopped
- NODE_ENV=production healthcheck:
- PORT=3000 test: ["CMD", "node", "-e", "require('http').get('http://localhost:3001/api/health',r=>{process.exit(r.statusCode===200?0:1)}).on('error',()=>process.exit(1))"]
- DB_PATH=/app/data/school.db interval: 30s
- JWT_SECRET=africa-alert-production-secret-2024 timeout: 5s
command: > retries: 3
sh -c " start_period: 15s
cd server && node src/database/init.js &&
node src/index.js &
cd ../client && npx serve -s dist -l 3000
"
restart: unless-stopped

View File

@ -1,29 +1,12 @@
#!/bin/sh #!/bin/sh
set -e set -e
echo "Starting Africa Alert School Management System..." echo "Starting NextGen School Management System..."
# Initialize database if not exists cd /app/server
if [ ! -f "data/school.db" ]; then
echo "Initializing database..."
cd server && node src/database/init.js && cd ..
fi
# Start API server in background echo "Applying database migrations (idempotent)..."
echo "Starting API server on port 3001..." node src/database/init.js
cd server && node src/index.js &
API_PID=$!
# Wait for API to be ready echo "Starting server on port ${PORT:-3001}..."
sleep 2 exec node src/index.js
# Start frontend in background
echo "Starting frontend on port 3000..."
cd ../client && npx serve -s dist -l 3000 &
FRONTEND_PID=$!
# Handle shutdown gracefully
trap "kill $API_PID $FRONTEND_PID 2>/dev/null" EXIT
# Keep container running
wait

View File

@ -0,0 +1,23 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nextgen-data-pvc
namespace: nextgen
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nextgen-uploads-pvc
namespace: nextgen
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi

View File

@ -7,8 +7,10 @@ resources:
- 20-mattermost.yaml - 20-mattermost.yaml
- 30-vaultwarden.yaml - 30-vaultwarden.yaml
- 45-infisical-secrets.yaml - 45-infisical-secrets.yaml
- 50-nextgen-pvc.yaml
- supabase-nextgen-credentials.yaml - supabase-nextgen-credentials.yaml
- supabase-nextgen.yaml - supabase-nextgen.yaml
- supabase-nextgen-ingress.yaml - supabase-nextgen-ingress.yaml

View File

@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: nextgen
resources:
- ../../nextgen
namePrefix: prod-
patchesStrategicMerge:
- patch-env.yaml

View File

@ -0,0 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: next-gen-main
namespace: nextgen
spec:
replicas: 2
template:
spec:
containers:
- name: app
env:
- name: NODE_ENV
value: "production"
- name: ALLOWED_ORIGINS
value: "https://next-gen.techarvest.co.zw,https://main.next-gen.techarvest.co.zw"

View File

@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: nextgen
resources:
- ../../nextgen
namePrefix: staging-
patchesStrategicMerge:
- patch-env.yaml

View File

@ -0,0 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: next-gen-dev
namespace: nextgen
spec:
replicas: 1
template:
spec:
containers:
- name: app
env:
- name: NODE_ENV
value: "staging"
- name: ALLOWED_ORIGINS
value: "https://staging.next-gen.techarvest.co.zw,http://localhost:3000"