新增CI/CD脚本

This commit is contained in:
2026-09-11 11:44:09 +08:00
parent c381201858
commit 6ad0c9530d
3 changed files with 79 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
# 基础镜像地址
ARG VAR_BASE_IMAGE
# 基础镜像
FROM ${VAR_BASE_IMAGE}
# 镜像作者
LABEL MAINTAINER="djangoadmin@163.com"
# 设置 python 环境变量
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
# 环境变量参数
ARG VAR_PROFILES
# 端口参数
ARG VAR_PORT
# 文件参数
ARG VAR_PYFILE
# 文件地址
ARG VAR_PYFILE_PATH
# 设置端口
ENV PORT=${VAR_PORT}
# 设置文件包名
ENV PYFILE=${VAR_PYFILE}
# 设置环境变量
ENV PROFILES=${VAR_PROFILES}
# 安装必要的软件包
RUN yum install -y yum-utils net-tools && \
yum install -y gcc gcc-c++ make cmake openssl-devel bzip2-devel libffi-devel mysql-devel
# 更新pip
RUN pip3 install -U pip
# 设置国内镜像源
RUN pip3 config set global.index-url http://mirrors.aliyun.com/pypi/simple
RUN pip3 config set install.trusted-host mirrors.aliyun.com
# 升级pip版本
RUN python3 -m pip install --upgrade pip
# 安装工具
RUN pip3 install --upgrade setuptools wheel
RUN pip3 install ez_setup
# 创建工作区
RUN mkdir -p /opt/apps
# 设置工作区
WORKDIR /opt/apps
# 拷贝文件
COPY ${VAR_PYFILE_PATH} ./
# 安装依赖
RUN pip install -r requirements.txt
RUN pip install uwsgi
# 暴露端口
EXPOSE ${PORT}
# 执行启动项目
CMD ["sh", "-c", "python3 ${PYFILE}.py runserver 0.0.0.0:${PORT} --noreload"]