kevin1207 commited on
Commit
66b0607
·
verified ·
1 Parent(s): 31d9fe2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -3
Dockerfile CHANGED
@@ -27,6 +27,7 @@ RUN pnpm build
27
 
28
  # production stage
29
  FROM nginx:stable-alpine AS production-stage
 
30
  # 创建必要的 Nginx 目录并设置权限
31
  RUN mkdir -p /var/cache/nginx && \
32
  mkdir -p /var/log/nginx && \
@@ -34,17 +35,19 @@ RUN mkdir -p /var/cache/nginx && \
34
  chown -R nginx:nginx /var/cache/nginx && \
35
  chown -R nginx:nginx /var/log/nginx && \
36
  chown -R nginx:nginx /etc/nginx/conf.d
37
- # 修改 nginx.conf 的用户设置
38
- RUN sed -i 's/user nginx/user nginx/g' /etc/nginx/nginx.conf
39
  COPY --from=build-stage /app/dist /usr/share/nginx/html
40
  COPY --from=build-stage /app/nginx.conf /etc/nginx/conf.d/default.conf
41
 
42
  # 确保 Nginx 目录的权限正确
43
  RUN chown -R nginx:nginx /usr/share/nginx/html && \
44
  chmod -R 755 /usr/share/nginx/html
 
45
  # 使用非 root 用户运行
46
- USER nginx
 
47
  EXPOSE 80
 
48
  CMD ["nginx", "-g", "daemon off;"]
49
 
50
 
 
27
 
28
  # production stage
29
  FROM nginx:stable-alpine AS production-stage
30
+
31
  # 创建必要的 Nginx 目录并设置权限
32
  RUN mkdir -p /var/cache/nginx && \
33
  mkdir -p /var/log/nginx && \
 
35
  chown -R nginx:nginx /var/cache/nginx && \
36
  chown -R nginx:nginx /var/log/nginx && \
37
  chown -R nginx:nginx /etc/nginx/conf.d
38
+
 
39
  COPY --from=build-stage /app/dist /usr/share/nginx/html
40
  COPY --from=build-stage /app/nginx.conf /etc/nginx/conf.d/default.conf
41
 
42
  # 确保 Nginx 目录的权限正确
43
  RUN chown -R nginx:nginx /usr/share/nginx/html && \
44
  chmod -R 755 /usr/share/nginx/html
45
+
46
  # 使用非 root 用户运行
47
+ USER nginx
48
+
49
  EXPOSE 80
50
+
51
  CMD ["nginx", "-g", "daemon off;"]
52
 
53