From 381b8857ec1e45efae4a252bf52539d4e31ce3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=9D=E5=B7=9D?= Date: Wed, 1 Dec 2021 01:24:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E7=BB=B4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 14 ++++++++++++++ Dockerfile | 6 ++++++ gunicorn.conf.py | 8 ++++++++ setting.py | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile create mode 100644 gunicorn.conf.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..99969cd --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,14 @@ +stages: + - deploy + +job: + stage: deploy + script: +# - docker stop tfse_app_api +# - docker rm tfse_app_api + - docker build -t tfse_app_api . + - docker run -d -p 51020:51020 --name tfse_app_api -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro tfse_app_api + only: + - master + tags: + - tfse_app_api diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6546e0f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.8 +WORKDIR /usr/src/app/tfse_app_api +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.mirrors.ustc.edu.cn/simple +COPY . . +CMD ["gunicorn", "app:app", "-c", "./gunicorn.conf.py"] diff --git a/gunicorn.conf.py b/gunicorn.conf.py new file mode 100644 index 0000000..5e52a68 --- /dev/null +++ b/gunicorn.conf.py @@ -0,0 +1,8 @@ +from setting import APP_PORT + +# 并行工作进程数 +workers = 10 +# 监听内网端口 +bind = '0.0.0.0:{}'.format(APP_PORT) +# 工作模式协程 +worker_class = 'gevent' diff --git a/setting.py b/setting.py index 8a6aabd..ce69fb9 100644 --- a/setting.py +++ b/setting.py @@ -1,3 +1,3 @@ # 应用配置 APP_NAME = 'tfse_app_api' -APP_PORT = '' +APP_PORT = 51020