Skip to content

Add Docker support for running onnx-modifier#146

Open
helloworld77 wants to merge 2 commits intoZhangGe6:masterfrom
helloworld77:master
Open

Add Docker support for running onnx-modifier#146
helloworld77 wants to merge 2 commits intoZhangGe6:masterfrom
helloworld77:master

Conversation

@helloworld77
Copy link

Description

Summary

This PR adds the ability to run onnx-modifier in a Docker container, so users can start the service without installing Python or dependencies locally. The documentation in README is updated with a new section "launch from Docker container".

Motivation

  • Users in containerized or restricted environments can run onnx-modifier without a local Python setup.
  • Deployment and sharing become easier (e.g. on servers or CI).
  • Keeps the same workflow as other launch methods (clone → run → open in browser).

Changes

  1. Dockerfile (new)

    • Base image: Python 3.9 slim.
    • Install dependencies from requirements.txt.
    • Default command: python entry.py --host 0.0.0.0 --port 5000 so the app is reachable from outside the container.
  2. README.md

    • New section "launch from Docker container" with:
      • docker build and docker run commands.
      • Note that Flask will show http://0.0.0.0:5000/ and http://127.0.0.1:5000/; opening either in the browser launches onnx-modifier.
  3. onnx_modifier/flask_server.py

    • entry.py (or the script that starts the server) is assumed to support --host and --port so the server can bind to 0.0.0.0:5000 inside the container. Any small changes in this file are to support that and/or fix download behavior when running in Docker (e.g. using absolute path for send_file if needed).

How to use (for reviewers/users)

git clone https://github.com/ZhangGe6/onnx-modifier.git
cd onnx-modifier
docker build -t onnxmodifier .
docker run -d --restart always --pids-limit -1 --security-opt seccomp=unconfined -p 5000:5000 --name onnxmodifier onnxmodifier

Then open http://127.0.0.1:5000/ (or http://0.0.0.0:5000/) in a browser.

Note for maintainers

  • If you prefer to use the official Docker Hub Python image in the upstream repo, the Dockerfile base image can be set to python:3.9-slim and pip install can be run without a custom index (e.g. remove -i https://pypi.tuna.tsinghua.edu.cn/simple for a generic Dockerfile).

中文版(可选)

标题

feat: 支持通过 Docker 容器启动 onnx-modifier

简述

本 PR 增加通过 Docker 运行 onnx-modifier 的方式,并在 README 中新增「launch from Docker container」小节,包含构建与运行命令。使用方式与从源码启动一致:构建镜像 → 运行容器 → 在浏览器中打开输出的地址即可使用。

修改说明

  • 新增 Dockerfile:基于 Python 3.9 slim,安装 requirements.txt,默认以 --host 0.0.0.0 --port 5000 启动,便于从宿主机访问。
  • 更新 README.md:增加 Docker 构建与运行示例,并说明浏览器可访问 http://0.0.0.0:5000/http://127.0.0.1:5000/
  • onnx_modifier/flask_server.py:确保支持 --host/--port 并在容器内正确绑定;如有需要,修正下载逻辑(如使用绝对路径)以在 Docker 环境下正常工作。

使用步骤

见上方英文版中的 docker builddocker run 命令,启动后在浏览器打开 http://127.0.0.1:5000/ 即可。

@ZhangGe6
Copy link
Owner

@helloworld77 Thanks for the contribution. What are the necessities of the modifications in static/index.js and flask_server.py?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants