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
67 changes: 67 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: Build and Push Docker Image

on: # yamllint disable-line rule:truthy
push:
branches: [master, development]
paths:
- .github/workflows/docker.yml
- version.mpralib.txt
- workflow/envs/Dockerfile_mpralib
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Read mpralib version from version file
id: mpralib_version
run: |
VERSION=$(tr -d '[:space:]' < version.mpralib.txt)
if [[ -z "$VERSION" ]]; then
echo "version.mpralib.txt is empty"
exit 1
fi
if [[ ! "$VERSION" =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
echo "Invalid version format in version.mpralib.txt: $VERSION"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Check if Docker tag already exists
id: tag_exists
run: |
TAG="visze/mpralib:${{ steps.mpralib_version.outputs.version }}"
if docker manifest inspect "$TAG" > /dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Tag already exists on Docker Hub: $TAG"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Tag does not exist yet: $TAG"
fi

- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Build and push Docker image
if: steps.tag_exists.outputs.exists == 'false'
uses: docker/build-push-action@v6
with:
context: .
file: workflow/envs/Dockerfile_mpralib
push: true
tags: visze/mpralib:${{ steps.mpralib_version.outputs.version }}
build-args: |
MPRALIB_VERSION=${{ steps.mpralib_version.outputs.version }}
1 change: 1 addition & 0 deletions version.mpralib.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.10.5
4 changes: 3 additions & 1 deletion workflow/envs/Dockerfile_mpralib
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FROM ghcr.io/prefix-dev/pixi:latest

RUN pixi global install "python>=3.10" "mpralib==0.10.4" "htslib" conda -c conda-forge -c bioconda
ARG MPRALIB_VERSION

RUN pixi global install "python>=3.10" "mpralib==${MPRALIB_VERSION}" "htslib" conda -c conda-forge -c bioconda
2 changes: 1 addition & 1 deletion workflow/envs/mpralib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ channels:
- bioconda
dependencies:
- python>=3.10
- mpralib==0.10.4
- mpralib==0.10.5
- htslib
14 changes: 14 additions & 0 deletions workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from snakemake.utils import validate

SCRIPTS_DIR = "../scripts"
ENVS_DIR = "../envs"
MPRALIB_VERSION_FILE = "../../version.mpralib.txt"


def getWorkflowFile(dir_name, name):
Expand All @@ -18,6 +19,19 @@ def getCondaEnv(name):
return getWorkflowFile(ENVS_DIR, name)


def getMpralibVersion():
with open(workflow.source_path(MPRALIB_VERSION_FILE)) as f:
mpralib_version = f.read().strip()
if not mpralib_version:
raise WorkflowError("version.mpralib.txt is empty.")
return mpralib_version


MPRALIB_VERSION = getMpralibVersion()
VISZE_MPRALIB_CONTAINER = f"docker://visze/mpralib:{MPRALIB_VERSION}"
QUAY_MPRALIB_CONTAINER = f"docker://quay.io/biocontainers/mpralib:{MPRALIB_VERSION}--pyhdfd78af_0"


def getLabelFile():
if "label_file" in config:
return config["label_file"]
Expand Down
6 changes: 3 additions & 3 deletions workflow/rules/elements.smk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rule get_element_counts:
conda:
getCondaEnv("mpralib.yaml")
container:
"docker://quay.io/biocontainers/mpralib:0.10.4--pyhdfd78af_0"
QUAY_MPRALIB_CONTAINER
threads: 1
resources:
mem_mb=lambda wc, input: calc_mem_gb(input[0], 75) * 1024, # Adjust memory based on input size
Expand Down Expand Up @@ -85,7 +85,7 @@ rule get_reporter_elements:
conda:
getCondaEnv("mpralib.yaml")
container:
"docker://quay.io/biocontainers/mpralib:0.10.4--pyhdfd78af_0"
QUAY_MPRALIB_CONTAINER
threads: 1
resources:
mem_mb=lambda wc, input: calc_mem_gb(input[0], 50) * 1024, # Adjust memory based on input size
Expand Down Expand Up @@ -116,7 +116,7 @@ rule get_reporter_genomic_elements:
conda:
getCondaEnv("mpralib.yaml")
container:
"docker://visze/mpralib:0.10.4"
VISZE_MPRALIB_CONTAINER
threads: 1
resources:
mem_mb=lambda wc, input: calc_mem_gb(input[0], 50) * 1024, # Adjust memory based on input size
Expand Down
8 changes: 4 additions & 4 deletions workflow/rules/variants.smk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rule get_variant_counts:
conda:
getCondaEnv("mpralib.yaml")
container:
"docker://quay.io/biocontainers/mpralib:0.10.4--pyhdfd78af_0"
QUAY_MPRALIB_CONTAINER
threads: 1
resources:
mem_mb=lambda wc, input: calc_mem_gb(input[0], 75) * 1024, # Adjust memory based on input size
Expand Down Expand Up @@ -44,7 +44,7 @@ rule get_variant_map:
conda:
getCondaEnv("mpralib.yaml")
container:
"docker://quay.io/biocontainers/mpralib:0.10.4--pyhdfd78af_0"
QUAY_MPRALIB_CONTAINER
threads: 1
resources:
mem_mb=lambda wc, input: calc_mem_gb(input[0], 10) * 1024, # Adjust memory based on input size
Expand Down Expand Up @@ -135,7 +135,7 @@ rule get_reporter_variants:
conda:
getCondaEnv("mpralib.yaml")
container:
"docker://quay.io/biocontainers/mpralib:0.10.4--pyhdfd78af_0"
QUAY_MPRALIB_CONTAINER
threads: 1
resources:
mem_mb=lambda wc, input: calc_mem_gb(input[1], 75) * 1024, # Adjust memory based on input size
Expand Down Expand Up @@ -168,7 +168,7 @@ rule get_reporter_genomic_variants:
conda:
getCondaEnv("mpralib.yaml")
container:
"docker://visze/mpralib:0.10.4"
VISZE_MPRALIB_CONTAINER
threads: 1
resources:
mem_mb=lambda wc, input: calc_mem_gb(input[1], 75) * 1024, # Adjust memory based on input size
Expand Down
Loading