ADD: aU project image package shell

This commit is contained in:
AniviaTn
2025-02-28 14:12:12 +08:00
parent 532c321bdc
commit bb71cacdbc
10 changed files with 169 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
# Docker container deployment
agentUniverse provides standard work environment images for the containerized deployment of agentUniverse projects. This document will explain how to deploy your own project using such images. You can find the full tag list on [this site](https://cr.console.aliyun.com/repository/cn-hangzhou/agent_universe/agent_universe/images).
agentUniverse provides standard work environment images for the containerized deployment of agentUniverse projects. This document will explain how to deploy your own project using such images. You can find the full tag list on [this site](https://cr.console.aliyun.com/repository/cn-hangzhou/agent_universe/agent_universe/images). If you want to package an image based on your own project, please refer to [Project Image Packaging](./Project_Image_Packaging.md).
## Preparations
1. Build your own project according to the standard directory structure of agentUniverse, referring to the [Application_Engineering_Structure_Explanation](../../../Get_Start/1.Application_Project_Structure_and_Explanation.md). For ease of explanation, this document assumes the project name and project directory are `sample_standard_app`.

View File

@@ -1,6 +1,6 @@
# High Availability Deployment with K8S
agentUniverse provides standard working environment images specifically designed to support containerized deployments on Kubernetes (K8S) clusters. This guide will demonstrate how to utilize these images to deploy and set up a cluster within a K8S environment. You can get the full list of tags on [this site](https://cr.console.aliyun.com/repository/cn-hangzhou/agent_universe/agent_universe/images).
Official K8S Documentation: [Kubernetes Setup Documentation](https://kubernetes.io/docs/setup/)
Official K8S Documentation: [Kubernetes Setup Documentation](https://kubernetes.io/docs/setup/). If you want to package an image based on your own project, please refer to [Project Image Packaging](./Project_Image_Packaging.md).
## 1. Resource Configuration
Firstly, you need to configure the necessary resource files. Below is an example YAML configuration file used to define the required Namespace, Deployment, and Service resources:

View File

@@ -0,0 +1,20 @@
# Project Image Packaging
In the sample project `sample_standard_app`, we provide a script that automates the process of packaging an aU project into an image. This script helps you create an image based on the CentOS 8 system, including the Python runtime environment and project dependencies. You can then refer to [Docker Container Deployment](./Docker_Container_Deployment.md) and [K8S Deployment](./K8S_Deployment.md) to deploy your aU application.
## Execution Steps
```shell
# 1. Navigate to the image_build directory. Replace sample_standard_app with your actual project name.
cd xxx/xxx/sample_standard_app/image_build
chmod +x start_build.sh
./start_build.sh
```
## Configurable Parameters
You can modify the following configurations in the script:
```shell
IMAGE_NAME=${PROJECT_NAME}
IMAGE_TAG="latest"
```
- `IMAGE_NAME` specifies the output image name, with the default value set to your project directory name.
- `IMAGE_TAG` specifies the output image tag, with the default value set to latest.

View File

@@ -1,6 +1,6 @@
# Docker容器化部署
AgentUniverse提供标准的工作环境镜像用于容器化部署AgentUniverse工程。本文档将介绍如何基于工作环境镜像部署您自己的工程项目。镜像tag列表可以在[这里获取](https://cr.console.aliyun.com/repository/cn-hangzhou/agent_universe/agent_universe/images)。
AgentUniverse提供标准的工作环境镜像用于容器化部署AgentUniverse工程。本文档将介绍如何基于工作环境镜像部署您自己的工程项目。镜像tag列表可以在[这里获取](https://cr.console.aliyun.com/repository/cn-hangzhou/agent_universe/agent_universe/images)。如果您希望打包一个基于自己工程的镜像,请参考[工程镜像打包](./工程镜像打包.md)。
## 准备工作
1. 按照AgentUniverse的标准结构目录搭建自己的项目具体结构参考[应用工程结构及说明](../../../开始使用/1.标准应用工程结构说明.md)。为方便说明,在本文档中假设项目名称和工程目录为`sample_standard_app`

View File

@@ -1,5 +1,5 @@
# K8S集群部署
AgentUniverse 提供标准的工作环境镜像,并且支持在 Kubernetes (K8S) 集群上容器化部署。本指南将指导您如何利用这些工作环境镜像,在 K8S 上部署和搭建集群。镜像tag列表您可以在[这里获取](https://cr.console.aliyun.com/repository/cn-hangzhou/agent_universe/agent_universe/images)。
AgentUniverse 提供标准的工作环境镜像,并且支持在 Kubernetes (K8S) 集群上容器化部署。本指南将指导您如何利用这些工作环境镜像,在 K8S 上部署和搭建集群。镜像tag列表您可以在[这里获取](https://cr.console.aliyun.com/repository/cn-hangzhou/agent_universe/agent_universe/images)。如果您希望打包一个基于自己工程的镜像,请参考[工程镜像打包](./工程镜像打包.md)。
官方K8S使用文档[Kubernetes Setup Documentation](https://kubernetes.io/docs/setup/)

View File

@@ -0,0 +1,22 @@
# 工程镜像打包
我们在示例工程sample_standard_app中提供了一个将aU工程打包为镜像的[脚本](../../../../../../examples/sample_standard_app/image_build/start_build.sh)可以帮助您自动化的打包一个基于centos8系统包含python运行环境、项目依赖的镜像后续您可以参考[Docker容器化部署](./Docker容器化部署.md)和[K8S部署](./K8S部署.md)部署您的aU应用。
## 执行步骤
```shell
# 1. 将当前路径切换至image_build目录下, sample_standard_app可替换为实际项目名称
cd xxx/xxx/sample_standard_app/image_build
chmod +x start_build.sh
./start_build.sh
```
## 可配置项
您可以修改脚本中的以下配置
```shell
IMAGE_NAME=${PROJECT_NAME}
IMAGE_TAG="latest"
```
- IMAGE_NAME表示最终输出的镜像名称默认值为你的工程目录名
- IMAGE_TAG表示最终输出的镜像tag默认值为latest

View File

@@ -0,0 +1,40 @@
FROM docker.io/library/centos:centos8.4.2105
MAINTAINER fanen.lhy@antgroup.com
ARG PROJECT_NAME
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*; \
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*; \
yum install -y wget; \
yum install -y unzip; \
yum install -y vim; \
yum install -y jq; \
yum install -y net-tools; \
yum install -y langpacks-zh_CN; \
yum clean all; \
mkdir -p /usr/local/etc/workspace/shell; \
mkdir -p /usr/local/etc/workspace/project; \
sed -i 's/^LANG=.*/LANG="zh_CN.UTF-8"/' /etc/locale.conf
ENV TZ=Asia/Shanghai
ENV PROJECT_NAME=${PROJECT_NAME}
COPY ./shell /usr/local/etc/workspace/shell/
# Copy project files excluding the image_build directory
COPY ./project_files/ /usr/local/etc/workspace/${PROJECT_NAME}
RUN rm -rf /usr/local/etc/workspace/${PROJECT_NAME}/image_build
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && \
/bin/bash /usr/local/etc/workspace/shell/install_python.sh -p 3.10
RUN mkdir -p ~/.pip; \
echo '[global]'>>~/.pip/pip.conf; \
echo 'index-url = https://mirrors.aliyun.com/pypi/simple/ '>>~/.pip/pip.conf; \
/bin/bash --login -c "pip install poetry==1.8.0"; \
# Install dependencies from pyproject.toml
cd /usr/local/etc/workspace/${PROJECT_NAME} && \
/bin/bash --login -c "poetry config virtualenvs.create false && poetry install --no-root"
WORKDIR /home
ENTRYPOINT ["/bin/bash","--login", "/usr/local/etc/workspace/shell/start.sh"]

View File

@@ -0,0 +1,38 @@
#!/bin/bash
wget https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-Linux-x86_64.sh --no-check-certificate
chmod +x Miniforge3-Linux-x86_64.sh
./Miniforge3-Linux-x86_64.sh -b -p /usr/local/etc/workspace/miniforge
/usr/local/etc/workspace/miniforge/bin/conda init
source /root/.bashrc
echo 'channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
' >~/.condarc
conda config --set show_channel_urls yes
conda clean -i -y
while getopts ":p:" opt; do
case $opt in
p)
if [ "$OPTARG" == "3.10" ]; then
conda create -y -c conda-forge -n agentuniverse310 python=3.10
fi
;;
esac
done
echo "conda activate agentuniverse310" >>/root/.bashrc
/bin/bash -c "/usr/local/etc/workspace/miniforge/bin/conda init"

View File

@@ -0,0 +1,27 @@
#!/bin/bash
TARGET_DIR="/usr/local/etc/workspace/project"
if [ -z "$(ls -A "$TARGET_DIR")" ]; then
mv /usr/local/etc/workspace/${PROJECT_NAME} $TARGET_DIR
echo "use default project"
else
rm -rf /usr/local/etc/workspace/${PROJECT_NAME}
fi
DIR_COUNT=$(find "$TARGET_DIR" -maxdepth 1 -type d | wc -l)
if [ "$DIR_COUNT" -eq 2 ]; then
UNIQUE_DIR=$(find "$TARGET_DIR" -maxdepth 1 -type d | tail -n 1)
cd "$UNIQUE_DIR"
else
echo "please only place one directory under project"
fi
cd ./bootstrap/platform
nohup python3 -u product_application.py &
cd ../intelligence
python3 -u server_application.py

View File

@@ -0,0 +1,18 @@
#!/bin/bash
PROJECT_NAME=$(basename $(cd ../ && pwd))
IMAGE_NAME=${PROJECT_NAME}
IMAGE_TAG="latest"
echo "Project name detected: $PROJECT_NAME"
rm -rf ./project_files
mkdir -p ./project_files
cd ../
find . -mindepth 1 -maxdepth 1 -not -name "image_build" -exec cp -r {} image_build/project_files/ \;
cd image_build
docker build --no-cache --platform linux/amd64 --build-arg PROJECT_NAME=$PROJECT_NAME --tag=${IMAGE_NAME}:${IMAGE_TAG} .
rm -rf ./project_files