Skip to content
Open
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
51 changes: 51 additions & 0 deletions .github/workflows/publish-segmentation-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Create and publish segmentation image

on:
push:
branches: [ 'master' ]
paths:
- "segmentation/**"
- ".github/workflows/publish-segmentation-image.yaml"
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: als-computing/microct-segmentation

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=raw,value=latest

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./segmentation
file: ./segmentation/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ env/
.env/
.venv/
ENV/
.ENV/
.ENV/.DS_Store
26 changes: 26 additions & 0 deletions segmentation/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Git
.git
.gitignore

# Notebook checkpoints
**/.ipynb_checkpoints/

# Python environments
env/
.env/
.venv/
ENV/
.ENV/

# Model weights / checkpoints
*.pth
*.pt
*.ckpt
*.onnx
*.h5

# Local data and outputs
data/
models/
outputs/
runs/
17 changes: 17 additions & 0 deletions segmentation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# model weights / checkpoints
*.pth
*.pt
*.ckpt
*.onnx
*.h5

# notebook checkpoints
.ipynb_checkpoints/

# local data locations (optional)
data/
models/
outputs/
runs/
.DS_Store
**/.DS_Store
62 changes: 62 additions & 0 deletions segmentation/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Most of this is from: https://gitlab.com/NERSC/nersc-official-images/-/blob/main/nersc/python/3.9-anaconda-2021.11/Dockerfile
FROM docker.io/library/ubuntu:latest
WORKDIR /opt

RUN \
apt-get update && apt-get install --yes \
build-essential \
gfortran \
git \
wget \
libgl1 libegl1 libxext6 libsm6 libxrender1 && \
apt-get clean all && rm -rf /var/lib/apt/lists/*

#miniforge
# Download and install the latest Miniforge (comes with Mamba and conda-forge)
RUN wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O /tmp/miniforge.sh && \
bash /tmp/miniforge.sh -b -p /opt/miniconda && \
rm /tmp/miniforge.sh

# Update PATH environment variable to include Miniforge
ENV PATH="/opt/miniconda/bin:$PATH"


# Install base packages from microct + dependencies for vtk_trial.ipynb
# Added: opencv, matplotlib, vtk, pytorch stack
RUN mamba install --yes -c conda-forge -c astra-toolbox -c simpleitk -c pytorch -c nvidia \
python=3.10 \
jupyterlab astropy cartopy cython cfitsio "dask[distributed]" scipy scikit-learn scikit-image numba h5py joblib pandas statsmodels _libgcc_mutex \
astra-toolbox tifffile tomopy dxchange svmbir itk simpleitk pyfftw natsort olefile tqdm zarr \
opencv matplotlib vtk pytorch torchvision torchaudio pytorch-cuda=12.4 \
&& mamba clean --all -f -y

# Install Detectron2 (requires pytorch)
RUN python -m pip install --no-build-isolation 'git+https://github.com/facebookresearch/detectron2.git'

# # install SYRIS
# COPY syris syris
# # RUN git clone git@github.com:ufo-kit/syris.git
# RUN conda install -c conda-forge -y cmake pybind11 -- the NERSC docs say something about not using cmake
# RUN cd syris && pip install -r requirements.txt && pip install .
# RUN rm -fR syris


# for NERSC jupyterhub environment
RUN pip install batchspawner
ENV NERSC_JUPYTER_IMAGE=YES

# VTK/EGL Environment Configuration for Headless Rendering
ENV VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN=1
ENV VTK_OPENGL_HAS_EGL=1
ENV VTK_USE_OFFSCREEN_EGL=1
ENV LD_LIBRARY_PATH=/usr/lib64:${LD_LIBRARY_PATH}
ENV __GLX_VENDOR_LIBRARY_NAME=nvidia
ENV __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_nvidia.json
ENV VTK_DEFAULT_EGL_DEVICE=0



# expected by entrypoint script
RUN mkdir -p /alsuser /alsdata

WORKDIR /alsuser
13 changes: 13 additions & 0 deletions segmentation/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
segmentation:
build:
context: .
dockerfile: Dockerfile
platform: linux/amd64
container_name: segmentation
volumes:
- .:/alsuser
ports:
- "8000:8000"
command: jupyter lab --ip=0.0.0.0 --port=8000 --no-browser --allow-root --NotebookApp.token=''
restart: unless-stopped
Loading