-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Add Docker support for patch-backporting #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Git | ||
| .git | ||
| .gitignore | ||
|
|
||
| # Python | ||
| __pycache__ | ||
| *.pyc | ||
| *.pyo | ||
| *.pyd | ||
| .Python | ||
| env/ | ||
| venv/ | ||
| .venv/ | ||
| pip-log.txt | ||
| pip-delete-this-directory.txt | ||
|
|
||
| # PDM | ||
| pdm.lock | ||
| .pdm-python | ||
|
|
||
| # IDEs | ||
| .idea/ | ||
| .vscode/ | ||
|
|
||
| # Project specific | ||
| logs/ | ||
| .claude/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Use an official Python runtime as a parent image | ||
| FROM python:3.10-slim | ||
|
|
||
| # Set environment variables | ||
| ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
| PYTHONUNBUFFERED=1 | ||
|
|
||
| # Install system dependencies | ||
| # git: for GitPython | ||
| # curl: for downloading files | ||
| # universal-ctags: for code indexing | ||
| # build-essential, cmake, autoconf, automake, libtool, pkg-config: for compiling target projects (like libtiff) | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| git \ | ||
| curl \ | ||
| universal-ctags \ | ||
| build-essential \ | ||
| cmake \ | ||
| autoconf \ | ||
| automake \ | ||
| libtool \ | ||
| pkg-config \ | ||
| zlib1g-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install Docker CLI manually | ||
| RUN curl -fsSL https://download.docker.com/linux/static/stable/$(uname -m)/docker-24.0.5.tgz -o docker.tgz \ | ||
| && tar xzvf docker.tgz \ | ||
| && mv docker/docker /usr/local/bin/ \ | ||
| && rm -rf docker docker.tgz | ||
|
|
||
| # Set the working directory in the container | ||
| WORKDIR /app | ||
|
|
||
| # Copy the requirements file into the container | ||
| COPY requirements.txt . | ||
|
|
||
| # Install Python dependencies | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| # Copy the rest of the application code | ||
| COPY . . | ||
|
|
||
| # Change working directory to src as per usage instructions | ||
| WORKDIR /app/src | ||
|
|
||
| # Default command to run the application (prints help) | ||
| CMD ["python", "backporting.py", "--help"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,30 @@ cd src | |
| python backporting.py --config example.yml --debug # 记得填写配置文件 | ||
| ``` | ||
|
|
||
| ## Docker 使用方法 | ||
|
|
||
| 构建 Docker 镜像: | ||
|
|
||
| ```shell | ||
| docker build -t patch-backporting . | ||
| ``` | ||
|
|
||
| 运行容器: | ||
|
|
||
| ```shell | ||
| # 请确保挂载了必要的目录(项目代码、配置文件、数据集) | ||
| # 示例:假设当前目录下有 config.yml,数据集位于 /path/to/dataset | ||
| docker run --rm -v $(pwd):/app/src -v /path/to/dataset:/path/to/dataset patch-backporting python backporting.py --config config.yml | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same to README.en
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. README has been updated with the interactive mode instructions. Thanks! |
||
| ``` | ||
|
|
||
| 或者,您可以使用交互模式在容器内执行脚本: | ||
|
|
||
| ```shell | ||
| docker run --rm -it -v $(pwd):/app/src -v /path/to/dataset:/path/to/dataset patch-backporting /bin/bash | ||
| # 在容器内部执行 | ||
| python backporting.py --config config.yml | ||
| ``` | ||
|
|
||
| ## 配置结构 | ||
|
|
||
| ```yml | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also use
docker run -it patch-backporting /bin/bashand execute scripts in docker.Please add it to README.