Skip to content

Commit 666db0e

Browse files
Add Docker containerization infrastructure
- Add modern Dockerfile with ROOT 6.34.00 and Ubuntu 24.04 LTS - Add GitHub Actions workflows for build/test and Docker publishing - Add docker-entrypoint.sh and docker-run.sh helper scripts - Add version tracking in python/larcv/version.py - Update README with Docker quick start and comprehensive usage guide - Remove deprecated Travis CI and Singularity Hub integrations - Add CHANGELOG.md for release tracking - Images will be published to ghcr.io/deeplearnphysics/larcv2
1 parent 125eb08 commit 666db0e

12 files changed

Lines changed: 474 additions & 58 deletions

File tree

.Dockerfile

Lines changed: 0 additions & 37 deletions
This file was deleted.

.dockerignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Build artifacts
2+
build/
3+
*.o
4+
*.so
5+
*.pyc
6+
*.pyo
7+
__pycache__/
8+
*.egg-info/
9+
dist/
10+
11+
# Git
12+
.git/
13+
.gitignore
14+
.gitmodules
15+
16+
# IDE and editor files
17+
.vscode/
18+
.idea/
19+
*.swp
20+
*.swo
21+
*~
22+
.DS_Store
23+
24+
# Documentation
25+
doc/
26+
*.md
27+
!README.md
28+
29+
# CI/CD
30+
.github/
31+
.travis.yml
32+
33+
# Test files
34+
test/
35+
tests/
36+
*.test
37+
38+
# Old Dockerfile
39+
.Dockerfile
40+
41+
# Virtual environments
42+
venv/
43+
env/
44+
ENV/
45+
46+
# Logs
47+
*.log

.github/workflows/build-test.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- main
8+
pull_request:
9+
branches:
10+
- develop
11+
- main
12+
workflow_dispatch:
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Build Docker image
26+
uses: docker/build-push-action@v5
27+
with:
28+
context: .
29+
push: false
30+
load: true
31+
tags: larcv2:test
32+
cache-from: type=gha
33+
cache-to: type=gha,mode=max
34+
35+
- name: Test LArCV import
36+
run: |
37+
docker run --rm larcv2:test python -c "import larcv; print('LArCV version:', larcv.__version__)"
38+
39+
- name: Test basic functionality
40+
run: |
41+
docker run --rm larcv2:test python -c "
42+
import larcv
43+
print('Testing LArCV basic functions...')
44+
print('LArCV loaded successfully!')
45+
print('Version:', larcv.__version__)
46+
"
47+
48+
- name: Run ROOT tests
49+
run: |
50+
docker run --rm larcv2:test python -c "
51+
import ROOT
52+
from ROOT import larcv
53+
print('ROOT and LArCV loaded successfully!')
54+
print('ROOT version:', ROOT.gROOT.GetVersion())
55+
"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
branches:
8+
- develop
9+
- main
10+
pull_request:
11+
branches:
12+
- develop
13+
- main
14+
workflow_dispatch:
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
jobs:
21+
build-and-push:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Log in to the Container registry
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ${{ env.REGISTRY }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Extract metadata (tags, labels) for Docker
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
tags: |
47+
# For PRs, tag with pr-number
48+
type=ref,event=pr
49+
# For branch pushes, tag with branch name
50+
type=ref,event=branch
51+
# For version tags: v2.3.4 -> 2.3.4, 2.3, latest
52+
type=semver,pattern={{version}}
53+
type=semver,pattern={{major}}.{{minor}}
54+
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
55+
56+
- name: Build and push Docker image
57+
uses: docker/build-push-action@v5
58+
with:
59+
context: .
60+
push: ${{ github.event_name != 'pull_request' }}
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max
65+
66+
cleanup-old-images:
67+
runs-on: ubuntu-latest
68+
needs: build-and-push
69+
if: github.event_name != 'pull_request'
70+
permissions:
71+
packages: write
72+
73+
steps:
74+
- name: Delete old untagged images
75+
uses: actions/delete-package-versions@v5
76+
with:
77+
package-name: 'larcv2'
78+
package-type: 'container'
79+
min-versions-to-keep: 5
80+
delete-only-untagged-versions: 'true'

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Docker containerization with automatic builds via GitHub Actions
12+
- Container images published to ghcr.io/deeplearnphysics/larcv2
13+
- Docker helper script (`docker-run.sh`) for easier container usage
14+
- Version tracking in `python/larcv/version.py`
15+
- Comprehensive Docker documentation in README
16+
17+
### Changed
18+
- Modernized Dockerfile with ROOT 6.30.06 and Ubuntu 22.04
19+
- Updated build system to support containerized builds
20+
21+
## [2.3.0] - 2026-04-02
22+
23+
### Added
24+
- Initial version tracking
25+
- Container infrastructure setup
26+
27+
[Unreleased]: https://github.com/DeepLearnPhysics/larcv2/compare/v2.3.0...HEAD
28+
[2.3.0]: https://github.com/DeepLearnPhysics/larcv2/releases/tag/v2.3.0

Dockerfile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Use ROOT6 official image as base
2+
# Available versions: https://hub.docker.com/r/rootproject/root/tags
3+
# Note: ROOT images are linux/amd64 only. On ARM (Apple Silicon), Docker will use emulation.
4+
FROM rootproject/root:6.34.00-ubuntu24.04
5+
6+
LABEL maintainer="drielsma@stanford.edu"
7+
LABEL org.opencontainers.image.source="https://github.com/DeepLearnPhysics/larcv2"
8+
LABEL org.opencontainers.image.description="LArCV2: Image/volumetric data processing framework with deep learning interfaces"
9+
LABEL org.opencontainers.image.licenses="MIT"
10+
11+
# Set working directory
12+
WORKDIR /app/larcv2
13+
14+
# Set environment variables to prevent Python from writing bytecode and buffering
15+
ENV PYTHONUNBUFFERED=1 \
16+
PYTHONDONTWRITEBYTECODE=1 \
17+
DEBIAN_FRONTEND=noninteractive
18+
19+
# Install system dependencies
20+
RUN apt-get update && \
21+
apt-get install -y --no-install-recommends \
22+
build-essential \
23+
cmake \
24+
git \
25+
python3-pip \
26+
python3-dev \
27+
python3-numpy \
28+
libopencv-dev \
29+
python3-opencv \
30+
&& rm -rf /var/lib/apt/lists/*
31+
32+
# Set up Python symlinks (ROOT6 image might have different python setup)
33+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
34+
35+
# Copy the entire project
36+
COPY . .
37+
38+
# Set up LArCV environment variables
39+
ENV LARCV_BASEDIR=/app/larcv2 \
40+
LARCV_BUILDDIR=/app/larcv2/build \
41+
LARCV_COREDIR=/app/larcv2/larcv/core \
42+
LARCV_APPDIR=/app/larcv2/larcv/app \
43+
LARCV_LIBDIR=/app/larcv2/build/lib \
44+
LARCV_INCDIR=/app/larcv2/build/include \
45+
LARCV_BINDIR=/app/larcv2/build/bin \
46+
LARCV_ROOT6=1 \
47+
LARCV_CXX=g++ \
48+
LARCV_NUMPY=1 \
49+
LARCV_OPENCV=1
50+
51+
# Set OpenCV paths for configure script
52+
ENV OPENCV_INCDIR=/usr/include/opencv4 \
53+
OPENCV_LIBDIR=/usr/lib/x86_64-linux-gnu
54+
55+
# Update PATH and library paths
56+
# Note: Extending paths from base ROOT image which already has these variables set
57+
# docker-lint: ignore=UndefinedVar
58+
ENV PATH="${LARCV_BASEDIR}/bin:${LARCV_BINDIR}:${PATH}" \
59+
LD_LIBRARY_PATH="${LARCV_LIBDIR}:/usr/local/lib:${LD_LIBRARY_PATH:-}" \
60+
PYTHONPATH="${LARCV_BASEDIR}/python:${PYTHONPATH:-}"
61+
62+
# Build LArCV
63+
RUN mkdir -p ${LARCV_BUILDDIR} ${LARCV_LIBDIR} ${LARCV_BINDIR} && \
64+
bash -c "source configure.sh -q && make -j$(nproc)"
65+
66+
# Verify the build
67+
RUN python -c "import larcv; print('LArCV imported successfully')" || \
68+
(echo "Failed to import larcv" && exit 1)
69+
70+
# Set up entrypoint to ensure environment is loaded
71+
COPY docker-entrypoint.sh /usr/local/bin/
72+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
73+
74+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
75+
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)