Skip to content

Commit 28ab13e

Browse files
committed
feat: Add Docker support for patch-backporting
- Added Dockerfile based on python:3.10-slim with necessary dependencies (git, ctags, docker-cli, build-essential, zlib). - Added .dockerignore to optimize build context. - Updated README.md with Docker build and run instructions.
1 parent 835d239 commit 28ab13e

4 files changed

Lines changed: 107 additions & 0 deletions

File tree

.dockerignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Python
6+
__pycache__
7+
*.pyc
8+
*.pyo
9+
*.pyd
10+
.Python
11+
env/
12+
venv/
13+
.venv/
14+
pip-log.txt
15+
pip-delete-this-directory.txt
16+
17+
# PDM
18+
pdm.lock
19+
.pdm-python
20+
21+
# IDEs
22+
.idea/
23+
.vscode/
24+
25+
# Project specific
26+
logs/
27+
.claude/

Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Use an official Python runtime as a parent image
2+
FROM python:3.10-slim
3+
4+
# Set environment variables
5+
ENV PYTHONDONTWRITEBYTECODE=1 \
6+
PYTHONUNBUFFERED=1
7+
8+
# Install system dependencies
9+
# git: for GitPython
10+
# curl: for downloading files
11+
# universal-ctags: for code indexing
12+
# build-essential, cmake, autoconf, automake, libtool, pkg-config: for compiling target projects (like libtiff)
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
git \
15+
curl \
16+
universal-ctags \
17+
build-essential \
18+
cmake \
19+
autoconf \
20+
automake \
21+
libtool \
22+
pkg-config \
23+
zlib1g-dev \
24+
&& rm -rf /var/lib/apt/lists/*
25+
26+
# Install Docker CLI manually
27+
RUN curl -fsSL https://download.docker.com/linux/static/stable/$(uname -m)/docker-24.0.5.tgz -o docker.tgz \
28+
&& tar xzvf docker.tgz \
29+
&& mv docker/docker /usr/local/bin/ \
30+
&& rm -rf docker docker.tgz
31+
32+
# Set the working directory in the container
33+
WORKDIR /app
34+
35+
# Copy the requirements file into the container
36+
COPY requirements.txt .
37+
38+
# Install Python dependencies
39+
RUN pip install --no-cache-dir -r requirements.txt
40+
41+
# Copy the rest of the application code
42+
COPY . .
43+
44+
# Change working directory to src as per usage instructions
45+
WORKDIR /app/src
46+
47+
# Default command to run the application (prints help)
48+
CMD ["python", "backporting.py", "--help"]

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ cd src
2626
python backporting.py --config example.yml --debug # Remember fill out the config.
2727
```
2828

29+
## Docker Usage
30+
31+
Build the docker image:
32+
33+
```shell
34+
docker build -t patch-backporting .
35+
```
36+
37+
Run the container:
38+
39+
```shell
40+
# Ensure you mount the necessary directories (code, config, datasets)
41+
# Example: assuming config.yml is in current dir and datasets are in /data
42+
docker run --rm -v $(pwd):/app/src -v /path/to/dataset:/path/to/dataset patch-backporting python backporting.py --config config.yml
43+
```
44+
2945
## Config structure
3046

3147
```yml

README.zh-CN.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ cd src
2626
python backporting.py --config example.yml --debug # 记得填写配置文件
2727
```
2828

29+
## Docker 使用方法
30+
31+
构建 Docker 镜像:
32+
33+
```shell
34+
docker build -t patch-backporting .
35+
```
36+
37+
运行容器:
38+
39+
```shell
40+
# 请确保挂载了必要的目录(项目代码、配置文件、数据集)
41+
# 示例:假设当前目录下有 config.yml,数据集位于 /path/to/dataset
42+
docker run --rm -v $(pwd):/app/src -v /path/to/dataset:/path/to/dataset patch-backporting python backporting.py --config config.yml
43+
```
44+
2945
## 配置结构
3046

3147
```yml

0 commit comments

Comments
 (0)