Skip to content

Commit 316826b

Browse files
committed
fix: add nginx.conf and fix CI/CD config
1 parent becba06 commit 316826b

2 files changed

Lines changed: 47 additions & 9 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ on:
77

88
env:
99
REGISTRY: ghcr.io
10-
IMAGE_REPO: achernar-eridani
11-
IMAGE_FRONTEND: ${{ github.GH_USER }}/blog-frontend
12-
IMAGE_BACKEND: ${{ github.GH_USER }}/blog-backend
10+
IMAGE_OWNER: achernar-eridani # 固定的 GitHub 用户名(小写)
1311
TAG: ${{ github.sha }}
1412

1513
jobs:
@@ -22,11 +20,13 @@ jobs:
2220
echo "TODO: add tests"
2321
echo "::notice::Skip tests for now"
2422
25-
2623
# ---------- 2) Build & Push ----------
2724
build:
2825
needs: test
2926
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
packages: write
3030
steps:
3131
- uses: actions/checkout@v4
3232

@@ -46,8 +46,8 @@ jobs:
4646
file: ./client/Dockerfile.prod
4747
platforms: linux/amd64
4848
tags: |
49-
${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}:${{ env.TAG }}
50-
${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}:latest
49+
${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/blog-frontend:${{ env.TAG }}
50+
${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/blog-frontend:latest
5151
push: true
5252

5353
- name: Build & push backend
@@ -57,8 +57,8 @@ jobs:
5757
file: ./Dockerfile.backend.prod
5858
platforms: linux/amd64
5959
tags: |
60-
${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}:${{ env.TAG }}
61-
${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}:latest
60+
${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/blog-backend:${{ env.TAG }}
61+
${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/blog-backend:latest
6262
push: true
6363

6464
# ---------- 3) Deploy ----------
@@ -93,4 +93,4 @@ jobs:
9393
fi
9494
echo "retry $i"; sleep 3
9595
done
96-
echo "✗ Health check failed"; exit 1
96+
echo "✗ Health check failed"; exit 1

client/nginx.conf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
server {
2+
listen 443 ssl http2;
3+
server_name myshkin451.com www.myshkin451.com;
4+
5+
ssl_certificate /etc/letsencrypt/live/myshkin451.com/fullchain.pem;
6+
ssl_certificate_key /etc/letsencrypt/live/myshkin451.com/privkey.pem;
7+
8+
ssl_protocols TLSv1.2 TLSv1.3;
9+
ssl_ciphers HIGH:!aNULL:!MD5;
10+
ssl_prefer_server_ciphers on;
11+
12+
root /usr/share/nginx/html;
13+
index index.html;
14+
15+
location / {
16+
try_files $uri $uri/ /index.html;
17+
}
18+
19+
location /api/ {
20+
proxy_pass http://backend:3000;
21+
proxy_set_header Host $host;
22+
proxy_set_header X-Real-IP $remote_addr;
23+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
24+
proxy_set_header X-Forwarded-Proto $scheme;
25+
}
26+
27+
location /uploads/ {
28+
proxy_pass http://backend:3000;
29+
proxy_set_header Host $host;
30+
proxy_set_header X-Real-IP $remote_addr;
31+
}
32+
}
33+
34+
server {
35+
listen 80;
36+
server_name myshkin451.com www.myshkin451.com;
37+
return 301 https://$host$request_uri;
38+
}

0 commit comments

Comments
 (0)