This commit is contained in:
arrelin
2025-12-15 18:43:14 +03:00
parent 6966fbbc2c
commit 20ad9f5833
4 changed files with 92 additions and 7 deletions

View File

@@ -29,7 +29,7 @@ services:
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
RUST_LOG: ${RUST_LOG:-info}
ports:
- "3000:3000"
- "8080:8080"
depends_on:
postgres:
condition: service_healthy
@@ -42,9 +42,10 @@ services:
dockerfile: Dockerfile
container_name: family_budget_frontend
ports:
- "5173:5173"
- "80:80"
depends_on:
- backend
backend:
condition: service_started
networks:
- app_network

19
frontend/.dockerignore Normal file
View File

@@ -0,0 +1,19 @@
node_modules/
dist/
.git/
.gitignore
.env
.env.*
!.env.example
*.md
Dockerfile
docker-compose.yml
.dockerignore
.idea/
.vscode/
*.swp
*.swo
*~
.DS_Store
coverage/
.eslintcache

View File

@@ -1,13 +1,23 @@
FROM node:20-alpine
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
EXPOSE 5173
ARG VITE_API_BASE_URL=/
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
RUN npm run build
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

55
frontend/nginx.conf Normal file
View File

@@ -0,0 +1,55 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://backend: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;
}
location /families {
proxy_pass http://backend:8080;
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;
}
location /login {
proxy_pass http://backend:8080;
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;
}
location /logout {
proxy_pass http://backend:8080;
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;
}
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 6;
gzip_min_length 1000;
}