基于alpine、Ubuntu制作nginx镜像
#基础镜像
FROM alpine:3.11
LABEL maintanier="miaosenguo 952726682@qq.com"
#镜像仓库地址
COPY repositories /etc/apk/repositories
#安装
RUN apk update&& apk add iotop gcc libgcc libc-dev libcurl libc-ytils pcre-dev zlib-dev libnfs make pcre pcre2 zip unzip net-tools pstree wget libvent libevent-dev iproute2
#nginx镜像
RUN addgroup -g 2019 -S nginx && adduser -s /sbin/nologin -S -D -u 2019 -G nginx nginx
#添加源码包
ADD nginx-1.16.1.tar.fz /usr/local/src
#编译安装
RUN cd /usr/local/src/nginx-1.16.1 && ./config --prefix=/app/nginx && make && make install && ln -sv /app/nginx/sbin/nginx /usr/bin
#业务镜像
#配置文件
COPY nginx.conf /app/nginx/conf/nginx.conf
#添加静态文件
ADD static.tar.gz /data/nginx/html
RUN cd /app/nginx/html && unzip static.zip && rm -rf static.zip && chown -R nginx.nginx /data/nginx /app/nginx
EXPOSE 80 443
CMD ["nginx"]
其他文件
repositories
http://mirrors.aliyun.com/alpine/v3.11/main
http://mirrors.aliyun.com/alpine/v3.11/community