diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..a8173ba --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,42 @@ +name: Docker Build & Publish + +on: + push: + branches: [ "main", "dp-gui" ] + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Server image + uses: docker/build-push-action@v5 + with: + context: ./server + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-server:${{ github.ref_name }} + + - name: Build and push Client image + uses: docker/build-push-action@v5 + with: + context: ./client + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-client:${{ github.ref_name }} \ No newline at end of file diff --git a/client/nginx.conf b/client/nginx.conf index f224d69..c6c24d4 100644 --- a/client/nginx.conf +++ b/client/nginx.conf @@ -1,17 +1,32 @@ server { listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; location / { - root /usr/share/nginx/html; - index index.html index.htm; try_files $uri $uri/ /index.html; } - location /api/ { + proxy_pass http://server:3000; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $http_host; + proxy_cache_bypass $http_upgrade; + } +} +server { + listen 3000; + server_name localhost; + location / { proxy_pass http://backend:3000/; - 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 Host \$http_host; } } \ No newline at end of file diff --git a/install.sh b/install.sh index 3975fdc..02c61f7 100644 --- a/install.sh +++ b/install.sh @@ -6,6 +6,10 @@ set -euo pipefail ################################# REPO_URL="https://github.com/denpiligrim/3dp-manager/archive/refs/heads/dp-gui.tar.gz" PROJECT_DIR="/opt/3dp-manager" +DOCKER_USER="denpiligrim" +DOCKER_TAG="dp-gui" +IMAGE_SERVER="ghcr.io/${DOCKER_USER}/3dp-manager-server:${DOCKER_TAG}" +IMAGE_CLIENT="ghcr.io/${DOCKER_USER}/3dp-manager-client:${DOCKER_TAG}" # Цвета для вывода RED='\033[0;31m' @@ -178,51 +182,6 @@ log "Сгенерированы секретные ключи для БД и JWT ################################# # ГЕНЕРАЦИЯ ФАЙЛОВ DOCKER ################################# - -# --- 1. Dockerfile для Client --- -cat > client/Dockerfile < server/Dockerfile < server/.env < client/nginx-client.conf < client/nginx-client.conf <