Browse Source

dockerfile

master
feing 9 months ago
parent
commit
d7d76f0dc2
2 changed files with 63 additions and 5 deletions
  1. 9
    5
      Dockerfile
  2. 54
    0
      default-nginx.conf

+ 9
- 5
Dockerfile View File

@@ -1,5 +1,5 @@
# 使用 Node 作为基础镜像
FROM registry.cn-hangzhou.aliyuncs.com/zsanyu/rcsc:amd64-node-21
FROM registry.cn-hangzhou.aliyuncs.com/zsanyu/rcsc:amd64-node-21 as builder

# 设置工作目录
WORKDIR /app
@@ -17,8 +17,12 @@ COPY . .
# 构建项目
RUN npx vite build

# 暴露端口
EXPOSE 3000
FROM nginx:stable-alpine

RUN rm -rf /etc/nginx/conf.d/default.conf

# 启动应用
CMD ["npm", "run", "serve"]
COPY --from=builder /app/dist /usr/share/nginx/html
COPY --from=builder /app/default-nginx.conf /etc/nginx/conf.d/default.conf

# 暴露端口
EXPOSE 80

+ 54
- 0
default-nginx.conf View File

@@ -0,0 +1,54 @@
server {
listen 80;
listen [::]:80;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

# location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
# }

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ @rewrites;
}

location @rewrites {
rewrite ^(.+)$ /index.html last;
}
#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


Loading…
Cancel
Save