From 2067cbe6deba34d96d053d33dfa58f6674e1436f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=BD=A6=E6=B3=A2?= Date: Wed, 11 Nov 2020 12:31:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E9=98=B6=E6=AE=B5=E7=BC=96=E8=AF=91?= =?UTF-8?q?=EF=BC=8C=20=E5=BC=95=E5=85=A5pip=20wheels=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=EF=BC=8C=20=E5=88=86=E4=B8=BAbuidler=20?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E5=9F=BA=E7=A1=80=E7=8E=AF=E5=A2=83=EF=BC=8C?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E9=95=9C=E5=83=8F=E4=BB=8Ebuilder=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E6=8B=B7=E8=B4=9D=E4=BA=A7=E7=89=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/Dockerfile/Dockerfile | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/docs/Dockerfile/Dockerfile b/docs/Dockerfile/Dockerfile index 387eaee..b2167ca 100644 --- a/docs/Dockerfile/Dockerfile +++ b/docs/Dockerfile/Dockerfile @@ -2,27 +2,39 @@ # Copyright: (c) # Released under the AGPL-3.0 License. -FROM python:3.6.10-alpine3.11 +FROM python:3.6.10-alpine3.11 as builder RUN echo -e "http://mirrors.aliyun.com/alpine/v3.11/main\nhttp://mirrors.aliyun.com/alpine/v3.11/community" > /etc/apk/repositories -RUN apk update && apk add --no-cache nginx mariadb nodejs-npm git build-base openldap-dev supervisor redis bash -RUN apk add --no-cache --virtual .build-deps openssl-dev gcc musl-dev python3-dev libffi-dev openssh-client make \ +RUN apk update && apk add --no-cache nodejs-npm git build-base openldap-dev supervisor +RUN apk add --no-cache --virtual .build-deps openssl-dev gcc musl-dev python3-dev libffi-dev make \ && mkdir /etc/supervisor.d - -ENV VERSION=2.2.0 RUN git clone https://github.com/openspug/spug.git --depth=1 /spug && cd /spug && git pull -RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && pip install --upgrade pip && pip install --no-cache-dir -r /spug/spug_api/requirements.txt \ - && pip install --no-cache-dir gunicorn \ +RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && pip install --upgrade pip && pip install wheel && pip wheel -r /spug/spug_api/requirements.txt --wheel-dir=/pippacks/wheels \ + && pip wheel gunicorn --wheel-dir=/pippacks/wheels \ && apk del .build-deps +RUN cd /spug/spug_web/ && npm i --registry=https://registry.npm.taobao.org && npm run build -RUN cd /spug/spug_web/ && npm i --registry=https://registry.npm.taobao.org && npm run build \ - && mv /spug/spug_web/build /var/www/ + + +FROM python:3.6.10-alpine3.11 +ENV VERSION=2.2.0 +RUN echo -e "http://mirrors.aliyun.com/alpine/v3.11/main\nhttp://mirrors.aliyun.com/alpine/v3.11/community" > /etc/apk/repositories + +# 这里也是可以优化的地方,有一些软件可以外置,可作为dockerfile参数项决定需不需要build进来 +RUN apk update && apk add --no-cache nginx mariadb supervisor redis bash git openssh-client openldap-dev + +COPY --from=builder /pippacks /pippacks +COPY --from=builder /spug /spug +COPY --from=builder /spug/spug_web/build /var/www/build +RUN cd /spug/spug_api/ && pip install --no-index --find-links=/pippacks/wheels -r requirements.txt && pip install gunicorn --no-index --find-links=/pippacks/wheels + +RUN rm -rf /pippacks ADD spug.ini /etc/supervisor.d/spug.ini ADD default.conf /etc/nginx/conf.d/default.conf ADD entrypoint.sh /entrypoint.sh -ENTRYPOINT ["sh", "/entrypoint.sh"] +ENTRYPOINT ["sh", "/entrypoint.sh"] \ No newline at end of file