两段编译,减小镜像体积

pull/55/head
root 2019-10-08 19:20:35 +08:00
parent 5576acc29d
commit 3db1b8a243
1 changed files with 9 additions and 3 deletions

View File

@ -1,18 +1,24 @@
FROM nginx FROM debian:latest as builder
MAINTAINER cppla https://cpp.la MAINTAINER cppla https://cpp.la
RUN apt-get update RUN apt-get update
RUN apt-get -y install gcc g++ make git RUN apt-get -y install gcc g++ make git
RUN git clone https://github.com/cppla/ServerStatus RUN git clone https://github.com/cppla/ServerStatus
RUN cp -rf /ServerStatus/web/* /usr/share/nginx/html/
WORKDIR /ServerStatus/server WORKDIR /ServerStatus/server
RUN make RUN make
RUN pwd && ls -a RUN pwd && ls -a
# glibc env run
FROM nginx:latest
RUN mkdir -p /ServerStatus/server/
COPY --from=builder /ServerStatus/server /ServerStatus/server/
COPY --from=builder /ServerStatus/web /usr/share/nginx/html/
EXPOSE 80 35601 EXPOSE 80 35601
CMD nohup sh -c '/etc/init.d/nginx start && /ServerStatus/server/sergate --config=/ServerStatus/server/config.json --web-dir=/usr/share/nginx/html' CMD nohup sh -c '/etc/init.d/nginx start && /ServerStatus/server/sergate --config=/ServerStatus/server/config.json --web-dir=/usr/share/nginx/html'