diff --git a/.Rbuildignore b/.Rbuildignore index 923b852..360db7d 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -10,3 +10,4 @@ ^\.prettierignore$ ^\.prettierrc$ ^data-raw$ +^Dockerfile$ diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..0d16270 --- /dev/null +++ b/.github/workflows/docker.yml @@ -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 }} diff --git a/DESCRIPTION b/DESCRIPTION index 1798a6e..40c34ff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,6 +23,7 @@ Imports: Suggests: readr, testthat (>= 3.0.0) +biocViews: Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4a69b1e --- /dev/null +++ b/Dockerfile @@ -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