diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index b45dbdf..d7be2a5 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -37,10 +37,12 @@ jobs: SSH_PORT: ${{ secrets.SSH_PORT }} SSH_USER: ${{ secrets.SSH_USER }} DEPLOY_DIR: ${{ secrets.SSH_DEPLOY_DIR }} + COMPOSE_FILE: ${{ secrets.COMPOSE_FILE }} run: | mkdir -p ~/.ssh echo "$SSH_KEY" > ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key PORT="${SSH_PORT:-22}" + FILE="${COMPOSE_FILE:-docker-compose.yml}" ssh -i ~/.ssh/deploy_key -p "$PORT" -o StrictHostKeyChecking=no -o BatchMode=yes "$SSH_USER@$SSH_HOST" \ - "cd $DEPLOY_DIR && git pull --ff-only && docker compose pull && sudo -n systemctl stop torgi && sudo -n systemctl start torgi && sudo -n systemctl is-active torgi" + "cd $DEPLOY_DIR && git pull --ff-only && docker compose -f \"$FILE\" pull && sudo -n systemctl stop torgi && sudo -n systemctl start torgi && sudo -n systemctl is-active torgi" diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 015b5ab..fb012f6 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -9,7 +9,10 @@ COPY . ./ RUN npm run build # Этап 2: раздача статики + прокси API. +# Хост бэкенда задается переменной BACKEND_HOST (шаблон обрабатывается +# entrypoint'ом nginx при старте контейнера). FROM nginx:1.27-alpine +ENV BACKEND_HOST=client-backend COPY --from=build /app/dist /usr/share/nginx/html -COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY nginx.conf.template /etc/nginx/templates/default.conf.template EXPOSE 80 diff --git a/frontend/nginx.conf b/frontend/nginx.conf deleted file mode 100644 index a2a9348..0000000 --- a/frontend/nginx.conf +++ /dev/null @@ -1,28 +0,0 @@ -server { - listen 80; - - # API бэкенда (Spring Boot в compose-сервисе client-backend) - location /api/ { - proxy_pass http://client-backend:8181; - 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; - } - - # Swagger UI бэкенда (удобно на первое время, потом можно закрыть) - location /swagger-ui/ { - proxy_pass http://client-backend:8181; - proxy_set_header Host $host; - } - location /v3/api-docs { - proxy_pass http://client-backend:8181; - proxy_set_header Host $host; - } - - # Статика React SPA - location / { - root /usr/share/nginx/html; - try_files $uri /index.html; - } -}