Skip to content

Commit

Permalink
Update certificate and key file paths in main.go and config.go
Browse files Browse the repository at this point in the history
  • Loading branch information
waveyboym committed Jun 16, 2024
1 parent 09f795b commit 5f64e39
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 68 deletions.
40 changes: 2 additions & 38 deletions .github/workflows/deploy-golang-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-golang-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions occupi-backend/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 0 additions & 12 deletions occupi-backend/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 4 additions & 5 deletions occupi-backend/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
}
}

0 comments on commit 5f64e39

Please sign in to comment.