From cda86ded5f5ea3197c0f7e4390bc52e040c1c71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D1=80=D1=81=D0=B5=D0=BD=D1=82=D1=8C=D0=B5=D0=B2=20=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Sat, 15 Aug 2026 20:32:44 +0300 Subject: [PATCH] Add Platform container deployment --- deploy/platform-backend.Dockerfile | 22 ++++++++++++ deploy/platform-compose.yml | 56 +++++++++++++++++++++++++++++ deploy/platform-frontend.Dockerfile | 22 ++++++++++++ deploy/platform-nginx.conf | 21 +++++++++++ 4 files changed, 121 insertions(+) create mode 100644 deploy/platform-backend.Dockerfile create mode 100644 deploy/platform-compose.yml create mode 100644 deploy/platform-frontend.Dockerfile create mode 100644 deploy/platform-nginx.conf diff --git a/deploy/platform-backend.Dockerfile b/deploy/platform-backend.Dockerfile new file mode 100644 index 0000000..af9f9dc --- /dev/null +++ b/deploy/platform-backend.Dockerfile @@ -0,0 +1,22 @@ +FROM python:3.12-slim + +WORKDIR /app + +ENV PYTHONUNBUFFERED=1 +ENV PYTHONDONTWRITEBYTECODE=1 + +COPY platform/backend/requirements.txt . + +RUN pip install --no-cache-dir -r requirements.txt + +COPY platform/backend/ . + +RUN useradd --create-home --uid 1001 appuser \ + && mkdir -p /data \ + && chown -R appuser:appuser /app /data + +USER appuser + +EXPOSE 8000 + +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file diff --git a/deploy/platform-compose.yml b/deploy/platform-compose.yml new file mode 100644 index 0000000..48da3ca --- /dev/null +++ b/deploy/platform-compose.yml @@ -0,0 +1,56 @@ +services: + + platform-backend: + build: + context: .. + dockerfile: deploy/platform-backend.Dockerfile + + restart: unless-stopped + + environment: + APP_NAME: Platform + APP_VERSION: 1.0.0 + APP_DEBUG: "false" + APP_CORS_ORIGINS: "http://192.168.1.35" + + DATABASE_URL: "sqlite:////data/platform.db" + + JWT_SECRET_KEY: "CHANGE_ME_PLATFORM_JWT_SECRET" + JWT_ALGORITHM: "HS256" + JWT_ACCESS_TOKEN_EXPIRE_MINUTES: "480" + + volumes: + - platform_data:/data + + expose: + - "8000" + + healthcheck: + test: + [ + "CMD", + "python", + "-c", + "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/api/v1/health')" + ] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s + + platform-frontend: + build: + context: .. + dockerfile: deploy/platform-frontend.Dockerfile + + restart: unless-stopped + + depends_on: + platform-backend: + condition: service_healthy + + ports: + - "80:80" + +volumes: + platform_data: \ No newline at end of file diff --git a/deploy/platform-frontend.Dockerfile b/deploy/platform-frontend.Dockerfile new file mode 100644 index 0000000..fdc04db --- /dev/null +++ b/deploy/platform-frontend.Dockerfile @@ -0,0 +1,22 @@ +FROM node:22-alpine AS build + +WORKDIR /app + +COPY platform/frontend/package.json platform/frontend/package-lock.json ./ + +RUN npm ci + +COPY platform/frontend/ . + +RUN npm run build + + +FROM nginx:alpine + +COPY --from=build /app/dist /usr/share/nginx/html + +COPY deploy/platform-nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/deploy/platform-nginx.conf b/deploy/platform-nginx.conf new file mode 100644 index 0000000..7421441 --- /dev/null +++ b/deploy/platform-nginx.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location /api/ { + proxy_pass http://platform-backend:8000; + 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 / { + try_files $uri $uri/ /index.html; + } +} \ No newline at end of file