-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
4,737 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Build fastgpt-sandbox images and copy image to docker hub | ||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- 'projects/sandbox/**' | ||
tags: | ||
- 'v*' | ||
jobs: | ||
build-fastgpt-sandbox-images: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install Dependencies | ||
run: | | ||
sudo apt update && sudo apt install -y nodejs npm | ||
- name: Set up QEMU (optional) | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
driver-opts: network=host | ||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GH_PAT }} | ||
- name: Set DOCKER_REPO_TAGGED based on branch or tag | ||
run: | | ||
if [[ "${{ github.ref_name }}" == "main" ]]; then | ||
echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt-sandbox:latest" >> $GITHUB_ENV | ||
else | ||
echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt-sandbox:${{ github.ref_name }}" >> $GITHUB_ENV | ||
fi | ||
- name: Build and publish image for main branch or tag push event | ||
env: | ||
DOCKER_REPO_TAGGED: ${{ env.DOCKER_REPO_TAGGED }} | ||
run: | | ||
docker buildx build \ | ||
-f projects/sandbox/Dockerfile \ | ||
--platform linux/amd64,linux/arm64 \ | ||
--label "org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/fastgpt-sandbox" \ | ||
--label "org.opencontainers.image.description=fastgpt-sandbox image" \ | ||
--push \ | ||
--cache-from=type=local,src=/tmp/.buildx-cache \ | ||
--cache-to=type=local,dest=/tmp/.buildx-cache \ | ||
-t ${DOCKER_REPO_TAGGED} \ | ||
. | ||
push-to-ali-hub: | ||
needs: build-fastgpt-sandbox-images | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Login to Ali Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: registry.cn-hangzhou.aliyuncs.com | ||
username: ${{ secrets.ALI_HUB_USERNAME }} | ||
password: ${{ secrets.ALI_HUB_PASSWORD }} | ||
- name: Set DOCKER_REPO_TAGGED based on branch or tag | ||
run: | | ||
if [[ "${{ github.ref_name }}" == "main" ]]; then | ||
echo "IMAGE_TAG=latest" >> $GITHUB_ENV | ||
else | ||
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV | ||
fi | ||
- name: Pull image from GitHub Container Registry | ||
run: docker pull ghcr.io/${{ github.repository_owner }}/fastgpt-sandbox:${{env.IMAGE_TAG}} | ||
- name: Tag image with Docker Hub repository name and version tag | ||
run: docker tag ghcr.io/${{ github.repository_owner }}/fastgpt-sandbox:${{env.IMAGE_TAG}} ${{ secrets.ALI_IMAGE_NAME }}/fastgpt-sandbox:${{env.IMAGE_TAG}} | ||
- name: Push image to Docker Hub | ||
run: docker push ${{ secrets.ALI_IMAGE_NAME }}/fastgpt-sandbox:${{env.IMAGE_TAG}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 定义默认变量 | ||
proxy=null | ||
image=null | ||
|
||
# 定义目标 | ||
.PHONY: build | ||
|
||
# 检查 target 是否定义 | ||
ifndef name | ||
$(error name is not defined) | ||
endif | ||
|
||
filePath=./projects/$(name)/Dockerfile | ||
|
||
dev: | ||
pnpm --prefix ./projects/$(name) dev | ||
|
||
build: | ||
ifeq ($(proxy), taobao) | ||
docker build -f $(filePath) -t $(image) . --build-arg proxy=taobao | ||
else ifeq ($(proxy), clash) | ||
docker build -f $(filePath) -t $(image) . --network host --build-arg HTTP_PROXY=http://127.0.0.1:7890 --build-arg HTTPS_PROXY=http://127.0.0.1:7890 | ||
else | ||
docker build -f $(filePath) -t $(image) . | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,40 @@ | ||
# 打包命令 | ||
## Premise | ||
|
||
Since FastGPT is managed in the same way as monorepo, it is recommended to install 'make' first during development. | ||
|
||
monorepo Project Name: | ||
|
||
- app: main project | ||
-...... | ||
|
||
## Dev | ||
|
||
```sh | ||
# Build image, not proxy | ||
docker build -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.4.7 --build-arg name=app . | ||
# Give automatic script code execution permission (on non-Linux systems, you can manually execute the postinstall.sh file content) | ||
chmod -R +x ./scripts/ | ||
# Executing under the code root directory installs all dependencies within the root package, projects, and packages | ||
pnpm i | ||
|
||
# Not make cmd | ||
cd projects/app | ||
pnpm dev | ||
|
||
# build image with proxy | ||
docker build -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.4.7 --build-arg name=app --build-arg proxy=taobao . | ||
# Make cmd | ||
make dev name=app | ||
``` | ||
|
||
# Pg 常用索引 | ||
|
||
```sql | ||
CREATE INDEX IF NOT EXISTS modelData_dataset_id_index ON modeldata (dataset_id); | ||
CREATE INDEX IF NOT EXISTS modelData_collection_id_index ON modeldata (collection_id); | ||
CREATE INDEX IF NOT EXISTS modelData_teamId_index ON modeldata (team_id); | ||
``` | ||
## Build | ||
|
||
```sh | ||
# Docker cmd: Build image, not proxy | ||
docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 . --build-arg name=app | ||
# Make cmd: Build image, not proxy | ||
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 | ||
|
||
# Docker cmd: Build image with proxy | ||
docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 . --build-arg name=app --build-arg proxy=taobao | ||
# Make cmd: Build image with proxy | ||
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 proxy=taobao | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/global/core/workflow/template/system/sandbox/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const JS_TEMPLATE = `function main({data1, data2}){ | ||
return { | ||
result: data1, | ||
data2 | ||
} | ||
}`; |
Oops, something went wrong.