Add full monorepo: virtual-banker, backend, frontend, docs, scripts, deployment
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
30
deployment/Dockerfile.backend
Normal file
30
deployment/Dockerfile.backend
Normal file
@@ -0,0 +1,30 @@
|
||||
FROM golang:1.21-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go mod files
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/virtual-banker-api ./main.go
|
||||
|
||||
# Final stage
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk --no-cache add ca-certificates curl
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
COPY --from=builder /app/virtual-banker-api .
|
||||
|
||||
EXPOSE 8081
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD curl -f http://localhost:8081/health || exit 1
|
||||
|
||||
CMD ["./virtual-banker-api"]
|
||||
|
||||
28
deployment/Dockerfile.widget
Normal file
28
deployment/Dockerfile.widget
Normal file
@@ -0,0 +1,28 @@
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Copy source
|
||||
COPY . .
|
||||
|
||||
# Build
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM nginx:alpine
|
||||
|
||||
# Copy built files
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
COPY --from=builder /app/public/widget.js /usr/share/nginx/html/widget.js
|
||||
|
||||
# Copy nginx config
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
50
deployment/docker-compose.yml
Normal file
50
deployment/docker-compose.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
virtual-banker-api:
|
||||
build:
|
||||
context: ../backend
|
||||
dockerfile: ../deployment/Dockerfile.backend
|
||||
environment:
|
||||
- DATABASE_URL=postgres://explorer:changeme@postgres:5432/explorer?sslmode=disable
|
||||
- REDIS_URL=redis://redis:6379
|
||||
- PORT=8081
|
||||
ports:
|
||||
- "8081:8081"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8081/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '2'
|
||||
memory: 2G
|
||||
reservations:
|
||||
cpus: '1'
|
||||
memory: 1G
|
||||
restart: unless-stopped
|
||||
labels:
|
||||
- "com.solacescanscout.name=virtual-banker-api"
|
||||
- "com.solacescanscout.version=1.0.0"
|
||||
- "com.solacescanscout.service=virtual-banker-api"
|
||||
|
||||
virtual-banker-widget:
|
||||
build:
|
||||
context: ../widget
|
||||
dockerfile: ../deployment/Dockerfile.widget
|
||||
ports:
|
||||
- "8082:80"
|
||||
restart: unless-stopped
|
||||
labels:
|
||||
- "com.solacescanscout.name=virtual-banker-widget"
|
||||
- "com.solacescanscout.version=1.0.0"
|
||||
- "com.solacescanscout.service=virtual-banker-widget-cdn"
|
||||
|
||||
44
deployment/nginx.conf
Normal file
44
deployment/nginx.conf
Normal file
@@ -0,0 +1,44 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Enable gzip
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# CORS for widget embedding
|
||||
add_header Access-Control-Allow-Origin "*" always;
|
||||
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
|
||||
add_header Access-Control-Allow-Headers "Content-Type, Authorization" always;
|
||||
|
||||
# Widget loader script
|
||||
location /widget.js {
|
||||
add_header Content-Type "application/javascript";
|
||||
expires 1h;
|
||||
}
|
||||
|
||||
# Static assets
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
expires 1h;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Health check
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user