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

on:
workflow_dispatch:
release:
types: [published]

env:
IMAGE_NAME: "scworkflow" # must be lowercase
CONTEXT: "./"
NAMESPACE: "nciccbr"

permissions: read-all

jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare build-time variables
id: vars
run: |
echo "DATE=$(date +"%Y-%m-%d")" >> "$GITHUB_OUTPUT"

if [ '${{ github.event_name }}' == 'release' ]; then
VERSION=${{ github.ref_name }}
DOCKER_TAGS=${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${VERSION},${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:latest
else
HASH=$(git rev-parse --short HEAD)
VERSION="$(grep 'Version:' $CONTEXT/DESCRIPTION | sed 's/Version: /v/')_${HASH}"
DOCKER_TAGS=${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${VERSION}
fi
echo "VERSION_TAG=$(echo $VERSION)" >> "$GITHUB_OUTPUT"
echo "DOCKER_TAGS=$(echo $DOCKER_TAGS)" >> "$GITHUB_OUTPUT"

- name: debug
run: |
echo "the github tag is ${{ github.ref_name }}"
echo "github event_name is ${{ github.event_name }}"
echo "the version tag is ${{ steps.vars.outputs.VERSION_TAG }}"

- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.vars.outputs.DOCKER_TAGS }} # include 'latest' tag if this is a release
context: ${{ env.CONTEXT }}
file: ${{ env.CONTEXT }}/Dockerfile
build-args: |
BUILD_DATE=${{ steps.vars.outputs.DATE }}
BUILD_TAG=${{ steps.vars.outputs.VERSION_TAG }}
REPONAME=${{ env.IMAGE_NAME }}
R_VERSION=4.3.2
64 changes: 64 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM nciccbr/ccbr_ubuntu_22.04:v4

# build time variables
ARG BUILD_DATE="000000"
ENV BUILD_DATE=${BUILD_DATE}
ARG BUILD_TAG="000000"
ENV BUILD_TAG=${BUILD_TAG}
ARG REPONAME="000000"
ENV REPONAME=${REPONAME}

ARG R_VERSION=4.3.2
ENV R_VERSION=${R_VERSION}

SHELL ["/bin/bash", "-lc"]

# Install conda and give write permissions to conda folder
RUN echo 'export PATH=/opt2/conda/bin:$PATH' > /etc/profile.d/conda.sh && \
wget --quiet "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" -O ~/miniforge3.sh && \
/bin/bash ~/miniforge3.sh -b -p /opt2/conda && \
rm ~/miniforge3.sh && chmod 777 -R /opt2/conda/
ENV PATH="/opt2/conda/bin:$PATH"

# Pin channels and update
RUN conda config --add channels conda-forge \
&& conda config --add channels bioconda \
&& conda config --set channel_priority strict

# install conda packages
RUN mamba install -y -c conda-forge \
r-base=${R_VERSION} \
r-devtools \
r-ggplot2 \
r-ggrepel r-viridis r-upsetr r-patchwork r-plotly \
r-matrix r-mgcv r-survival \
bioconductor-genomicranges \
bioconductor-summarizedexperiment \
bioconductor-delayedarray \
bioconductor-s4arrays \
bioconductor-annotationdbi \
bioconductor-annotate \
bioconductor-keggrest \
&& conda clean -afy

# install R package
COPY . /opt2/SCWorkflow
RUN R -e "devtools::install_local('/opt2/SCWorkflow', dependencies = TRUE, repos='http://cran.rstudio.com')"

# add scworkflow exec to the path
# RUN chmod -R +x /opt2/conda/lib/R/library/SCWorkflow/exec
# ENV PATH="$PATH:/opt2/conda/lib/R/library/SCWorkflow/exec"
# RUN scworkflow --help

# copy example script & json to data
COPY ./inst/extdata/example_script.sh /data2/
COPY ./inst/extdata/json_args/ /data2/json_args/

# Save Dockerfile in the docker
COPY Dockerfile /opt2/Dockerfile_${REPONAME}.${BUILD_TAG}
RUN chmod a+r /opt2/Dockerfile_${REPONAME}.${BUILD_TAG}

# cleanup
WORKDIR /data2
RUN apt-get clean && apt-get purge \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Loading