Skip to content

Commit

Permalink
feat(run): support docker build and run
Browse files Browse the repository at this point in the history
  • Loading branch information
booboosui committed Aug 16, 2023
1 parent 8cca7da commit 9dfd843
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 31 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/default.yaml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).**
Expand Down
20 changes: 20 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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"
20 changes: 1 addition & 19 deletions docs/DOCUMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
27 changes: 21 additions & 6 deletions docs/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)。**
Expand Down

0 comments on commit 9dfd843

Please sign in to comment.