From 21183245d02a071752efe903b048583bcc584c60 Mon Sep 17 00:00:00 2001 From: LarsonLian <1808762134@qq.com> Date: Mon, 26 Feb 2024 21:15:04 +0800 Subject: [PATCH 1/4] Add GitHub Actions workflow --- .github/workflows/docker-image-ai-core.yml | 61 +++++++++++++++++ .github/workflows/docker-image-api.yml | 61 +++++++++++++++++ .github/workflows/docker-image-web.yml | 78 ++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 .github/workflows/docker-image-ai-core.yml create mode 100644 .github/workflows/docker-image-api.yml create mode 100644 .github/workflows/docker-image-web.yml diff --git a/.github/workflows/docker-image-ai-core.yml b/.github/workflows/docker-image-ai-core.yml new file mode 100644 index 0000000..af438c1 --- /dev/null +++ b/.github/workflows/docker-image-ai-core.yml @@ -0,0 +1,61 @@ +name: AI Core Docker Image CI + +on: + push: + paths: + - 'backend/ai-service/**' + branches: + - 'main' + release: + types: [ published ] + +env: + IMAGE_NAME: 'samepaage/samepage-ai-core' + DOCKERFILE: './backend/ai-service/Dockerfile' + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} + type=ref,event=branch + type=sha,enable=true,priority=100,prefix=,suffix=,format=long + type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + file: ${{ env.DOCKERFILE }} + platforms: | + linux/amd64 + linux/arm64 + build-args: | + COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/docker-image-api.yml b/.github/workflows/docker-image-api.yml new file mode 100644 index 0000000..fbb0c0a --- /dev/null +++ b/.github/workflows/docker-image-api.yml @@ -0,0 +1,61 @@ +name: Api Docker Image CI + +on: + push: + paths: + - 'backend/management-service/**' + branches: + - 'main' + release: + types: [ published ] + +env: + IMAGE_NAME: 'samepaage/samepage-api' + DOCKERFILE: './backend/management-service/Dockerfile' + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} + type=ref,event=branch + type=sha,enable=true,priority=100,prefix=,suffix=,format=long + type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + file: ${{ env.DOCKERFILE }} + platforms: | + linux/amd64 + linux/arm64 + build-args: | + COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/docker-image-web.yml b/.github/workflows/docker-image-web.yml new file mode 100644 index 0000000..eab7898 --- /dev/null +++ b/.github/workflows/docker-image-web.yml @@ -0,0 +1,78 @@ +name: Web Docker Image CI + +on: + push: + paths: + - 'frontend/**' + branches: + - 'main' + release: + types: [ published ] + +env: + IMAGE_NAME: 'samepaage/samepage-web' + DOCKERFILE: './frontend/Dockerfile' + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} + type=ref,event=branch + type=sha,enable=true,priority=100,prefix=,suffix=,format=long + type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }} + - name: set Node.js + uses: actions/setup-node@v4 + with: + node-version: '16.14' + - name: build web + run: | + cd ./frontend + npm install -g pnpm + pnpm install --no-frozen-lockfile + pnpm nx run login:build + pnpm nx run web:build + pnpm nx run doc-chat:build + pnpm nx run h5:build + pnpm nx run playground:build + pnpm nx run scripts:build + cd .. + + - name: Build and push + uses: docker/build-push-action@v5 + with: + content: ./ + file: ${{ env.DOCKERFILE }} + platforms: | + linux/amd64 + linux/arm64 + build-args: | + COMMIT_SHA=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + context: . + cache-from: type=gha + cache-to: type=gha,mode=max From 9ba244f227cd27b7d923f3d3c122f3182ad1203e Mon Sep 17 00:00:00 2001 From: LarsonLian <1808762134@qq.com> Date: Mon, 26 Feb 2024 21:18:07 +0800 Subject: [PATCH 2/4] fix(Service initialization exception): --- .../ai/samepage/service/impl/AssistantConvMsgTaskService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/management-service/src/main/java/ai/samepage/service/impl/AssistantConvMsgTaskService.java b/backend/management-service/src/main/java/ai/samepage/service/impl/AssistantConvMsgTaskService.java index 7b1f05d..fa67345 100644 --- a/backend/management-service/src/main/java/ai/samepage/service/impl/AssistantConvMsgTaskService.java +++ b/backend/management-service/src/main/java/ai/samepage/service/impl/AssistantConvMsgTaskService.java @@ -254,7 +254,6 @@ */ @Service("assistant_chat") @Slf4j -@ConditionalOnBean(LlmGatewayService.class) public class AssistantConvMsgTaskService implements ConvMsgTaskService { From 2c25520b47250e0eebff694a8146b9d0694b446a Mon Sep 17 00:00:00 2001 From: LarsonLian <1808762134@qq.com> Date: Mon, 26 Feb 2024 21:24:39 +0800 Subject: [PATCH 3/4] Add project .gitignore --- backend/ai-service/.gitignore | 130 +++++++++++++++++++++++++- backend/management-service/.gitignore | 23 +++++ 2 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 backend/management-service/.gitignore diff --git a/backend/ai-service/.gitignore b/backend/ai-service/.gitignore index b243b8b..9803c29 100644 --- a/backend/ai-service/.gitignore +++ b/backend/ai-service/.gitignore @@ -1,10 +1,136 @@ +# Byte-compiled / optimized / DLL files __pycache__/ +*.py[cod] +*$py.class -log/ +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: *.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version -#.env +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# Ignore Visual Studio Code settings +.vscode/ *.bak/ *.bak diff --git a/backend/management-service/.gitignore b/backend/management-service/.gitignore new file mode 100644 index 0000000..1172b5d --- /dev/null +++ b/backend/management-service/.gitignore @@ -0,0 +1,23 @@ +# Compiled class files +*.class + +# Log files +*.log + +# IntelliJ IDEA files +.idea/ + +# Eclipse files +.classpath +.project +.settings/ + +# Maven files +target/ + +# Gradle files +build/ + +# Operating System files +.DS_Store +Thumbs.db From 9e256fb0dcde8a38150df2295f9b9d3e294aa649 Mon Sep 17 00:00:00 2001 From: LarsonLian <1808762134@qq.com> Date: Tue, 27 Feb 2024 14:20:51 +0800 Subject: [PATCH 4/4] Update docker-compose.yml --- deploy/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index ee595d4..974cc19 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -120,7 +120,7 @@ services: one-api: condition: service_healthy ai-service-worker: - image: samepaage/ai-service:main + image: samepaage/samepage-ai-core:main container_name: ai-service-worker restart: always networks: