Skip to content

Commit

Permalink
Merge branch 'v2.0.16'
Browse files Browse the repository at this point in the history
  • Loading branch information
blackholll committed Apr 5, 2023
2 parents 33957b1 + 350db23 commit 2211eb3
Show file tree
Hide file tree
Showing 39 changed files with 1,926 additions and 386 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/image_build_base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build Base Image
on:
push:
branches:
- 'update_base_image**'
jobs:
build_base:
name: Build Base
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Get current date
id: date
run: echo "::set-output name=today::$(date +'%Y-%m-%d')"
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: docker_compose_deploy/loonflow-base/Dockerfile
platforms: linux/amd64
push: true
tags: blackholll/loonflow-base:latest,blackholll/loonflow-base:${{ steps.date.outputs.today }}
34 changes: 34 additions & 0 deletions .github/workflows/image_build_task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Task Image
on:
push:
tags:
- 'r**'
jobs:
build_task:
name: Build Task
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: docker_compose_deploy/loonflow-task/Dockerfile
platforms: linux/amd64
push: true
tags: blackholll/loonflow-task:latest,blackholll/loonflow-task:${{ github.ref_name }}
34 changes: 34 additions & 0 deletions .github/workflows/image_build_web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Web Image
on:
push:
tags:
- 'r**'
jobs:
build_web:
name: Build Web
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: docker_compose_deploy/loonflow-web/Dockerfile
platforms: linux/amd64
push: true
tags: blackholll/loonflow-web:latest,blackholll/loonflow-web:${{ github.ref_name }}
12 changes: 6 additions & 6 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ name: Unit test CI

on:
push:
branchs: [ v1.1.0 ]
tags:
- r**
pull_request:
branchs: [ v1.1.0 ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [ 3.6 ]
python-version: [ "3.10" ]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.6
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ qq群的目的:
- 加微信好友,微信答疑
- 两次线上会议(半小时内)答疑
- 提出的合理通用新需求,优先支持
<<<<<<< HEAD
=======

>>>>>>> v2.0.16
## 基本架构
LOONFLOW 分为两部分:
Expand Down
12 changes: 5 additions & 7 deletions apps/ticket/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ def get(self, request, *args, **kwargs):
# app_name
app_name = request.META.get('HTTP_APPNAME')

# 未指定创建起止时间则取最近一年的记录
# 未指定创建起止时间则取最近三年的记录
if not(create_start or create_end):
import datetime
now = datetime.datetime.now()
now_str = str(now)[:19]
last_year_time = '%4d%s' % (now.year-1, now_str[4:])
datetime.datetime.now() - datetime.timedelta(days=365)
create_start = last_year_time
create_end = now_str
end_time = datetime.datetime.now() + datetime.timedelta(hours=1)
last_year_time = datetime.datetime.now() - datetime.timedelta(days=365*3)
create_start = str(last_year_time)[:19]
create_end = str(end_time)[:19]

flag, result = ticket_base_service_ins.get_ticket_list(
sn=sn, title=title, username=username, create_start=create_start, create_end=create_end,
Expand Down
8 changes: 4 additions & 4 deletions apps/workflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Workflow(BaseModel):

class WorkflowAdmin(BaseModel):
"""
工作流管理员
工作流管理员, 该model已经废弃, 当前使用的是WorkflowUserPermission
"""
workflow = models.ForeignKey(Workflow, to_field='id', db_constraint=False, on_delete=models.DO_NOTHING)
username = models.CharField('管理员', max_length=100, help_text='除超级管理员及该工作流创建人外,管理人员也可以直接编辑该工作流')
Expand Down Expand Up @@ -83,7 +83,7 @@ class CustomField(BaseModel):

def upload_workflow_script(instance, filename):
"""
因为脚本中可能会存在一些私密信息,如账号密码等,所以重命名文件,避免可以直接下载此文件
因为脚本中可能会存在一些私密信息,如账号密码等,所以重命名文件,避免可以直接下载此文件。已经废弃,不再支持脚本方式的notice,请使用hook
:param instance:
:param filename:
:return:
Expand All @@ -98,7 +98,7 @@ def upload_workflow_script(instance, filename):

class WorkflowScript(BaseModel):
"""
流程中执行的脚本
流程中执行的脚本, 已经废弃,不再支持脚本方式的notice,请使用hook
"""
name = models.CharField('名称', max_length=50)
saved_name = models.FileField('存储的文件名', upload_to=upload_workflow_script, help_text='请上传python脚本,media/workflow_script/demo_script.py为示例脚本,请参考编写')
Expand All @@ -108,7 +108,7 @@ class WorkflowScript(BaseModel):

def upload_notice_script(instance, filename):
"""
因为通知脚本中可能会存在一些私密信息,如账号密码等,所以重命名文件,避免可以直接下载此文件
因为通知脚本中可能会存在一些私密信息,如账号密码等,所以重命名文件,避免可以直接下载此文件。 已经废弃,不再支持脚本方式的notice,请使用hook
:param instance:
:param filename:
:return:
Expand Down
59 changes: 33 additions & 26 deletions docker_compose_deploy/README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,51 @@

为了方便的数据的持久化以及升级操作,本部署方案需要使用外部数据库(mysql),请事先准备好数据库


# 准备工作
- 准备一台linux系统(建议centos7)的服务器,需要4G以上内存(因为编译前端比较需要内存)
- 准备一台linux系统(建议centos7)的服务器,建议4G以上内存
- 安装好python3(请自行百度或者google)
- 安装好docker-compose(请自行百度或者google)
- 配置容器镜像加速(请自行百度或者google)
- 准备好数据库,并授予权限

# 部署及启动服务
## 使用容器mysql
```
# 启动服务
cd docker_compose_deploy
docker compose -f docker-compse.yml up -d
# 停止服务
docker compose -f docker-compse.yml stop
```

## 使用自己的mysql

```
# 进入mysql后创建数据库并授权
mysql> create database loonflow character set utf8mb4; # 注意要使用utf8mb4字符集
mysql> grant all privileges on loonflow.* to loonflow@'%' identified by '123456';
```
- 修改run.py中相关配置
```
db_host = '' # loonflow使用的数据库的ip
db_port = '' # loonflow使用的数据库的端口
db_name = '' # loonflow使用的数据库的名称
db_user = '' # loonflow使用的数据库的用户
db_password = '' # loonflow使用的数据库的用户密码
# 移除及更新docker-compose.yml中mysql相关配置
移除loonflow-mysql服务
移除loonflow-task和loonflow-web服务中depends_on的oonflow-mysql
修改loonflow-task和loonflow-web服务中的mysql地址、用户、密码
ddl_db_user = '' # 可以执行ddl(拥有修改表结构权限)的用户
ddl_db_password = '' # 可以执行ddl(拥有修改表结构权限)的用户的密码
# 启动服务
cd docker_compose_deploy
docker compose -f docker-compse.yml up -d
# 停止服务
docker compose -f docker-compse.yml stop
```

# 常见问题
- 如何修改mysql的密码

#### 启动方式
cd 到 docker_compose_deploy目录后,执行以下命令
容器mysql服务的root密码:docker_compose_deploy/docker-compose.yml中MYSQL_ROOT_PASSWORD(需要第一次启动服务之前修改)

```
# 安装并启动服务
python3 run.py install # 此命令后修改dockerfile中的数据库配置,然后启动
容器mysql服务loonflow的密码: docker_compose_deploy/loonflow-mysql/init/create_database.sql(需要第一次启动服务之前修改)

# 启动服务
python3 run.py start # 此命令直接启动服务,请保证之前install过(也就是dockerfile中数据库配置已被修改)
- 如何修改redis的密码

# 停止服务, 这种方式对于celery task任务非优雅停止,可以使用flower(celery的监控系统),将任务消费停止,并且等待所有任务都结束后再执行
python3 run.py stop
```
docker_compose_deploy/docker-compose.yml中loonflow-redis中requirepass及其他服务环境变量中的密码

- 支持ARM架构下docker方式启动么

开发环境直参考https://loonflow.readthedocs.io 直接启动. 生成环境别折腾了,找个linux服务器吧
44 changes: 35 additions & 9 deletions docker_compose_deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,57 @@ services:
- 6379:6379
command:
redis-server --requirepass loonflow123

loonflow-mysql:
hostname: loonflow-mysql
image: mysql:5.7
volumes:
- ./loonflow-mysql/data:/var/lib/mysql
- ./loonflow-mysql/conf/my.cnf:/etc/my.cnf
- ./loonflow-mysql/init:/docker-entrypoint-initdb.d
restart: always
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: 327%aXtaz*z&
secure_file_priv:

loonflow-web:
hostname: loonflow-web
build:
context: ../
dockerfile: docker_compose_deploy/loonflow-web/Dockerfile
image: blackholll/loonflow-web:latest
depends_on:
- loonflow-redis
- loonflow-mysql
ports:
- 80:80
environment:
DB_HOST: loonflow-mysql
DB_USER: loonflow
DB_PASS: 2Nir9D6&muYq
REDIS_HOST: loonflow-redis
REDIS_PASS: loonflow123
command:
- /bin/sh
- -c
- |
/opt/venv/loonflow/bin/uwsgi /opt/loonflow/uwsgi.ini
nginx -c /etc/nginx/nginx.conf -g "daemon off;"
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf -g "daemon off;"
loonflow-task:
hostname: loonflow-task
build:
context: ../
dockerfile: docker_compose_deploy/loonflow-task/Dockerfile
image: blackholll/loonflow-task:latest
depends_on:
- loonflow-redis
- loonflow-mysql
environment:
DB_NAME: loonflow
DB_HOST: loonflow-mysql
DB_USER: loonflow
DB_PASS: 2Nir9D6&muYq
REDIS_HOST: loonflow-redis
REDIS_PASS: loonflow123
command:
- /bin/sh
- -c
- |
cd /opt/loonflow
celery -A tasks worker -l info -c 8 -Q loonflow
/opt/venv/loonflow/bin/celery -A tasks worker -l info -c 8 -Q loonflow
35 changes: 35 additions & 0 deletions docker_compose_deploy/loonflow-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM centos:7
LABEL [email protected]

RUN mkdir -p /var/log/loonflow & \
yum install -y wget make mysql-devel gcc gcc-devel python3-devel mysql-devel zlib-devel openssl-devel git automake libtool libffi-devel

WORKDIR /tmp

RUN wget http://www.openssl.org/source/openssl-1.1.1q.tar.gz --no-check-certificate
RUN tar -zxvf openssl-1.1.1q.tar.gz
RUN cd openssl-1.1.1q && ./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl \
&& make && make install \
&& echo "/usr/local/lib64/" >> /etc/ld.so.conf \
&& echo "/usr/local/openssl/lib" >> /etc/ld.so.conf \
&& ldconfig \
&& ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl \
&& ln -s /usr/local/openssl/include/openssl /usr/include/openssl


RUN wget https://www.python.org/ftp/python/3.10.9/Python-3.10.9.tgz
RUN tar zxvf Python-3.10.9.tgz
RUN cd Python-3.10.9 && ./configure --with-openssl=/usr/local/openssl --enable-optimizations && make altinstall


RUN wget http://nginx.org/download/nginx-1.22.1.tar.gz --no-check-certificate
RUN tar zxvf nginx-1.22.1.tar.gz
RUN sed -i "s/\/.openssl//g" /tmp/nginx-1.22.1/auto/lib/openssl/conf
RUN cd nginx-1.22.1 && ./configure --with-openssl=/usr/local/openssl --with-http_stub_status_module --with-http_ssl_module && make && make install

WORKDIR /opt
RUN wget -c https://nodejs.org/download/release/v14.3.0/node-v14.3.0-linux-x64.tar.xz --no-check-certificate
RUN tar -xvf node-v14.3.0-linux-x64.tar.xz
RUN mv node-v14.3.0-linux-x64 nodejs
RUN ln -s /opt/nodejs/bin/node /usr/local/bin/node
RUN ln -s /opt/nodejs/bin/npm /usr/local/bin/npm
Loading

0 comments on commit 2211eb3

Please sign in to comment.