# 如果需要luarocks，需要改用fat镜像
FROM openresty/openresty:1.15.8.3-1-alpine

# 修复时区显示问题
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
  && apk add tzdata \ 
  && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  && echo "Asia/Shanghai" > /etc/timezone \
  && apk del tzdata \
  && chown nobody /home \
  && chown nobody /var/run/openresty

# 使用非root用户启动nginx
USER nobody

RUN mkdir -p /home/quant_group/dist \
  && mkdir /home/quant_group/logs \
  && touch /home/quant_group/logs/error.log /home/quant_group/logs/access.log \
  # 拷贝默认文件，避免代码存放不当导致循环请求异常
  && cp /usr/local/openresty/nginx/html/index.html /home/quant_group/dist

COPY nginx.conf /usr/local/openresty/nginx/conf/
COPY default.conf /etc/nginx/conf.d/
