mirror of
https://github.com/dataelement/bisheng.git
synced 2026-09-24 23:19:52 +08:00
ci: add backend base image
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
name: BASE_CI
|
||||
|
||||
on:
|
||||
push:
|
||||
# Sequence of patterns matched against refs/tags
|
||||
tags:
|
||||
- "base.v*"
|
||||
|
||||
env:
|
||||
DOCKERHUB_REPO: dataelement/
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build_bisheng:
|
||||
runs-on: ubuntu-latest
|
||||
# if: startsWith(github.event.ref, 'refs/tags')
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: |
|
||||
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
||||
|
||||
- name: Set Environment Variable
|
||||
run: echo "RELEASE_VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
|
||||
|
||||
# 登录 docker hub
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
|
||||
# DOCKERHUB_USERNAME 是 docker hub 账号名.
|
||||
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# - name: Login to DockerHub
|
||||
# uses: docker/login-action@v1
|
||||
# with:
|
||||
# registry: https://cr.dataelem.com/
|
||||
# username: ${{ secrets.CR_DOCKERHUB_USERNAME }}
|
||||
# password: ${{ secrets.CR_DOCKERHUB_TOKEN }}
|
||||
|
||||
# 构建 backend 并推送到 Docker hub
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: install poetry
|
||||
uses: snok/install-poetry@v1
|
||||
with:
|
||||
installer-parallel: true
|
||||
|
||||
- name: Build backend and push
|
||||
id: docker_build_backend
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
# backend 的context目录
|
||||
context: "./src/backend/"
|
||||
# 是否 docker push
|
||||
push: true
|
||||
# docker build arg, 注入 APP_NAME/APP_VERSION
|
||||
platforms: linux/amd64,linux/arm64
|
||||
build-args: |
|
||||
APP_NAME="bisheng-backend"
|
||||
APP_VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||
# 生成两个 docker tag: ${APP_VERSION} 和 latest
|
||||
tags: |
|
||||
${{ env.DOCKERHUB_REPO }}bisheng-backend:${{ steps.get_version.outputs.VERSION }}
|
||||
# 构建 Docker frontend 并推送到 Docker hub
|
||||
- name: Process git message
|
||||
id: process_message
|
||||
run: |
|
||||
value=$(echo "${{ github.event.head_commit.message }}" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/%0A/g')
|
||||
value=$(echo "${value}" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\r/%0A/g')
|
||||
echo "message=${value}" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: notify feishu
|
||||
uses: fjogeleit/http-request-action@v1
|
||||
with:
|
||||
url: ${{ secrets.FEISHU_WEBHOOK }}
|
||||
method: 'POST'
|
||||
data: '{"msg_type":"post","content":{"post":{"zh_cn":{"title": "${{ steps.get_version.outputs.VERSION }}发布成功", "content": [[{"tag":"text","text":"基础镜像"},{"tag":"text","text":"${{ env.message }}"}]]}}}}'
|
||||
+2
-36
@@ -1,42 +1,8 @@
|
||||
FROM python:3.10-slim
|
||||
FROM dataelement/bisheng-backend:base.v1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN echo \
|
||||
deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib \
|
||||
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib \
|
||||
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main \
|
||||
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main \
|
||||
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib \
|
||||
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib \
|
||||
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib \
|
||||
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib \
|
||||
> /etc/apt/sources.list
|
||||
|
||||
|
||||
# Install Poetry
|
||||
RUN apt-get update && apt-get install gcc g++ curl build-essential postgresql-server-dev-all -y
|
||||
RUN apt-get update && apt-get install procps -y
|
||||
# Install font
|
||||
RUN apt install vim fonts-wqy-zenhei -y
|
||||
# opencv
|
||||
RUN apt-get update && apt-get install -y libglib2.0-0 libsm6 libxrender1 libxext6 libgl1
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.8.2
|
||||
# # Add Poetry to PATH
|
||||
ENV PATH="${PATH}:/root/.local/bin"
|
||||
# # Copy the pyproject.toml and poetry.lock files
|
||||
# COPY poetry.lock pyproject.toml ./
|
||||
# Copy the rest of the application codes
|
||||
COPY ./ ./
|
||||
|
||||
# Install NLTK data
|
||||
RUN mv -f ./nltk_data /root/nltk_data/
|
||||
|
||||
RUN python -m pip install --upgrade pip && \
|
||||
pip install shapely==2.0.1
|
||||
|
||||
# Install dependencies
|
||||
RUN poetry config virtualenvs.create false
|
||||
RUN poetry install --no-interaction --no-ansi --without dev
|
||||
|
||||
CMD ["uvicorn", "bisheng.main:app", "--workers", "2", "--host", "0.0.0.0", "--port", "7860"]
|
||||
CMD ["sh entrypoint.sh"]
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
FROM python:3.10-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN echo \
|
||||
deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib \
|
||||
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib \
|
||||
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main \
|
||||
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main \
|
||||
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib \
|
||||
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib \
|
||||
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib \
|
||||
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib \
|
||||
> /etc/apt/sources.list
|
||||
|
||||
|
||||
# Install Poetry
|
||||
RUN apt-get update && apt-get install gcc g++ curl build-essential postgresql-server-dev-all -y
|
||||
RUN apt-get update && apt-get install procps -y
|
||||
# Install font
|
||||
RUN apt install vim fonts-wqy-zenhei -y
|
||||
# opencv
|
||||
RUN apt-get update && apt-get install -y libglib2.0-0 libsm6 libxrender1 libxext6 libgl1
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.8.2
|
||||
# # Add Poetry to PATH
|
||||
ENV PATH="${PATH}:/root/.local/bin"
|
||||
# # Copy the pyproject.toml and poetry.lock files
|
||||
# COPY poetry.lock pyproject.toml ./
|
||||
# Copy the rest of the application codes
|
||||
COPY ./pyproject.toml ./
|
||||
|
||||
RUN python -m pip install --upgrade pip && \
|
||||
pip install shapely==2.0.1
|
||||
|
||||
# Install dependencies
|
||||
RUN poetry config virtualenvs.create false
|
||||
RUN poetry install --no-interaction --no-ansi --without dev
|
||||
|
||||
# install nltk_data
|
||||
RUN python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab'); nltk.download('averaged_perceptron_tagger'); nltk.download('averaged_perceptron_tagger_eng'); "
|
||||
|
||||
CMD ["sh entrypoint.sh"]
|
||||
@@ -1,23 +0,0 @@
|
||||
import json
|
||||
import os
|
||||
from queue import Queue
|
||||
from typing import Dict
|
||||
|
||||
from bisheng.workflow.callback.base_callback import BaseCallback
|
||||
from bisheng.workflow.graph.workflow import Workflow
|
||||
|
||||
|
||||
def main(workflow_data: Dict = None):
|
||||
base_callback = BaseCallback()
|
||||
input_queue = Queue()
|
||||
|
||||
workflow = Workflow(workflow_id='zgq_1', user_id='1', workflow_data=workflow_data, max_steps=10, timeout=1,
|
||||
callback=base_callback, input_queue=input_queue)
|
||||
print(workflow.run())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(os.getcwd())
|
||||
with open('./workflow_data.json', 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
main(data)
|
||||
Reference in New Issue
Block a user