From 9dfd84324922f749334ae772efcf31bc3fa30a7d Mon Sep 17 00:00:00 2001 From: booboosui Date: Wed, 16 Aug 2023 16:35:28 +0800 Subject: [PATCH] feat(run): support docker build and run --- .github/workflows/default.yaml | 40 ++++++++++++++++++++++++++++++++++ README.md | 27 ++++++++++++++++++----- build.sh | 20 +++++++++++++++++ docs/DOCUMENT.md | 20 +---------------- docs/README_CN.md | 27 ++++++++++++++++++----- 5 files changed, 103 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/default.yaml create mode 100644 build.sh diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml new file mode 100644 index 00000000..34edb198 --- /dev/null +++ b/.github/workflows/default.yaml @@ -0,0 +1,40 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the "master" branch + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Runs a set of commands using the runners shell + - name: Get pwd + run: | + pwd + ls -alh + - name: Run Docker Build Script + env: + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + DOCKER_REPO: ${{ secrets.DOCKERHUB_REPO }} + run: | + chmod +x build.sh + ./build.sh \ No newline at end of file diff --git a/README.md b/README.md index ac870ae1..3676e5b7 100644 --- a/README.md +++ b/README.md @@ -48,12 +48,27 @@ Through the above introduction and Demo demonstration, you must be curious about ## Quick Start -1. Clone the latest code or select a released version, Python3.7 or later is ready. -2. Generate the configuration file: Copy `env.yaml.tpl` and rename it to `env.yaml`. -3. Modify the configuration file: Edit `env.yaml` and add the necessary information such as GPT Token (refer to [documentation link](docs/DOCUMENT.md) for detailed instructions). -4. Run the service: Execute `sh run.sh` on Linux or Mac, or double-click `run.bat` on Windows. -5. Access the service: Access the service through a browser (check the startup log for the access address, default is http://127.0.0.1:8080). -6. Complete requirement development: Follow the instructions on the page to complete requirement development, and view the generated code in the `./workspace` directory. +1. Run with source code + ``` + 1. Clone the latest code or select a released version, Python3.7 or later is ready. + 2. Generate the configuration file: Copy `env.yaml.tpl` and rename it to `env.yaml`. + 3. Modify the configuration file: Edit `env.yaml` and add the necessary information such as GPT Token (refer to [documentation link](docs/DOCUMENT.md) for detailed instructions). + 4. Run the service: Execute `sh run.sh` on Linux or Mac, or double-click `run.bat` on Windows. + 5. Access the service: Access the service through a browser (check the startup log for the access address, default is http://127.0.0.1:8080). + 6. Complete requirement development: Follow the instructions on the page to complete requirement development, and view the generated code in the `./workspace` directory. + ``` +2. Run with Docker + ```shell + 1. Create a directory: mkdir -p workspace + 2. Copy 'env.yaml.tpl' from the repository to the current directory and rename it to 'env.yaml' + 3. Modify the configuration file: edit 'env.yaml' and add necessary information such as GPT Token. + 4. docker run -it \ + -v$PWD/workspace:/app/workspace \ + -v$PWD/env.yaml:/app/env.yaml \ + -p8080:8080 -p8081:8081 kuafuai/devopsgpt:latest + 5. Access the service: Access the service through a browser (access address provided in the startup log, the default is http://127.0.0.1:8080). + 6. Complete the requirement development: complete the requirement development according to the guidance of the page, and view the generated code in the './workspace 'directory + ``` **For detailed documentation and configuration parameters, please refer to the [documentation link](docs/DOCUMENT.md).** diff --git a/build.sh b/build.sh new file mode 100644 index 00000000..9d86d316 --- /dev/null +++ b/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Get the current commit SHA +COMMIT_SHA=$(git rev-parse HEAD) + +# Get the current date in the format YYYYMMDD +CURRENT_DATE=$(date +%Y%m%d) + +# Construct the new tag +NEW_TAG="${CURRENT_DATE}-${COMMIT_SHA:0:7}" + +# Build the Docker image with the new tag +docker build -t "${DOCKER_REPO}:${NEW_TAG}" -t "${DOCKER_REPO}:latest" -f Dockerfile . + +# Login to Docker Hub +echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + +# Push the Docker image with the new tag +docker push "${DOCKER_REPO}:${NEW_TAG}" +docker push "${DOCKER_REPO}:latest" \ No newline at end of file diff --git a/docs/DOCUMENT.md b/docs/DOCUMENT.md index c0b36485..f498e235 100644 --- a/docs/DOCUMENT.md +++ b/docs/DOCUMENT.md @@ -75,22 +75,4 @@ APPS contains information about the applications you need to develop. The first - setp1Task (used for breaking down tasks). - service.lib: Libraries/packages available for the service. - setpReqChooseLib (analysis of libraries/packages used together). -- service.specification: Specification for using library packages. - -## Docker Build & Run - -1. **Build the Docker Image**: - ``` - docker build . -t devopsgpt - ``` -2. **Setup Workspace**: - ``` - mkdir -p workspace - ``` -3. **Run the Docker Container**: - ``` - docker run -it \ - -v$PWD/workspace:/app/workspace \ - -v$PWD/env.yaml:/app/env.yaml \ - -p8080:8080 -p8081:8081 devopsgpt - ``` +- service.specification: Specification for using library packages. \ No newline at end of file diff --git a/docs/README_CN.md b/docs/README_CN.md index 1bf609bd..9f86db01 100644 --- a/docs/README_CN.md +++ b/docs/README_CN.md @@ -57,12 +57,27 @@ ## 快速开始 -1. 克隆最新代码或选择已发布的版本,准备好 Python3.7 或以上版本。 -2. 生成配置文件:复制 `env.yaml.tpl` 并重命名为 `env.yaml`。 -3. 修改配置文件:编辑 `env.yaml`,添加GPT Token等必要信息。 -4. 运行服务:在 Linux 或 Mac 上执行 `sh run.sh`,在 Windows 上双击运行 `run.bat`。 -5. 访问服务:通过浏览器访问服务(启动日志中提供的访问地址,默认为 http://127.0.0.1:8080)。 -6. 完成需求开发:按照页面引导完成需求开发,在 `./workspace` 目录下查看生成的代码。 +1. 源码运行 + ``` + 1. 克隆最新代码或选择已发布的版本,准备好 Python3.7 或以上版本。 + 2. 生成配置文件:复制 `env.yaml.tpl` 并重命名为 `env.yaml`。 + 3. 修改配置文件:编辑 `env.yaml`,添加GPT Token等必要信息。 + 4. 运行服务:在 Linux 或 Mac 上执行 `sh run.sh`,在 Windows 上双击运行 `run.bat`。 + 5. 访问服务:通过浏览器访问服务(启动日志中提供的访问地址,默认为 http://127.0.0.1:8080)。 + 6. 完成需求开发:按照页面引导完成需求开发,在 `./workspace` 目录下查看生成的代码。 + ``` +2. Docker运行 + ```shell + 1. 创建一个目录:mkdir -p workspace + 2. 从仓库中复制 `env.yaml.tpl` 到当前目录,并重命名为 `env.yaml` + 3. 修改配置文件:编辑 `env.yaml`,添加GPT Token等必要信息。 + 4. docker run -it \ + -v$PWD/workspace:/app/workspace \ + -v$PWD/env.yaml:/app/env.yaml \ + -p8080:8080 -p8081:8081 kuafuai/devopsgpt:latest + 5. 访问服务:通过浏览器访问服务(启动日志中提供的访问地址,默认为 http://127.0.0.1:8080) + 6. 完成需求开发:按照页面引导完成需求开发,在 `./workspace` 目录下查看生成的代码 + ``` **详细文档和配置参数请参考 [文档链接](./DOCUMENT_CN.md)。**