Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .dockerignore
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/
48 changes: 48 additions & 0 deletions Dockerfile
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"]
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@ cd src
python backporting.py --config example.yml --debug # Remember fill out the config.
```

## Docker Usage

Build the docker image:

```shell
docker build -t patch-backporting .
```

Run the container:

```shell
# Ensure you mount the necessary directories (code, config, datasets)
# Example: assuming config.yml is in current dir and datasets are in /data
docker run --rm -v $(pwd):/app/src -v /path/to/dataset:/path/to/dataset patch-backporting python backporting.py --config config.yml
Copy link
Collaborator

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/bash and execute scripts in docker.
Please add it to README.

```

Alternatively, you can use the interactive mode to execute scripts inside the container:

```shell
docker run --rm -it -v $(pwd):/app/src -v /path/to/dataset:/path/to/dataset patch-backporting /bin/bash
# Inside the container
python backporting.py --config config.yml
```

## Config structure

```yml
Expand Down
24 changes: 24 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same to README.en

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down