[refactored] update method of production environment
This commit is contained in:
parent
efbe13b808
commit
2403dcba58
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
__pycache__
|
||||
build
|
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@ -0,0 +1,15 @@
|
||||
FROM python:3.12.6-bookworm
|
||||
|
||||
WORKDIR /app
|
||||
RUN pip install -i https://mirrors.bfsu.edu.cn/pypi/web/simple flask msgpack onnxruntime gunicorn
|
||||
|
||||
|
||||
# 指定容器创建时的默认命令。(可以被覆盖此命令为生产部署时的命令
|
||||
CMD gunicorn 'main:app' -b 0.0.0.0:22111
|
||||
|
||||
|
||||
### 若为开发阶段,则在运行时覆盖上述命令
|
||||
#python main.py
|
||||
|
||||
# 声明容器运行时监听的特定网络端口。但不会真的映射到外面
|
||||
EXPOSE 22111
|
2
main.py
2
main.py
@ -55,4 +55,4 @@ def register():
|
||||
return response
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True,host="0.0.0.0")
|
||||
app.run(debug=True,host="0.0.0.0",port=22111)
|
27
run.ps1
Normal file
27
run.ps1
Normal file
@ -0,0 +1,27 @@
|
||||
Param( [string]$cmd, [string]$version)
|
||||
|
||||
|
||||
If($cmd -eq "build_docker"){
|
||||
docker build -t sems-model-inference:latest .
|
||||
}
|
||||
|
||||
|
||||
If($cmd -eq "dev"){
|
||||
docker run --rm -p "22111:22111" -v "C:\SEMS-development\SEMS-model-inference:/app" --name sems-model-inference sems-model-inference:latest python main.py
|
||||
}
|
||||
|
||||
|
||||
If($cmd -eq "prod"){
|
||||
docker run --rm -d -p "22111:22111" -v "C:\SEMS-development\SEMS-model-inference:/app" --name sems-model-inference sems-model-inference:latest
|
||||
}
|
||||
|
||||
|
||||
If($cmd -eq "remove_docker"){
|
||||
docker stop sems-model-inference
|
||||
}
|
||||
|
||||
|
||||
|
||||
If($cmd -eq "release"){
|
||||
Compress-Archive -Path ./main.py,super_resolution.onnx -DestinationPath "./build/SEMS-model-inference-$version.zip" -Force
|
||||
}
|
Loading…
Reference in New Issue
Block a user