Skip to content

Commit 47be558

Browse files
author
gptkong
committed
update GitHub Actions workflow to enhance Docker build process; implement caching for improved performance and streamline build steps
1 parent f6cd622 commit 47be558

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

ahooks-docs/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 使用官方的Alpine Linux作为基础镜像
2+
FROM alpine:latest
3+
4+
# 为了clone仓库,需要安装git
5+
RUN apk add --no-cache git
6+
7+
# 克隆特定的分支到一个临时目录
8+
RUN git clone --branch gh-pages --depth=1 https://github.com/alibaba/hooks.git /tmp/hooks
9+
10+
# 创建一个新的阶段来构建最小的Nginx镜像
11+
FROM nginx:alpine
12+
13+
# 将克隆的内容复制到Nginx的html目录
14+
COPY --from=0 /tmp/hooks /usr/share/nginx/html
15+
16+
# 添加自定义Nginx配置
17+
COPY nginx.conf /etc/nginx/conf.d/default.conf
18+
19+
# 暴露Nginx的默认端口
20+
EXPOSE 80
21+
22+
# 启动Nginx服务器
23+
CMD ["nginx", "-g", "daemon off;"]

ahooks-docs/nginx.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
# 设置根目录
6+
root /usr/share/nginx/html;
7+
index index.html;
8+
9+
# 启用 gzip 压缩
10+
gzip on;
11+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
12+
13+
# 重写 /zh-CN/hooks/ 开头的请求到根路径
14+
location ^~ /zh-CN/hooks/ {
15+
rewrite ^/zh-CN/hooks/(.*) /$1 break;
16+
try_files $uri $uri/ /index.html;
17+
}
18+
19+
# 重写 /hooks/ 开头的请求到根路径
20+
location ^~ /hooks/ {
21+
rewrite ^/hooks/(.*) /$1 break;
22+
try_files $uri $uri/ /index.html;
23+
}
24+
25+
}

0 commit comments

Comments
 (0)