Skip to content

Commit 9c63268

Browse files
dpark01claude
andcommitted
Add Docker image build infrastructure
Set up repository for building and publishing a read QC tools Docker image: - Dockerfile based on micromamba with conda environment - GitHub Actions workflow for multi-arch builds (amd64/arm64) - Automatic publishing to ghcr.io on branch/tag push 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5448996 commit 9c63268

File tree

7 files changed

+227
-0
lines changed

7 files changed

+227
-0
lines changed

.dockerignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Git
2+
.git/
3+
.gitignore
4+
5+
# GitHub
6+
.github/
7+
8+
# Documentation
9+
README.md
10+
11+
# Scripts (not needed in image)
12+
scripts/
13+
14+
# IDE
15+
.idea/
16+
.vscode/
17+
18+
# OS
19+
.DS_Store
20+
21+
# Local testing
22+
*.log
23+
tmp/

.github/workflows/docker.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags:
8+
- '**'
9+
pull_request:
10+
branches:
11+
- main
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up QEMU
29+
uses: docker/setup-qemu-action@v3
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Log in to Container Registry
35+
if: github.event_name != 'pull_request'
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Extract metadata (tags, labels)
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+
tags: |
48+
# For branches: use branch name
49+
type=ref,event=branch
50+
# For tags: use tag name
51+
type=ref,event=tag
52+
# For PRs: use pr-<number>
53+
type=ref,event=pr
54+
# Add 'latest' tag for default branch
55+
type=raw,value=latest,enable={{is_default_branch}}
56+
57+
- name: Build and push Docker image
58+
uses: docker/build-push-action@v6
59+
with:
60+
context: .
61+
platforms: linux/amd64,linux/arm64
62+
push: ${{ github.event_name != 'pull_request' }}
63+
tags: ${{ steps.meta.outputs.tags }}
64+
labels: ${{ steps.meta.outputs.labels }}
65+
cache-from: type=gha
66+
cache-to: type=gha,mode=max

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.egg-info/
5+
.eggs/
6+
dist/
7+
build/
8+
9+
# IDE
10+
.idea/
11+
.vscode/
12+
*.swp
13+
*.swo
14+
15+
# OS
16+
.DS_Store
17+
Thumbs.db
18+
19+
# Local testing
20+
*.log
21+
tmp/

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM mambaorg/micromamba:2.4.0-ubuntu24.04
2+
3+
# Copy environment file and install dependencies
4+
COPY --chown=$MAMBA_USER:$MAMBA_USER env.yaml /tmp/env.yaml
5+
RUN micromamba install -y -n base -f /tmp/env.yaml && \
6+
micromamba clean --all --yes
7+
8+
# Enable conda environment activation for subsequent RUN commands
9+
ARG MAMBA_DOCKERFILE_ACTIVATE=1
10+
11+
# Verify key tools are available
12+
RUN python --version && \
13+
samtools --version | head -1 && \
14+
fastqc --version && \
15+
multiqc --version
16+
17+
# Set working directory
18+
WORKDIR /data

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# read-qc-tools
2+
3+
Docker image containing tools for read QC and processing.
4+
5+
## Included Tools
6+
7+
- **fastqc** - Quality control for high throughput sequence data
8+
- **multiqc** - Aggregate results from bioinformatics analyses
9+
- **samtools** - Tools for manipulating SAM/BAM files
10+
- **python 3.12** with biopython and pysam
11+
- **GNU parallel** - Shell tool for executing jobs in parallel
12+
- **jq** - Command-line JSON processor
13+
- **pigz** - Parallel gzip
14+
- **zstd** - Zstandard compression
15+
16+
## Usage
17+
18+
### Pull from GitHub Container Registry
19+
20+
```bash
21+
docker pull ghcr.io/OWNER/read-qc-tools:main
22+
```
23+
24+
Replace `OWNER` with the GitHub organization or username.
25+
26+
### Run interactively
27+
28+
```bash
29+
docker run --rm -it -v $(pwd):/data ghcr.io/OWNER/read-qc-tools:main bash
30+
```
31+
32+
### Run a specific command
33+
34+
```bash
35+
docker run --rm -v $(pwd):/data ghcr.io/OWNER/read-qc-tools:main fastqc reads.fastq.gz
36+
```
37+
38+
## Building Locally
39+
40+
```bash
41+
./scripts/build.sh
42+
```
43+
44+
Or with custom image name/tag:
45+
46+
```bash
47+
IMAGE_NAME=my-image TAG=dev ./scripts/build.sh
48+
```
49+
50+
## Multi-Architecture Support
51+
52+
The image is built for both `linux/amd64` (Intel/AMD) and `linux/arm64` (Apple Silicon, ARM servers). Docker will automatically pull the correct architecture for your platform.
53+
54+
## Modifying the Environment
55+
56+
Edit `env.yaml` to add or remove conda packages, then rebuild.

env.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: base
2+
channels:
3+
- conda-forge
4+
- bioconda
5+
dependencies:
6+
# QC tools
7+
- fastqc
8+
- multiqc
9+
10+
# Alignment/BAM tools
11+
- samtools
12+
13+
# Python and libraries
14+
- python=3.12
15+
- biopython
16+
- pysam
17+
18+
# CLI utilities
19+
- parallel # GNU parallel
20+
- jq
21+
- pigz
22+
- zstd

scripts/build.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
6+
7+
# Default image name
8+
IMAGE_NAME="${IMAGE_NAME:-read-qc-tools}"
9+
TAG="${TAG:-local}"
10+
11+
cd "$REPO_ROOT"
12+
13+
echo "Building Docker image: ${IMAGE_NAME}:${TAG}"
14+
15+
docker build \
16+
-t "${IMAGE_NAME}:${TAG}" \
17+
.
18+
19+
echo "Build complete: ${IMAGE_NAME}:${TAG}"
20+
echo ""
21+
echo "Run with: docker run --rm -it -v \$(pwd):/data ${IMAGE_NAME}:${TAG}"

0 commit comments

Comments
 (0)