diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..851dc77 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +node_modules +dist +.git +.gitignore +*.md +.vscode +pencil-new.pen +Reports.jpg diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2d17e36 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# ── Stage 1: Build ─────────────────────────────────────── +FROM node:22-alpine AS builder + +WORKDIR /app + +# Install dependencies first (layer cache) +COPY package.json package-lock.json ./ +RUN npm ci + +# Copy source and build +COPY . . +RUN npm run build + +# ── Stage 2: Serve ─────────────────────────────────────── +FROM nginx:alpine AS runner + +# Copy built assets from builder +COPY --from=builder /app/dist /usr/share/nginx/html + +# Copy custom nginx config for SPA routing +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a6e9884 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + taptrack-website: + build: + context: . + dockerfile: Dockerfile + container_name: taptrack-website + ports: + - "3000:80" + restart: unless-stopped diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..75effb5 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,24 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + # Gzip compression + gzip on; + gzip_types text/plain text/css application/javascript application/json image/svg+xml; + gzip_min_length 1024; + + # Cache static assets aggressively + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + try_files $uri =404; + } + + # SPA fallback — all routes serve index.html + location / { + try_files $uri $uri/ /index.html; + } +}