Skip to content

Commit

Permalink
Merge pull request #15 from CCBR/iss-9_docker
Browse files Browse the repository at this point in the history
feat: create Dockerfile & automatically build on release
  • Loading branch information
kelly-sovacool authored Dec 28, 2023
2 parents b39a2bf + 9e8f003 commit 7a8d8d5
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 0 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
^\.prettierignore$
^\.prettierrc$
^data-raw$
^Dockerfile$
57 changes: 57 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: docker

on:
# push:
# paths:
# - ".github/workflows/docker.yml"
# - "DESCRIPTION"
# - "Dockerfile"
workflow_dispatch:
release:
types: [published]

env:
IMAGE_NAME: "reneetools"
CONTEXT: "./"
NAMESPACE: "nciccbr"

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 }}
else
HASH=$(echo "${{ github.sha }}" | cut -c1-7)
VERSION="$(grep 'Version:' $CONTEXT/DESCRIPTION | sed 's/Version: //')_$HASH"
fi
echo "VERSION_TAG=$(echo $VERSION)" >> "$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: ${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.VERSION_TAG }}
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 }}
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Imports:
Suggests:
readr,
testthat (>= 3.0.0)
biocViews:
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Expand Down
96 changes: 96 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
FROM ubuntu:20.04

# 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}

RUN mkdir -p /opt2 && mkdir -p /data2
ENV TZ=America/New_York
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt update && apt-get -y upgrade
# Set the locale
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
locales build-essential cmake cpanminus && \
localedef -i en_US -f UTF-8 en_US.UTF-8 && \
cpanm FindBin Term::ReadLine

# install basic dependencies with apt-get
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
g++ \
gcc \
gfortran \
git \
libatlas-base-dev \
libblas-dev \
libboost-dev \
libbz2-dev \
libcurl4-openssl-dev \
libexpat1-dev \
libfreetype6-dev \
libgd-dev \
libgd-perl \
libglib2.0-dev \
libgpgme11-dev \
libgs-dev \
libgsl-dev \
libgsl0-dev \
libhtml-template-compiled-perl \
libicu-dev \
libjudy-dev \
liblapack-dev \
liblzma-dev \
libmysqlclient-dev \
libncurses-dev \
libopenmpi-dev \
libpng-dev \
librtmp-dev \
libseccomp-dev \
libssl-dev \
libtool \
libxml-libxml-debugging-perl \
libxml-opml-simplegen-perl \
libxml2-dev \
libxslt-dev \
make \
manpages-dev \
openjdk-17-jre-headless \
parallel \
pigz \
pkg-config \
rsync \
squashfs-tools \
unzip \
uuid-dev \
wget \
zlib1g \
zlib1g-dev \
zlibc

# 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"

# install devtools
RUN mamba install -c conda-forge r-base=4.3.2 r-devtools

# install R package
COPY . /opt2/reneeTools
RUN R -e 'devtools::install("/opt2/reneeTools")'

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

COPY Dockerfile /opt2/Dockerfile
RUN chmod -R a+rX /opt2/Dockerfile

WORKDIR /data2

0 comments on commit 7a8d8d5

Please sign in to comment.