diff --git a/.Rbuildignore b/.Rbuildignore index c47772ae..96f95038 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,4 +12,6 @@ pipeline_stores ^[^/]*\.r$ ^tests$ _targets -target_framework \ No newline at end of file +target_framework +^Dockerfile$ +^\\.dockerignore$ diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..d19c8cf1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git +.github +.Rproj.user +renv +renv.lock +pipeline_store +_targets diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 00000000..7b7be68b --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,56 @@ +name: docker-image + +on: + push: + branches: + - main + - master + tags: + - 'v*' + pull_request: + branches: + - main + - master + workflow_dispatch: + +jobs: + build-and-publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/hpcell + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..e4ed4d77 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM ghcr.io/bioconductor/bioconductor_docker:RELEASE_3_21 + +COPY . /opt/HPCell +RUN R -q -e "desc <- read.dcf('/opt/HPCell/DESCRIPTION'); pkgs <- unique(trimws(unlist(strsplit(paste(desc[1, c('Depends', 'Imports')], collapse = ','), ',')))); pkgs <- sub('\\\\s*\\\\(.*\\\\)', '', pkgs); pkgs <- pkgs[pkgs != '' & pkgs != 'R']; repos <- c(CRAN = 'https://cloud.r-project.org', BioCsoft = 'https://bioconductor.org/packages/3.21/bioc', BioCann = 'https://bioconductor.org/packages/3.21/data/annotation', BioCexp = 'https://bioconductor.org/packages/3.21/data/experiment', BioCworkflows = 'https://bioconductor.org/packages/3.21/workflows'); install.packages(pkgs, repos = repos)" +RUN R CMD INSTALL /opt/HPCell + +WORKDIR /work +CMD ["R"] diff --git a/README.md b/README.md index c17d21b9..1a17c3af 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,15 @@ The key features of HPCell include: remotes::install_github("MangiolaLaboratory/HPCell") ``` +### Docker image + +GitHub Actions now publishes a pre-built container image to GHCR: + +``` bash +docker pull ghcr.io/mangiolalaboratory/hpcell:main +docker run --rm -it ghcr.io/mangiolalaboratory/hpcell:main +``` + ## The input The pipeline accepts a vector of file paths. If this vector is named, diff --git a/README.rmd b/README.rmd index b34ad1a7..6c396cd4 100644 --- a/README.rmd +++ b/README.rmd @@ -39,6 +39,15 @@ remotes::install_github("MangiolaLaboratory/HPCell") ``` +### Docker image + +GitHub Actions now publishes a pre-built container image to GHCR: + +```{bash, eval=FALSE} +docker pull ghcr.io/mangiolalaboratory/hpcell:main +docker run --rm -it ghcr.io/mangiolalaboratory/hpcell:main +``` + ## The input The pipeline accepts a vector of file paths. @@ -724,4 +733,3 @@ By summarizing single-cell data into groups, it mimics traditional bulk RNA-seq ... |> tidySingleCellExperiment::aggregate_cells(!!x, slot = "data", assays=assays) ``` -