Compare commits
7 Commits
3.0-nohash
...
3.2-nohash
| Author | SHA1 | Date | |
|---|---|---|---|
| c18893e6f3 | |||
| c64d5a96cb | |||
| 379bacf023 | |||
| ad2420775e | |||
| fe1a62a7b3 | |||
| bf9f6e5cd5 | |||
| 22381f3034 |
24
action.yml
24
action.yml
@@ -12,32 +12,12 @@ runs:
|
|||||||
export http_proxy=http://100.100.13.14:8118 && \
|
export http_proxy=http://100.100.13.14:8118 && \
|
||||||
npm pkg set version=${{ github.ref_name }} && \
|
npm pkg set version=${{ github.ref_name }} && \
|
||||||
npm ci && \
|
npm ci && \
|
||||||
|
|
||||||
# 关键:构建时强制开启 HISTORY 模式
|
|
||||||
echo 'VITE_ROUTER_MODE=history' > .env.production && \
|
|
||||||
|
|
||||||
npm run build-only"
|
npm run build-only"
|
||||||
|
|
||||||
- uses: docker://ubuntu:latest
|
- uses: docker://ubuntu:latest
|
||||||
with:
|
with:
|
||||||
entrypoint: "/bin/bash"
|
entrypoint: "/bin/bash"
|
||||||
args: |
|
args: |
|
||||||
-c 'echo "FROM nginx:alpine" > Dockerfile && \
|
-c 'cp "${{ github.action_path }}/nginx.conf" ./ && cp "${{ github.action_path }}/vue.Dockerfile" ./Dockerfile'
|
||||||
echo "COPY dist /usr/share/nginx/html" >> Dockerfile && \
|
|
||||||
echo "WORKDIR /usr/share/nginx/html/" >> Dockerfile && \
|
|
||||||
|
|
||||||
# 关键:Nginx 配置,解决刷新 404(去掉 # 必须加)
|
|
||||||
echo "RUN echo \"server {\" > /etc/nginx/conf.d/default.conf" >> Dockerfile && \
|
|
||||||
echo "RUN echo \" listen 80;\" >> /etc/nginx/conf.d/default.conf" >> Dockerfile && \
|
|
||||||
echo "RUN echo \" server_name localhost;\" >> /etc/nginx/conf.d/default.conf" >> Dockerfile && \
|
|
||||||
echo "RUN echo \" root /usr/share/nginx/html;\" >> /etc/nginx/conf.d/default.conf" >> Dockerfile && \
|
|
||||||
echo "RUN echo \" index index.html;\" >> /etc/nginx/conf.d/default.conf" >> Dockerfile && \
|
|
||||||
echo "RUN echo \" location / {\" >> /etc/nginx/conf.d/default.conf" >> Dockerfile && \
|
|
||||||
echo "RUN echo \" try_files \$uri \$uri/ /index.html;\" >> /etc/nginx/conf.d/default.conf" >> Dockerfile && \
|
|
||||||
echo "RUN echo \" }\" >> /etc/nginx/conf.d/default.conf" >> Dockerfile && \
|
|
||||||
echo "RUN echo \"}\" >> /etc/nginx/conf.d/default.conf" >> Dockerfile && \
|
|
||||||
|
|
||||||
echo "已构建支持无 # 路由的 Dockerfile" && \
|
|
||||||
cat Dockerfile'
|
|
||||||
|
|
||||||
- uses: actions/docker-build-push@main
|
- uses: actions/docker-build-push@main
|
||||||
|
|||||||
21
nginx.conf
Normal file
21
nginx.conf
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# 👇 跨域配置开始
|
||||||
|
add_header Access-Control-Allow-Origin * always;
|
||||||
|
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE' always;
|
||||||
|
add_header Access-Control-Allow-Headers '*, Origin, X-Requested-With, Content-Type, Accept, Authorization, X-Token' always;
|
||||||
|
add_header Access-Control-Allow-Credentials 'true' always;
|
||||||
|
|
||||||
|
# 处理预检 OPTIONS 请求
|
||||||
|
if ($request_method = 'OPTIONS') {
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
# 👆 跨域配置结束
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
vue.Dockerfile
Normal file
3
vue.Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
COPY dist /usr/share/nginx/html
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
Reference in New Issue
Block a user