diff --git a/.github/workflows/deploy-golang-develop.yml b/.github/workflows/deploy-golang-develop.yml index a74370c3..37282574 100644 --- a/.github/workflows/deploy-golang-develop.yml +++ b/.github/workflows/deploy-golang-develop.yml @@ -20,45 +20,9 @@ defaults: working-directory: occupi-backend jobs: - build-push-docker: - name: Build and Push Develop Docker Image - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Decrypt env variables - run: | - echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 .dev.env.gpg > .dev.env - - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: occupi-backend - file: occupi-backend/Dockerfile.dev - platforms: linux/amd64,linux/arm64 - push: true - no-cache: true - tags: ${{ secrets.DOCKER_USERNAME }}/occupi-backend:latest-develop - deploy: name: Deploy for Develop runs-on: ubuntu-latest - needs: build-push-docker steps: - name: Checkout code @@ -71,7 +35,7 @@ jobs: username: ${{ secrets.VM_USERNAME }} key: ${{ secrets.VM_SSH_KEY }} source: "occupi-backend/docker-compose.dev.yml,occupi-backend/Dockerfile.dev" - target: "/home/Y2KODELABS/occupi-backend-dev" + target: "/home/${{ secrets.VM_USERNAME }}/occupi-backend-dev" # SSH to VM and run commands - name: SSH to VM @@ -81,7 +45,7 @@ jobs: username: ${{ secrets.VM_USERNAME }} key: ${{ secrets.VM_SSH_KEY }} script: | - cd /home/Y2KODELABS/occupi-backend-dev/occupi-backend + cd /home/${{ secrets.VM_USERNAME }}/occupi-backend-dev/occupi-backend echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }} docker compose -f docker-compose.dev.yml down DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }} docker compose -f docker-compose.dev.yml pull diff --git a/.github/workflows/deploy-golang-prod.yml b/.github/workflows/deploy-golang-prod.yml index 559753cc..05e8944a 100644 --- a/.github/workflows/deploy-golang-prod.yml +++ b/.github/workflows/deploy-golang-prod.yml @@ -125,7 +125,7 @@ jobs: username: ${{ secrets.VM_USERNAME }} key: ${{ secrets.VM_SSH_KEY }} script: | - cd /home/Y2KODELABS/occupi-backend + cd /home/${{ secrets.VM_USERNAME }}/occupi-backend gpg --quiet --batch --yes --decrypt --passphrase=$GPG_PASSPHRASE --output .env .env.gpg docker-compose -f docker-compose.traefik.yml up -d docker-compose -f docker-compose.prod.yml pull diff --git a/occupi-backend/docker-compose.dev.yml b/occupi-backend/docker-compose.dev.yml index 5a04ea10..aa81700b 100644 --- a/occupi-backend/docker-compose.dev.yml +++ b/occupi-backend/docker-compose.dev.yml @@ -17,18 +17,6 @@ services: - /etc/letsencrypt/live/dev.occupi.tech/fullchain.pem:/etc/letsencrypt/live/dev.occupi.tech/fullchain.pem:ro - /etc/letsencrypt/live/dev.occupi.tech/privkey.pem:/etc/letsencrypt/live/dev.occupi.tech/privkey.pem:ro - nginx: - image: nginx:latest - ports: - - "80:80" - - "443:443" - volumes: - - /etc/nginx:/etc/nginx:ro - - /etc/letsencrypt/live/dev.occupi.tech/fullchain.pem:/etc/letsencrypt/live/dev.occupi.tech/fullchain.pem:ro - - /etc/letsencrypt/live/dev.occupi.tech/privkey.pem:/etc/letsencrypt/live/dev.occupi.tech/privkey.pem:ro - depends_on: - - occupi-backend-dev - networks: webnet: external: true diff --git a/occupi-backend/docker-compose.prod.yml b/occupi-backend/docker-compose.prod.yml index 092adb33..74941076 100644 --- a/occupi-backend/docker-compose.prod.yml +++ b/occupi-backend/docker-compose.prod.yml @@ -17,18 +17,6 @@ services: - /etc/letsencrypt/live/occupi.tech/fullchain.pem:/etc/letsencrypt/live/occupi.tech/fullchain.pem:ro - /etc/letsencrypt/live/occupi.tech/privkey.pem:/etc/letsencrypt/live/occupi.tech/privkey.pem:ro - nginx: - image: nginx:latest - ports: - - "80:80" - - "443:443" - volumes: - - /etc/nginx:/etc/nginx:ro - - /etc/letsencrypt/live/occupi.tech/fullchain.pem:/etc/letsencrypt/live/occupi.tech/fullchain.pem:ro - - /etc/letsencrypt/live/occupi.tech/privkey.pem:/etc/letsencrypt/live/occupi.tech/privkey.pem:ro - depends_on: - - occupi-backend-prod - networks: webnet: external: true diff --git a/occupi-backend/nginx.conf b/occupi-backend/nginx.conf index 3fe24048..0b99c65f 100644 --- a/occupi-backend/nginx.conf +++ b/occupi-backend/nginx.conf @@ -1,7 +1,7 @@ # Redirect HTTP to HTTPS for both domains server { listen 80; - server_name occupi.tech www.occupi.tech dev.occupi.tech; + server_name occupi.tech www.occupi.tech dev.occupi.tech www.dev.occupi.tech; return 301 https://$host$request_uri; } @@ -14,7 +14,7 @@ server { ssl_certificate_key /etc/letsencrypt/live/occupi.tech/privkey.pem; location / { - proxy_pass http://occupi-backend-prod:8080; + proxy_pass https://localhost:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -25,17 +25,16 @@ server { # Development server block server { listen 443 ssl; - server_name dev.occupi.tech; + server_name dev.occupi.tech www.dev.occupi.tech; ssl_certificate /etc/letsencrypt/live/dev.occupi.tech/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/dev.occupi.tech/privkey.pem; location / { - proxy_pass http://occupi-backend-dev:8081; + proxy_pass https://localhost:8081; 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; } } -