Skip to content

Commit

Permalink
ci: set up gh actions to build & push docker containers
Browse files Browse the repository at this point in the history
towards #1
  • Loading branch information
kelly-sovacool committed Sep 5, 2023
1 parent fd31834 commit d42560d
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 0 deletions.
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
- "docker/**"
workflow_dispatch:

jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix-metadata: ${{ steps.metadata.outputs.matrix }}
steps:
- uses: hellofresh/action-changed-files@v3
id: metadata
with:
pattern: docker/(?P<image_dir>\w+)/.*
default-patterns: |
meta.yml
Dockerfile
update-docker:
needs: [generate-matrix]
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix-metadata) }}
if: ${{ fromJson(needs.generate-matrix.outputs.matrix-metadata).include[0] }} # skip if the matrix is empty!
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pietrobolcato/[email protected]
id: metadata
with:
config: ${{ github.workspace }}/docker/${{ matrix.image_dir }}/meta.yml
- name: Get date
id: date
run: |
echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_OUTPUT
- 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
# only try building & pushing the container if parsing the metadata worked
if: ${{ steps.metadata.outputs['container'] != '' }}
with:
context: docker/${{ matrix.image_dir }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metadata.outputs['container'] }}
build-args: |
BUILD_DATE=${{ steps.date.outputs.DATE }}
BUILD_TAG=${{ steps.metadata.outputs['version'] }}
REPONAME=${{ steps.metadata.outputs['image_name'] }}
4 changes: 4 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Containers for CRUISE

Dockerfiles to create containers for processes in this nextflow workflow.
These containers are built and pushed to dockerhub automatically when files in this directory change.
30 changes: 30 additions & 0 deletions docker/bagel/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM nciccbr/ccbr_ubuntu_base_20.04:v5

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

# download bagel scripts and install dependencies
RUN python3 -m pip install --upgrade pip
RUN pip3 install click numpy scipy scikit-learn
ADD https://github.com/hart-lab/bagel/archive/refs/tags/v2.0-115.tar.gz /opt2
WORKDIR /opt2
RUN tar -xzvf v2.0-115.tar.gz && rm -f v2.0-115.tar.gz
ENV PATH="${PATH}:/opt2/bagel-2.0-115"

# cleanup etc
# Save Dockerfile in the docker
COPY Dockerfile /opt2/Dockerfile_${REPONAME}.${BUILD_TAG}
RUN chmod a+r /opt2/Dockerfile_${REPONAME}.${BUILD_TAG}
#COPY argparse.bash /opt2
RUN chmod -R a+rx /opt2/argparse.bash
ENV PATH="/opt2/:$PATH"
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
apt-get autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/{apt,dpkg,cache,log}/
WORKDIR /data2
1 change: 1 addition & 0 deletions docker/bagel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Container for bagel processes in CRUISE
4 changes: 4 additions & 0 deletions docker/bagel/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dockerhub_namespace: kellysovacool
image_name: bagel
version: test
container: "$(dockerhub_namespace)/$(image_name):$(version)"
31 changes: 31 additions & 0 deletions docker/drugz/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM nciccbr/ccbr_ubuntu_base_20.04:v5

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

# download drugz script and install dependencies
RUN python3 -m pip install --upgrade pip
RUN pip3 install six numpy pandas scipy argparse
ADD https://github.com/hart-lab/drugz/archive/refs/heads/master.zip /opt2
WORKDIR /opt2
RUN ls
RUN unzip master.zip && rm -f master.zip
ENV PATH="${PATH}:/opt2/drugz-master"

# cleanup etc
# Save Dockerfile in the docker
COPY Dockerfile /opt2/Dockerfile_${REPONAME}.${BUILD_TAG}
RUN chmod a+r /opt2/Dockerfile_${REPONAME}.${BUILD_TAG}
#COPY argparse.bash /opt2
RUN chmod -R a+rx /opt2/argparse.bash
ENV PATH="/opt2/:$PATH"
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
apt-get autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/{apt,dpkg,cache,log}/
WORKDIR /data2
3 changes: 3 additions & 0 deletions docker/drugz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# drugz

Container for drugz processes in CRUISE
4 changes: 4 additions & 0 deletions docker/drugz/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dockerhub_namespace: kellysovacool
image_name: drugz
version: test
container: "$(dockerhub_namespace)/$(image_name):$(version)"
Empty file added docker/mageck/Dockerfile
Empty file.

0 comments on commit d42560d

Please sign in to comment.