Skip to content

Commit

Permalink
Merge pull request #40 from Imageomics/docker
Browse files Browse the repository at this point in the history
Adds Dockerfile + release container building
  • Loading branch information
johnbradley authored Aug 30, 2024
2 parents cbd0e85 + 3bf633a commit 12c503d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create and publish a Docker image

on:
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

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

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

- 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@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: "PYBIOCLIP_VERSION=${{ steps.meta.outputs.version }}"
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM condaforge/miniforge3:24.3.0-0

# Pass -s to tini since apptainer doesn't run as PID 1
ENTRYPOINT ["tini", "-s", "--"]

ARG PYBIOCLIP_VERSION

# Install pybioclip from the release archive because pypi can take a while to start working.
RUN pip install "https://github.com/Imageomics/pybioclip/archive/refs/tags/${PYBIOCLIP_VERSION}.tar.gz" && \
pip cache purge

# Create a non-root user with a home directory to help cache pybioclip files
RUN useradd -ms /bin/bash bcuser
USER bcuser
ENV PATH="$PATH:/home/bcuser/.local/bin"
WORKDIR /home/bcuser

0 comments on commit 12c503d

Please sign in to comment.