Skip to content

Commit

Permalink
Merge pull request #105 from olliecheng/docker_images
Browse files Browse the repository at this point in the history
Updated Dockerfile for easier deployment and consistent builds
  • Loading branch information
nadiadavidson authored Aug 21, 2024
2 parents 04209e9 + ee5cfbb commit bab028b
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 421 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.gitignore
.git/
Dockerfile
**/*.md
71 changes: 71 additions & 0 deletions .github/workflows/create_docker_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This Action is adapted from the GitHub Docs, located at:
# http://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages

name: "Publish JAFFA Docker image"

# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
workflow_dispatch:
inputs:
version:
description: 'JAFFA version to tag with'
required: true
latest:
description: 'Set the :latest Docker tag. Only enable for release builds, as it is recommended that users install the software at the :latest tag.'
required: true
default: true
type: boolean

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,priority=1000,enable=${{ github.event.inputs.latest }}
type=raw,value=${{ github.event.inputs.version }},priority=900
type=sha,prefix={{branch}}-
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
70 changes: 70 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# syntax=docker/dockerfile:1

# must use bookworm for directly compatible R version >=4.4.0
FROM debian:bullseye-slim AS base

# get latest version of R: https://cran.r-project.org/bin/linux/debian/
RUN apt-get update
RUN apt-get install -y gnupg2
RUN apt-get install -y perl python3

# set locale
RUN apt-get install -y locales
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8

RUN gpg --keyserver keyserver.ubuntu.com \
--recv-key '95C0FAF38DB3CCAD0C080A7BDC78B2DDEABC47B7'
RUN gpg --armor --export '95C0FAF38DB3CCAD0C080A7BDC78B2DDEABC47B7' | \
tee /etc/apt/trusted.gpg.d/cran_debian_key.asc

RUN echo 'deb http://cloud.r-project.org/bin/linux/debian bullseye-cran40/' >> /etc/apt/sources.list

RUN apt-get update

# fix version of Java for bpipe 0.9.9.2
RUN apt-get install -y r-base-core r-bioc-iranges openjdk-11-jre --no-install-recommends

# install libncurses.so.6 for minimap2
RUN apt-get install -y libncurses6 --no-install-recommends


FROM base AS build
# install useful tools for building non-R software
# this is placed after the R installs so that they can
# be cached
RUN apt-get install -y build-essential wget make cmake unzip zip python3 zlib1g-dev libncurses-dev


WORKDIR /JAFFA

COPY ./install_linux64.sh .
COPY ./src ./src

RUN ./install_linux64.sh

COPY . .

# set a reference file path to /ref for easy binding
RUN sed -i 's/refBase = codeBase/refBase = "\/ref"/' JAFFA_stages.groovy

# we only need this to run the image
FROM base

LABEL org.opencontainers.image.title "JAFFA" \
org.opencontainers.image.description "High sensitivity transcriptome-focused fusion gene detection." \
org.opencontainers.image.authors "Davidson, N.M., Majewski, I.J. & Oshlack, A." \
org.opencontainers.image.source "https://github.com/Oshlack/JAFFA" \
org.opencontainers.image.documentation "https://github.com/Oshlack/JAFFA/wiki/HowToSetUpJAFFA#docker"


COPY --from=build /JAFFA /JAFFA
# RUN strip --strip-debug /usr/local/lib/R/site-library/*/libs/*.so

RUN apt remove -y gcc
RUN apt autoremove

ENV PATH=${PATH}:/JAFFA/tools/bin:/JAFFA

ENTRYPOINT ["/JAFFA/tools/bin/bpipe", "run"]
136 changes: 0 additions & 136 deletions docker/Dockerfile

This file was deleted.

106 changes: 0 additions & 106 deletions docker/Dockerfile.v1.09

This file was deleted.

Loading

0 comments on commit bab028b

Please sign in to comment.