From 15234f32b495edc50590e0fd01c28ce09978f281 Mon Sep 17 00:00:00 2001 From: lz-wang Date: Sun, 4 Sep 2022 11:37:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=20Python=203.10=20+=20Cloud=20Center?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 21 +++++++++-- cloud-center/Dockerfile | 70 +++++++++++++++++++++++++++++++++++ cloud-center/requirements.txt | 16 ++++++++ 3 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 cloud-center/Dockerfile create mode 100644 cloud-center/requirements.txt diff --git a/.drone.yml b/.drone.yml index dec6b68..77f8ef2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,7 +1,7 @@ --- kind: pipeline type: ssh -name: 自动构建Python3.10镜像 +name: 自动构建Docker镜像 server: host: @@ -21,7 +21,8 @@ steps: commands: - docker ps - docker images - - name: Build Docker Image + + - name: Build Python 3.10 environment: USERNAME: from_secret: docker_hub_username @@ -29,6 +30,18 @@ steps: from_secret: docker_hub_token commands: - echo $USERNAME - - docker build . -t lzwang/python3.10:nightly -f ./python3.10/Dockerfile + - docker build . -t $USERNAME/python3.10:nightly -f ./python3.10/Dockerfile - docker login -u $USERNAME -p $TOKEN - - docker push lzwang/python3.10:nightly + - docker push $USERNAME/python3.10:nightly + + - name: Build CloudCenter + environment: + USERNAME: + from_secret: docker_hub_username + TOKEN: + from_secret: docker_hub_token + commands: + - echo $USERNAME + - docker build . -t $USERNAME/cloud-center:nightly -f ./cloud-center/Dockerfile + - docker login -u $USERNAME -p $TOKEN + - docker push $USERNAME/cloud-center:nightly diff --git a/cloud-center/Dockerfile b/cloud-center/Dockerfile new file mode 100644 index 0000000..95663b0 --- /dev/null +++ b/cloud-center/Dockerfile @@ -0,0 +1,70 @@ +FROM python:3 + +# image info +LABEL Project="CloudCenter" +LABEL Author="lzwang" +LABEL Email="zhuangwang82@gmail.com" +LABEL Version=0.2 + +# setup volume +VOLUME /project + +# setup workdir +WORKDIR /project + +# setup mirrors of apt +# https://mirrors.tuna.tsinghua.edu.cn/help/debian/ +RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free" > /etc/apt/sources.list \ + && echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free" >> /etc/apt/sources.list \ + && echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free" >> /etc/apt/sources.list \ + && echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list + +# update apt packages +RUN apt-get update -y && apt-get upgrade -y \ + && apt-get install apt-utils -y \ + && rm -rf /var/lib/apt/lists/* + +# install nodejs +# https://github.com/nodesource/distributions/blob/master/README.md#debinstall +RUN DEBIAN_FRONTEND=noninteractive \ + && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ + && apt-get install -y nodejs \ + && rm -rf /var/lib/apt/lists/* + +# setup nodejs +RUN npm install -g cnpm --registry=https://registry.npm.taobao.org \ + && echo "alias npm=cnpm" >> /root/.bashrc \ + && npm config set registry https://registry.npm.taobao.org + +# copy gitsh script +COPY ./gitsh /project/tools/gitsh +RUN chmod +x /project/tools/gitsh + +# setup mirrors of pip +# https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ +RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple + +# python pip install dependencies +COPY ./requirements.txt /project/requirements.txt + +# redis must > 4.0 (ignore slowapi requirement) +RUN pip install --no-cache-dir --upgrade pip \ + && pip install --no-cache-dir -r requirements.txt \ + && pip install --no-cache-dir redis==4.3.4 \ + && rm -rf /root/.cache \ + && rm -rf /tmp/* + +# install packages +RUN apt-get update -y && apt-get upgrade -y \ + && apt-get install vim pngquant -y \ + && rm -rf /var/lib/apt/lists/* + +# setup alias +RUN echo "alias ll='ls -la'" >> /root/.bashrc + +# setup timezone +RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && date + +# on start up +CMD ["python3", "/project/CloudCenter/main.py"] diff --git a/cloud-center/requirements.txt b/cloud-center/requirements.txt new file mode 100644 index 0000000..d89b433 --- /dev/null +++ b/cloud-center/requirements.txt @@ -0,0 +1,16 @@ +chardet>=4.0.0 +cos-python-sdk-v5>=1.9.15 +fastapi>=0.75.1 +gitpython>=3.1.27 +loguru>=0.6.0 +matplotlib>=3.5.2 +mkdocs>=1.3.0 +mkdocs-material>=8.2.9 +mkdocs-material-extensions>=1.0.3 +pillow>=9.1.0 +pydantic>=1.9.0 +python-dateutil>=2.8.2 +pyyaml>=6.0 +requests>=2.28.0 +slowapi>=0.1.5 +uvicorn>=0.17.6