1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

change docker

This commit is contained in:
MoonTestUse1
2024-12-23 23:44:46 +06:00
parent 876abdfc86
commit 866b0cbbf7
4 changed files with 18 additions and 11 deletions

View File

@@ -7,6 +7,11 @@ services:
dockerfile: ../docker/frontend/Dockerfile dockerfile: ../docker/frontend/Dockerfile
container_name: support-frontend container_name: support-frontend
restart: unless-stopped restart: unless-stopped
volumes:
- ./frontend:/app
- /app/node_modules
depends_on:
- backend
backend: backend:
build: build:
@@ -18,6 +23,7 @@ services:
- TELEGRAM_BOT_TOKEN=7677506032:AAHEqNUr1lIUfNVbLwaWIaPeKKShsCyz3eo - TELEGRAM_BOT_TOKEN=7677506032:AAHEqNUr1lIUfNVbLwaWIaPeKKShsCyz3eo
- TELEGRAM_CHAT_ID=-1002037023574 - TELEGRAM_CHAT_ID=-1002037023574
volumes: volumes:
- ./backend:/app
- sqlite_data:/app/instance - sqlite_data:/app/instance
nginx: nginx:
@@ -29,6 +35,7 @@ services:
volumes: volumes:
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro - ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
- ./frontend/dist:/usr/share/nginx/html:ro
depends_on: depends_on:
- frontend - frontend
- backend - backend

View File

@@ -1,3 +1,4 @@
# docker/backend/Dockerfile
FROM python:3.11-slim FROM python:3.11-slim
WORKDIR /app WORKDIR /app
@@ -6,11 +7,7 @@ RUN apt-get update && apt-get install -y \
gcc \ gcc \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt . COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY . .
CMD ["python", "run.py"] CMD ["python", "run.py"]

View File

@@ -5,13 +5,16 @@ WORKDIR /app
# Copy package files # Copy package files
COPY package*.json ./ COPY package*.json ./
# Install dependencies
RUN npm install RUN npm install
# Copy source code and build # Copy source code
COPY . . COPY . .
# Build the application
RUN npm run build RUN npm run build
# Production stage # Copy built files to nginx html directory
FROM nginx:alpine FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

View File

@@ -1,6 +1,6 @@
# docker/nginx/conf.d/default.conf # docker/nginx/conf.d/default.conf
upstream backend { upstream backend {
server backend:8000; server backend:8000; # Changed port to match FastAPI default
} }
server { server {
@@ -10,15 +10,15 @@ server {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.html; index index.html;
# Handle SPA routing # Handle frontend routes
location / { location / {
try_files $uri $uri/ /index.html; try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache"; add_header Cache-Control "no-cache";
} }
# Proxy API requests # Proxy API requests to backend
location /api/ { location /api/ {
proxy_pass http://backend/api/; proxy_pass http://backend/;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade'; proxy_set_header Connection 'upgrade';