diff --git a/aggregator-web/Dockerfile b/aggregator-web/Dockerfile new file mode 100644 index 0000000..583d868 --- /dev/null +++ b/aggregator-web/Dockerfile @@ -0,0 +1,29 @@ +# Build stage +FROM node:20-alpine AS build + +WORKDIR /app + +# Copy package files +COPY package*.json ./ + +# Install dependencies +RUN npm ci + +# Copy source code +COPY . . + +# Build the application +RUN npm run build + +# Production stage +FROM nginx:alpine + +# Copy built assets from build stage +COPY --from=build /app/dist /usr/share/nginx/html + +# Copy nginx configuration +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/aggregator-web/nginx.conf b/aggregator-web/nginx.conf new file mode 100644 index 0000000..26c4fde --- /dev/null +++ b/aggregator-web/nginx.conf @@ -0,0 +1,32 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Serve static files + location / { + try_files $uri $uri/ /index.html; + } + + # Proxy API requests to backend server + location /api/ { + proxy_pass http://server:8080; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + # Proxy health endpoint + location /health { + proxy_pass http://server:8080; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 03229a4..271d818 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -42,6 +42,17 @@ services: command: ["./redflag-server"] restart: unless-stopped + web: + build: + context: ./aggregator-web + dockerfile: Dockerfile + container_name: redflag-web + ports: + - "3000:80" + depends_on: + - server + restart: unless-stopped + volumes: postgres-data: server-data: