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
22 changes: 22 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Keep .git in the context: versioneer needs it to compute the package version.
# It is not copied into the final image (see the multi-stage Dockerfile).
.claude
.circleci
.github
.pytest_cache
.coverage*
.venv
venv
build
dist
docs
htmlcov
**/__pycache__
**/*.pyc
**/*.egg-info
Dockerfile
.dockerignore
Comment thread
bpinsard marked this conversation as resolved.
Resolved
.*rc
.zenodo.json
.pre-commit-config.yaml
.readthedhocs.yml
76 changes: 76 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Build the phys2bids container image and push it to GitHub Container Registry (ghcr.io).
#
# - Pull requests: build only, nothing is pushed.
# - Published releases and manual runs: build and push.

name: Docker

on:
release:
types: [created]

pull_request:
branches: [master]
Comment thread
smoia marked this conversation as resolved.
Resolved
workflow_dispatch:

permissions:
contents: read

concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true

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

steps:
- name: Checkout
uses: actions/checkout@v7.0.1
with:
# Full history so versioneer can derive the package version from tags.
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v4.4.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.4.1

- name: Log in to GitHub Container Registry
# Pull requests from forks get no write token, so skip login for them.
if: github.event_name != 'pull_request'
uses: docker/login-action@v4.8.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract image metadata (tags, labels)
id: meta
uses: docker/metadata-action@v6.2.0
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ github.event_name == 'release' }}

- name: Build and push
uses: docker/build-push-action@v7.4.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
# Never push from pull requests: they only build to check the Dockerfile.
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# syntax=docker/dockerfile:1
#
# phys2bids container image.
#
# Build: docker build -t phys2bids .
# Run: docker run --rm -v "$PWD":/data -w /data phys2bids -h

ARG PYTHON_VERSION=3.12

# ---- Build stage: install phys2bids and its optional readers into a venv ----
FROM python:${PYTHON_VERSION}-slim AS builder

ENV PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1

RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

WORKDIR /src
COPY . .

# versioneer reads the version from git metadata, so .git must be present in
# the build context (it is not copied into the final image).
RUN pip install --upgrade pip \
&& pip install ".[acq,mat]"

# ---- Runtime stage: only the virtualenv, no build tooling or sources ----
FROM python:${PYTHON_VERSION}-slim

LABEL org.opencontainers.image.title="phys2bids" \
org.opencontainers.image.description="Python library to convert physiological data files into BIDS format" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.source="https://github.com/physiopy/phys2bids"

COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1

# Run as an unprivileged user; mount data at /data.
RUN useradd --create-home --uid 1000 phys2bids \
&& mkdir /data \
&& chown phys2bids:phys2bids /data
USER phys2bids
WORKDIR /data

ENTRYPOINT ["phys2bids"]
CMD ["-h"]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Shortcuts:
- [Developer installation](https://phys2bids.readthedocs.io/en/latest/contributing.html#linux-and-mac-developer-installation)
- [**Contributor guide**](https://phys2bids.readthedocs.io/en/latest/contributorfile.html)
- [**Code of Conduct**](https://phys2bids.readthedocs.io/en/latest/conduct.html)
- [Docker image](#docker)
- [Developer calls calendar](https://calendar.google.com/calendar/u/0?cid=amoycDQ1MTdhMWdpaHNuNzlnOW1ucHJkMjRAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ)

## Tested OSs
Expand All @@ -60,6 +61,17 @@ Hence, while **we cannot ensure that phys2bids will run on Windows or MacOS/iOS*

We apologise for any discomfort.

## Docker
A container image with `phys2bids` installed is published to the GitHub Container Registry: [`ghcr.io/physiopy/phys2bids`](https://github.com/physiopy/phys2bids/pkgs/container/phys2bids). The image is built from the [`Dockerfile`](https://github.com/physiopy/phys2bids/blob/master/Dockerfile) at the root of the repository.

```bash
docker pull ghcr.io/physiopy/phys2bids:latest
docker run --rm -v "$PWD":/data ghcr.io/physiopy/phys2bids:latest -h
```

The container runs as a non-root user with `/data` as its working directory, so mount the folder holding your physiological files there.
That image do not support spike2.


<!-- ## Hacktoberfest
Hacktoberfest participants, welcome!
Expand Down