diff --git a/.jenkins/.env.yml b/.jenkins/.env.yml new file mode 100644 index 0000000..a7e7425 --- /dev/null +++ b/.jenkins/.env.yml @@ -0,0 +1,16 @@ +masterProfiles: ['','uat','prod'] +Profiles: ['','dev'] +jobConfigFile: "djangoadminConfig.yml" +npmCompileCMD: | + set -e \ + && yarn config set registry https://registry.npmmirror.com \ + && yarn config get registry \ + && yarn config set strict-ssl false \ + && yarn config set sass_binary_site https://repo.huaweicloud.com/node-sass/node-sass \ + && rm -rf node_modules \ + && rm -rf package-lock.json \ + && rm -rf node_modules/.cache 2>/dev/null || true \ + && yarn cache clean --force \ + && yarn global add node-gyp@10.3.1 \ + && yarn install --unsafe-perm --legacy-peer-deps --network-timeout 300000 \ + && yarn run build:${PROFILE} \ No newline at end of file diff --git a/.jenkins/Dockerfile b/.jenkins/Dockerfile new file mode 100644 index 0000000..e84d5eb --- /dev/null +++ b/.jenkins/Dockerfile @@ -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"] \ No newline at end of file diff --git a/.jenkins/Jenkinsfile b/.jenkins/Jenkinsfile new file mode 100644 index 0000000..8129435 --- /dev/null +++ b/.jenkins/Jenkinsfile @@ -0,0 +1,3 @@ +@Library('share-library@master')_ +orgName = 'djangoadmin' +pipelinePythonService(orgName) \ No newline at end of file