diff --git a/.github/workflows/build_container.yml b/.github/workflows/build_container.yml new file mode 100644 index 0000000..a823f38 --- /dev/null +++ b/.github/workflows/build_container.yml @@ -0,0 +1,61 @@ +name: Build Image using Containerfile +on: + push: + branches: + - 'development' + tags: + + pull_request: + types: + - opened + - synchronize + branches: + - 'development' + +permissions: + packages: write + contents: read + +jobs: + build: + name: Build image + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Determine tags + shell: bash + env: + REF_TYPE: ${{ github.ref_type }} + SHA: ${{ github.sha }} + EVENT_NAME: ${{ github.event_name }} + run: | + if [[ "${EVENT_NAME}" == "pull_request" ]]; then + echo "BASE_TAGS=${SHA}" | tee -a "${GITHUB_ENV}" + elif [[ "${REF_TYPE}" == "tag" ]]; then + echo "BASE_TAGS=latest ${GITHUB_REF#refs/*/} ${SHA}" | tee -a "${GITHUB_ENV}" + elif [[ "${REF_TYPE}" == "branch" ]]; then + echo "BASE_TAGS=${GITHUB_REF#refs/*/} ${SHA}" | tee -a "${GITHUB_ENV}" + else + echo "BASE_TAGS=${SHA}" | tee -a "${GITHUB_ENV}" + fi + + - name: Buildah Action + id: build_image + uses: redhat-actions/buildah-build@v2 + with: + image: CoverageCalculatorPy + tags: ${{ env.BASE_TAGS }} + containerfiles: | + ./Containerfile + + - name: Push to GHCR + uses: redhat-actions/push-to-registry@v2 + if: github.event_name != 'pull_request' + with: + image: ${{ steps.build_image.outputs.image }} + tags: ${{ steps.build_image.outputs.tags }} + registry: ghcr.io/awgl + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..783e31f --- /dev/null +++ b/Containerfile @@ -0,0 +1,10 @@ +FROM docker.io/python:3.11 + +# Copy script into folder +COPY CoverageCalculatorPy.py /usr/bin/ + +RUN chmod +x /usr/bin/CoverageCalculatorPy.py + +# Install pytabix +RUN pip install pytabix==0.1 + diff --git a/env/CoverageCalculatorPy.def b/env/CoverageCalculatorPy.def new file mode 100644 index 0000000..d742da7 --- /dev/null +++ b/env/CoverageCalculatorPy.def @@ -0,0 +1,15 @@ +Bootstrap: docker +From: python:3.11 + +%files + ../CoverageCalculatorPy.py /usr/bin/CoverageCalculatorPy.py + +%post + # Make script executable + chmod +x /usr/bin/CoverageCalculatorPy.py + + # Install pytabix + pip install pytabix==0.1 + +%runscript + exec "$@" diff --git a/env/CoverageCalculatorPy.yml b/env/CoverageCalculatorPy.yml index adc30e8..b3139eb 100644 --- a/env/CoverageCalculatorPy.yml +++ b/env/CoverageCalculatorPy.yml @@ -4,8 +4,6 @@ channels: - bioconda - defaults dependencies: - - python=3.6.7 - - zlib=1.2.11 - - pip: - - pytabix==0.1 + - python=3.11 + - pytabix=0.1