Browse Source

fix bug

main
xiaoz 12 months ago
parent
commit
1e138ab31d
  1. 9
      nginx/Dockerfile
  2. 3
      nginx/sh/install_nginx.sh

9
nginx/Dockerfile

@ -1,18 +1,13 @@
#基于哪个镜像制作,3.14会有问题 #基于哪个镜像制作,3.14会有问题
FROM alpine:3.13 FROM alpine:3.13
RUN addgroup -S nginx && adduser -S nginx -G nginx
USER nginx
#工作目录 #工作目录
WORKDIR /opt WORKDIR /opt
# 确保 nginx 用户有权限访问复制的文件 # 确保 nginx 用户有权限访问复制的文件
COPY --chown=nginx:nginx sh/* /opt/ COPY sh/* /opt/
#执行安装脚本 #执行安装脚本
# 切换到 root 用户进行安装
USER root
RUN sh install_nginx.sh RUN sh install_nginx.sh
# 切换回 nginx 用户
USER nginx
#健康检查 #健康检查
HEALTHCHECK --interval=10s --timeout=5s \ HEALTHCHECK --interval=10s --timeout=5s \

3
nginx/sh/install_nginx.sh

@ -52,6 +52,8 @@ install_before(){
#安装nginx #安装nginx
install_nginx(){ install_nginx(){
# 创建用户
addgroup -S nginx && adduser -S nginx -G nginx
cd /usr/local cd /usr/local
NGINX_NAME=xcdn-binary-alpine-${nginx_version}-${THEDATE}_x86_64.tar.gz NGINX_NAME=xcdn-binary-alpine-${nginx_version}-${THEDATE}_x86_64.tar.gz
wget http://soft.xiaoz.org/xcdn/${NGINX_NAME} wget http://soft.xiaoz.org/xcdn/${NGINX_NAME}
@ -63,6 +65,7 @@ install_nginx(){
export PATH=$PATH:'/usr/local/nginx/sbin' export PATH=$PATH:'/usr/local/nginx/sbin'
# 设置权限 # 设置权限
chown -R nginx:nginx /usr/local/nginx chown -R nginx:nginx /usr/local/nginx
chown -R nginx:nginx /opt
#日志分割 #日志分割
#wget --no-check-certificate https://raw.githubusercontent.com/helloxz/nginx-cdn/master/etc/logrotate.d/nginx -P /etc/logrotate.d/ #wget --no-check-certificate https://raw.githubusercontent.com/helloxz/nginx-cdn/master/etc/logrotate.d/nginx -P /etc/logrotate.d/

Loading…
Cancel
Save