Skip to content

Commit

Permalink
Add docker file and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
finsberg committed Feb 15, 2024
1 parent 9213e95 commit 05b61f6
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 1 deletion.
74 changes: 74 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Create and publish a Docker image

on:
push:
branches:
- "!*"
tags:
- "v*"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
LAB_NAME: lab

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

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- 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 base-image
id: meta-base
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta-base.outputs.tags }}
labels: ${{ steps.meta-base.outputs.labels }}
target: base

- name: Extract metadata (tags, labels) for lab images
id: meta-lab
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.LAB_NAME }}

- name: Build and push Docker lab image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta-lab.outputs.tags }}
labels: ${{ steps.meta-lab.outputs.labels }}
target: lab
Empty file removed Dockerfile
Empty file.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ This repository contains supplementary code for reproducing results in the paper
The code is heavily based on the library [`mps-motion`](https://github.com/ComputationalPhysiology/mps_motion). Please check out the [documentation](https://computationalphysiology.github.io/mps_motion/) in that library for more details.

## Running with binder
If you want to run the examples without installing anything you can launch an interactive environment with Binder, by clicking the following button: TODO: Add button
If you want to run the examples without installing anything you can launch an interactive environment with Binder, by clicking the following button [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ComputationalPhysiology/automatic-motion-estimation-hiPSC-CM/HEAD)

## Running locally

### Python virtual environment
To run the notebooks locally, you first need to install the necessary requirements. There are two options. Either, you can create a virtual environment with python
```
python3 -m venv venv
Expand All @@ -26,3 +28,17 @@ Next you install the dependencies
```
python3 -m pip install -r requirements.txt
```

### Docker

We also provide two different docker images for you. In order to start a container you can use the docker run command. For example the command
```
docker run --rm -v $(pwd):/home/shared -w /home/shared -ti ghcr.io/computationalphysiology/automatic-motion-estimation-hiPSC-CM:latest
```
will run the latest version and share your current working directory with the container. The source code of the repository is located at `/repo` in the docker container.

To run the notebooks, one can use `ghcr.io/computationalphysiology/automatic-motion-estimation-hiPSC-CM-lab:latest`, i.e
```
docker run -ti -p 8888:8888 --rm ghcr.io/computationalphysiology/automatic-motion-estimation-hiPSC-CM-lab:latest
```
to run interactively with Jupyter lab in browser.
27 changes: 27 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from ubuntu:22.04 as base

RUN apt-get update && apt-get install -y python3-pip gcc python3-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

WORKDIR /repo

COPY requirements.txt /repo

RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --no-cache-dir -r requirements.txt
# Install the headless version of opencv in docker
RUN python3 -m pip uninstall -y opencv-python opencv-contrib-python
RUN python3 -m pip install --no-cache-dir opencv-python-headless opencv-contrib-python-headless


COPY . /repo

FROM base as lab

# Had some issues with psutil (needed by jupyter) on aarch64, so need to install it from source
RUN python3 -m pip install --no-cache-dir psutil --no-binary=psutil
RUN python3 -m pip install --no-cache-dir jupyter

EXPOSE 8888/tcp
ENTRYPOINT [ "jupyter", "lab", "--ip", "0.0.0.0", "--port", "8888", "--no-browser", "--allow-root"]
1 change: 1 addition & 0 deletions runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.10

0 comments on commit 05b61f6

Please sign in to comment.