Skip to content

Commit

Permalink
update samtools version + update actions + clean up (#19)
Browse files Browse the repository at this point in the history
* BIO-2033 change env vars to v1.19

* rm transformBAM.sh

* rm commented code

* rm transformBAM.sh from Dockerfile

* rm scripts to test transformBAM.sh

* update to new github actions

* rm Dockerfile-test

* rm checkFileSize.R

* rm test-data

* don't copy entrypoint.sh because it's gone

* update README.md

did check versions of packages installed via apt, the correct versions are listed
  • Loading branch information
katgorski authored Feb 8, 2024
1 parent 73f1602 commit 9e59f48
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 332 deletions.
25 changes: 0 additions & 25 deletions .github/actions/action.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/actions/entrypoint.sh

This file was deleted.

175 changes: 125 additions & 50 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ on:
pull_request:

env:
# TODO: Change variable to your image's name.
IMAGE_NAME: bioinformatics

jobs:
Expand All @@ -27,61 +26,137 @@ jobs:
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into GitHub Container Registry
run: echo "${{ secrets.GHCR_TOKEN }}" | docker login https://ghcr.io -u ${{ secrets.GHCR_SVC_ACCOUNT }} --password-stdin

- name: Push image to GitHub Container Registry
- uses: actions/checkout@v4
with:
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- name: Set Date
run: echo "TODAYS_DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV

- name: Prepare tags
id: prep
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
# Docker Registries
GHCR_IMAGE_NAME="ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}"
DOCKER_HUB_IMAGE_NAME="${{ github.repository_owner }}/${{ env.IMAGE_NAME }}"
TAGS=""
FINAL_TAGS=""
# Identify Tags
# Type of tags:
# 1. Scenario 1 - x.y.z.patchedYYYYMMDD
# 2. Scenario 2 - Semver Tags x.y.z
# 3. Scenario 3 - Main Branch
# 4. Scenario 4 - Branches
if [[ $GITHUB_REF == refs/tags/* ]]; then
# If this is a tag push, use the tag name (stripping 'refs/tags/')
FULL_TAG=${GITHUB_REF#refs/tags/}
# Remove leading 'v' from tag if present
if [[ $FULL_TAG == v* ]]; then
FULL_TAG=${FULL_TAG#v}
fi

# Scenario 1 - x.y.z.patchedYYYYMMDD
# Tags
# 1. x.y.z.patchedYYYYMMDD
# 2. x.y.z
# 3. x.y
# 4. x
if [[ $FULL_TAG =~ (.*)\.patched[0-9]+ ]]; then
# Extract the base tag without the .patched segment
BASE_TAG=${BASH_REMATCH[1]}

if [[ $BASE_TAG =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}

TAGS="$FULL_TAG,$BASE_TAG,$MAJOR.$MINOR.$PATCH,$MAJOR.$MINOR,$MAJOR"
fi
else
# Scenario 2 - Semver Tags x.y.z
# Tags
# 1. x.y.z
# 2. x.y
# 3. x
if [[ $FULL_TAG =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}

TAGS="$MAJOR.$MINOR.$PATCH,$MAJOR.$MINOR,$MAJOR"
fi
fi
elif [[ $GITHUB_REF == refs/heads/main ]]; then
# Scenario 3 - Main Branch
# If this is a push to main, use 'latest'
TAGS="latest"
else
# Scenario 4 - Branches
# Otherwise, use the branch name, replacing non-alphanumeric characters with underscores
TAG=$(echo ${GITHUB_REF#refs/heads/} | sed 's/[^a-zA-Z0-9]/_/g')
TAGS=$TAG
fi

# For each tag, prepend the registry name and output a newline-separated list
for tag in $(echo "$TAGS" | tr ',' '\n'); do
FINAL_TAGS="$FINAL_TAGS $GHCR_IMAGE_NAME:$tag,"
FINAL_TAGS="$FINAL_TAGS $DOCKER_HUB_IMAGE_NAME:$tag,"
done

FINAL_TAGS=${FINAL_TAGS%,}

echo "tags=${FINAL_TAGS}" >> $GITHUB_OUTPUT

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
labels:
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.description=Bioinformatics Tools
org.opencontainers.image.vendor=Englander Institute for Precision Medicine
maintainer=Andrea Sboner <[email protected]>
org.opencontainers.image.authors=Andrea Sboner <[email protected]>

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

docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Log into GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_SVC_ACCOUNT }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Login to EIPM DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.EIPM_DOCKER_HUB_USERNAME }}
password: ${{ secrets.EIPM_DOCKER_HUB_TOKEN }}

- name: Push image to EIPM Docker Hub
run: |
IMAGE_ID=eipm/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Build and push to Docker Hub and GitHub Container Registry
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
file: ./Dockerfile
sbom: true
push: true
provenance: mode=max
tags: ${{ steps.prep.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:cache,mode=max

27 changes: 0 additions & 27 deletions .github/workflows/main.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/monthly-patching.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Monthly Patching

on:
schedule:
# Runs at 00:00 on the first day of every month
- cron: '30 6 29 * *'

jobs:
tag:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{secrets.GHCR_TOKEN}}

- name: Set up Git
run: |
git config --global user.name "eipmgithubsvc1"
git config --global user.email "[email protected]"
- name: Get the latest release
id: latest-release
uses: actions/github-script@v7
with:
script: |
const release = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
return release.data.tag_name;
- name: Generate new tag
run: |
ORIGINAL_TAG=${{ steps.latest-release.outputs.result }}
if [[ $ORIGINAL_TAG == *".patched"* ]]; then
BASE_TAG=${ORIGINAL_TAG%%.patched*}
else
BASE_TAG=$ORIGINAL_TAG
fi
DATE=$(date +'%Y%m%d')
echo "NEW_TAG=$BASE_TAG.patched$DATE" >> $GITHUB_ENV
- name: Create and push tag
run: |
git tag $NEW_TAG
git push origin $NEW_TAG
30 changes: 4 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ RUN apt-get update \
#===========================#
# Install SAMTOOLS & HTSLIB #
#===========================#
ENV SAMTOOLS_VERSION 1.9
ENV HTSLIB_VERSION 1.9
ENV SAMTOOLS_VERSION 1.19
ENV HTSLIB_VERSION 1.19
ENV samtools_dir /${PROGRAMS}/samtools-${SAMTOOLS_VERSION}
ENV htslib_dir ${samtools_dir}/htslib-${HTSLIB_VERSION}
RUN wget -O samtools-${SAMTOOLS_VERSION}.tar.bz2 https://github.com/samtools/samtools/releases/download/${SAMTOOLS_VERSION}/samtools-${SAMTOOLS_VERSION}.tar.bz2 \
Expand Down Expand Up @@ -75,8 +75,8 @@ ENV APP_NAME="bioinformatics" \
TZ='US/Eastern' \
PROGRAMS="opt" \
STAR_VERSION='2.7.6a' \
SAMTOOLS_VERSION='1.9' \
HTSLIB_VERSION='1.9'
SAMTOOLS_VERSION='1.19' \
HTSLIB_VERSION='1.19'

RUN apt-get update \
&& apt-get upgrade -y --fix-missing \
Expand All @@ -101,25 +101,3 @@ RUN Rscript /R/scripts/installPackages.R

### Add utilities file
COPY combine_pindel_vcfs.sh ${PROGRAMS}
COPY transformBAM.sh /usr/local/bin/
RUN chmod ugo+x /usr/local/bin/transformBAM.sh

### Add test data
COPY test-data/ /test-data/

### ADD entrypoint data
COPY .github/actions/entrypoint.sh /

#===========================#
# Security Updates #
#===========================#
# ENV GHOSTSCRIPT_VER 9.52
# ENV GS_VER 952
# ENV GHOSTSCRIPT_DIR /${PROGRAMS}/ghostscript-${GHOSTSCRIPT_VER}
# RUN wget -O ghostscript-${GHOSTSCRIPT_VER}.tar.gz https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/ghostscript-9.52.tar.gz \
# && tar -vxzf ghostscript-${GHOSTSCRIPT_VER}.tar.gz -C ${PROGRAMS} \
# && rm ghostscript-${GHOSTSCRIPT_VER}.tar.gz \
# && cd ${GHOSTSCRIPT_DIR} \
# && ./configure \
# && make \
# && make install
3 changes: 0 additions & 3 deletions Dockerfile-test

This file was deleted.

Loading

0 comments on commit 9e59f48

Please sign in to comment.