Commit 2958718e authored by Kantz's avatar Kantz
Browse files

nginx setup

parent 22db3d83
services: services:
nginx:
image: nginx:1.27-alpine
depends_on:
- backend
- frontend
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- frontend-dist:/usr/share/nginx/html:ro
restart: unless-stopped
backend: backend:
build: build:
context: ../backend context: ../backend
dockerfile: Dockerfile dockerfile: Dockerfile
env_file: env_file:
- ../backend/.env - ../backend/.env_openai
expose: expose:
- "8000" - "8000"
healthcheck: healthcheck:
...@@ -34,6 +22,8 @@ services: ...@@ -34,6 +22,8 @@ services:
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./logs:/app/logs - ./logs:/app/logs
networks:
- web
frontend: frontend:
build: build:
...@@ -41,9 +31,10 @@ services: ...@@ -41,9 +31,10 @@ services:
dockerfile: Dockerfile dockerfile: Dockerfile
depends_on: depends_on:
- backend - backend
volumes:
- frontend-dist:/dist
restart: unless-stopped restart: unless-stopped
networks:
- web
volumes: networks:
frontend-dist: web:
external: true
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri /index.html;
}
location /api/ {
proxy_pass http://backend:8000/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
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;
}
}
FROM node:22-alpine AS build FROM node:22-alpine AS build
WORKDIR /app WORKDIR /app
RUN corepack enable RUN corepack enable
COPY package.json pnpm-lock.yaml ./ COPY package.json pnpm-lock.yaml ./
...@@ -10,10 +9,6 @@ RUN pnpm install --frozen-lockfile ...@@ -10,10 +9,6 @@ RUN pnpm install --frozen-lockfile
COPY . . COPY . .
RUN pnpm run build RUN pnpm run build
FROM alpine:3.20 FROM nginx:1.27-alpine
COPY --from=build /app/dist /usr/share/nginx/html
WORKDIR /app COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist ./dist
CMD ["sh", "-c", "mkdir -p /dist && cp -r /app/dist/. /dist/ && tail -f /dev/null"]
server {
listen 3000;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment