跳到主要内容
版本:release-2.1.0

业务镜像构建

当mnist的wrapper.py的推理逻辑执行成功后,需要将项目文件进行打包构建服务镜像。方式如下:

  • 通过python的requirements.txt文件来构建推理环境。(本例中使用的方法)
  • 通过conda导出的yaml环境依赖来构建推理环境。

方式一: 修改mnist目录下的Dockerfile文件。(基础镜像内置python3.9)

# please visit https://github.com/xfyun/aiges/releases to get stable and suitable iamges.

FROM public.ecr.aws/iflytek-open/aiges-gpu:11.6-1.17-3.9.13-ubuntu1804-v2.0.0-rc6

# do this if you are on the chinese server.

RUN pip3 config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/

ADD requirements.txt /home/aiges

RUN pip install -r /home/aiges/requirements.txt

ADD wrapper /home/aiges

CMD ["sh", "-c", "./AIservice -m=0 -c=aiges.toml -s=svcName -u=http://companion.xfyun.iflytek:6868 -p=AIaaS -g=dx"]

通过docker构建镜像:

docker build -f Dockerfile -t mnist .

方式二: 使用envd并构建镜像,在mnist目录下创建build.envd文件。

参考文档-envd

def build():
config.pip_index(url = "https://pypi.tuna.tsinghua.edu.cn/simple")
base(language="python3.8", os="public.ecr.aws/iflytek-open/aiges-gpu:11.6-1.17-3.9.13-ubuntu1804-v2.0.0-rc6") #加载指定的base镜像和python版本
install.python_packages(requirements="requirements.txt")

通过envd构建镜像:

envd build -t mnist -f build.envd