Skip to content

Commit 44fa52f

Browse files
committed
chore: add config
1 parent e2180dd commit 44fa52f

File tree

5 files changed

+208
-0
lines changed

5 files changed

+208
-0
lines changed

docker/acme.docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
acme-sh:
3+
image: neilpang/acme.sh
4+
container_name: acme
5+
restart: always
6+
command: daemon
7+
environment:
8+
- Ali_Key=xxx
9+
- Ali_Secret=yyy
10+
volumes:
11+
- ./acme:/acme.sh
12+
network_mode: host
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy Blog
2+
3+
on:
4+
push:
5+
branches: main
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Connect server to deploy blog
15+
uses: appleboy/ssh-action@master
16+
with:
17+
host: ${{ secrets.SSH_HOST }}
18+
username: ${{ secrets.SSH_USER }}
19+
key: ${{ secrets.SSH_PRIVATE_KEY }}
20+
# 无缓存时,构建大约需要 10min+,8 次拉取重试约 8min+
21+
command_timeout: 30m
22+
script: |
23+
cd ${{ secrets.BLOG_PATH_REMOTE }}
24+
MAX_RETRIES=8
25+
RETRY_COUNT=0
26+
27+
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
28+
echo "▶️ Attempt $((RETRY_COUNT+1))/$MAX_RETRIES: Pulling code..."
29+
if git pull origin main; then
30+
echo "✅ Git pull succeeded"
31+
docker stop blog || true
32+
docker rm blog || true
33+
docker rmi nextjs || true
34+
docker build -t nextjs .
35+
docker compose up -d
36+
exit 0
37+
else
38+
echo "❌ Git pull failed (attempt $((RETRY_COUNT+1))/$MAX_RETRIES)"
39+
((RETRY_COUNT++))
40+
sleep 5
41+
fi
42+
done
43+
44+
echo "🛑 Error: Failed to pull code after $MAX_RETRIES attempts"
45+
exit 1

docker/minio-docker-compose.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'minio'
2+
services:
3+
minio:
4+
container_name: minio
5+
image: minio/minio
6+
restart: always
7+
environment:
8+
- TZ=Asia/Shanghai
9+
- MINIO_ROOT_USER=your_minio_username
10+
- MINIO_ROOT_PASSWORD=youer_minio_password
11+
networks:
12+
- nginx-network
13+
ports:
14+
- '9000:9000'
15+
- '9999:9999'
16+
volumes:
17+
- ./db:/data
18+
- ./config:/root/.minio
19+
command: minio server /data --console-address ":9999"
20+
healthcheck:
21+
test: ['CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live']
22+
interval: 30s
23+
timeout: 20s
24+
retries: 3
25+
networks:
26+
nginx-network:
27+
external: true

docker/nginx-docker-compose.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
services:
2+
nginx:
3+
image: nginx # nginx:alpine
4+
container_name: nginx
5+
restart: always
6+
ports:
7+
- 80:80
8+
- 443:443
9+
volumes:
10+
- ./html:/usr/share/nginx/html
11+
- ./logs:/var/log/nginx
12+
- /data/container/acme/acme:/etc/nginx/ssl
13+
# - ./nginx.conf:/etc/nginx/nginx.conf # dcoker 不支持文件挂载
14+
- ./conf.d:/etc/nginx/conf.d # conf.d 下的 *.conf 会被识别成 nginx 配置文件
15+
- ./default.d:/etc/nginx/default.d
16+
environment:
17+
- TZ=Asia/Shanghai
18+
privileged: true # 解决nginx的文件调用的权限问题
19+
networks:
20+
- nginx-network # 提前手动创建网络 docker network create nginx-network
21+
networks:
22+
nginx-network:
23+
external: true

docker/nginx.conf

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
server {
2+
listen 80;
3+
server_name test.com www.test.com;
4+
return 301 https://$host$request_uri;
5+
}
6+
7+
# standalone mode
8+
server {
9+
listen 443 ssl;
10+
http2 on;
11+
server_name test.com www.test.com;
12+
ssl_certificate "/etc/nginx/ssl/test.com_ecc/test.com.cer"; # fullchain.cer (recommended)
13+
ssl_certificate_key "/etc/nginx/ssl/test.com_ecc/test.com.key";
14+
ssl_session_cache shared:SSL:1m;
15+
ssl_session_timeout 10m;
16+
ssl_ciphers HIGH:!aNULL:!MD5;
17+
ssl_prefer_server_ciphers on;
18+
19+
# root /usr/share/nginx/html;
20+
21+
location / {
22+
# root /usr/share/nginx/html;
23+
# try_files $uri $uri/ /index.html;
24+
# index index.html index.htm;
25+
proxy_pass http://blog:3000; # container name is 'blog'
26+
proxy_set_header Host $http_host;
27+
proxy_set_header X-Real-IP $remote_addr;
28+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
29+
}
30+
}
31+
32+
# export mode
33+
server {
34+
# ....
35+
root /usr/share/nginx/html/jsonq/out;
36+
37+
location / {
38+
try_files $uri $uri.html $uri/ =404;
39+
}
40+
41+
# This is necessary when `trailingSlash: false`.
42+
# You can omit this when `trailingSlash: true`.
43+
location /blog/ {
44+
rewrite ^/blog/(.*)$ /blog/$1.html break;
45+
}
46+
47+
location ^~ /cdn-static/ {
48+
proxy_pass https://testingcf.jsdelivr.net/gh/json-q/picture-blog@main/;
49+
}
50+
51+
error_page 404 /404.html;
52+
location = /404.html {
53+
internal;
54+
}
55+
}
56+
57+
server {
58+
listen 80;
59+
server_name minio.test.com www.minio.test.com;
60+
return 301 https://$host$request_uri;
61+
}
62+
63+
server {
64+
#...
65+
66+
location / {
67+
proxy_pass http://minio:9999;
68+
proxy_set_header Host $http_host;
69+
proxy_set_header X-Real-IP $remote_addr;
70+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
71+
proxy_set_header X-Forwarded-Proto $scheme;
72+
73+
# support websocket
74+
proxy_http_version 1.1;
75+
proxy_set_header Upgrade $http_upgrade;
76+
proxy_set_header Connection "upgrade";
77+
}
78+
}
79+
80+
# img.test.com
81+
server {
82+
listen 80;
83+
server_name img.test.com www.img.test.com;
84+
return 301 https://$host$request_uri;
85+
}
86+
87+
server {
88+
#...
89+
90+
client_max_body_size 50m;
91+
proxy_buffer_size 128k;
92+
proxy_buffers 4 256k;
93+
proxy_busy_buffers_size 256k;
94+
proxy_temp_file_write_size 512k;
95+
96+
add_header Cache-Control "public, max-age=2592000";
97+
location / {
98+
proxy_pass http://minio:9000;
99+
proxy_set_header Host $http_host;
100+
}
101+
}

0 commit comments

Comments
 (0)