Skip to content

Commit 3bf633a

Browse files
committed
Adds Dockerfile + release container building
Command to build the container for pybioclip: ``` docker build --platform=linux/amd64 --build-arg="PYBIOCLIP_VERSION=1.0.0" -t pybioclip . ``` Adds GitHub action config to build the docker container on release.
1 parent cbd0e85 commit 3bf633a

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

.github/workflows/deploy-image.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
release:
5+
types: [published]
6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: ${{ github.repository }}
9+
10+
jobs:
11+
build-and-push-image:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Log in to the Container registry
22+
uses: docker/login-action@v3
23+
with:
24+
registry: ${{ env.REGISTRY }}
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Extract metadata (tags, labels) for Docker
29+
id: meta
30+
uses: docker/metadata-action@v4
31+
with:
32+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
33+
tags: |
34+
type=semver,pattern={{major}}.{{minor}}.{{patch}}
35+
type=semver,pattern={{major}}.{{minor}}
36+
type=semver,pattern={{major}}
37+
38+
- name: Build and push Docker image
39+
uses: docker/build-push-action@v6
40+
with:
41+
context: .
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}
45+
build-args: "PYBIOCLIP_VERSION=${{ steps.meta.outputs.version }}"

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM condaforge/miniforge3:24.3.0-0
2+
3+
# Pass -s to tini since apptainer doesn't run as PID 1
4+
ENTRYPOINT ["tini", "-s", "--"]
5+
6+
ARG PYBIOCLIP_VERSION
7+
8+
# Install pybioclip from the release archive because pypi can take a while to start working.
9+
RUN pip install "https://github.com/Imageomics/pybioclip/archive/refs/tags/${PYBIOCLIP_VERSION}.tar.gz" && \
10+
pip cache purge
11+
12+
# Create a non-root user with a home directory to help cache pybioclip files
13+
RUN useradd -ms /bin/bash bcuser
14+
USER bcuser
15+
ENV PATH="$PATH:/home/bcuser/.local/bin"
16+
WORKDIR /home/bcuser

0 commit comments

Comments
 (0)