Skip to content

Commit

Permalink
Merge pull request #9 from ncsa/docker
Browse files Browse the repository at this point in the history
update docker
  • Loading branch information
robkooper authored Nov 11, 2024
2 parents cd387d5 + ae06daf commit 92460d1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 81 deletions.
107 changes: 37 additions & 70 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,63 +23,33 @@ jobs:
packages: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# calculate some variables that are used later
- name: variable setup
run: |
if [ "${{ github.event.release.target_commitish }}" != "" ]; then
BRANCH="${{ github.event.release.target_commitish }}"
elif [[ $GITHUB_REF =~ pull ]]; then
BRANCH="$(echo $GITHUB_REF | sed 's#refs/pull/\([0-9]*\)/merge#PR-\1#')"
else
BRANCH=${GITHUB_REF##*/}
fi
push="false"
if [ "$BRANCH" == "main" ]; then
version="$(awk '/^## / { print tolower($2) }' CHANGELOG.md | head -1)"
tags="latest"
oldversion=""
while [ "${oldversion}" != "${version}" ]; do
oldversion="${version}"
tags="${tags} ${version}"
version=${version%.*}
done
version="$(awk '/^## / { print tolower($2) }' CHANGELOG.md | head -1)"
push="true"
elif [ "$BRANCH" == "develop" ]; then
version="develop"
tags="develop"
else
version="test"
tags="${BRANCH}"
fi
push_tags=""
for tag in ${tags}; do
push_tags="${push_tags}ncsa/checks:${tag},"
push_tags="${push_tags}ghcr.io/${{ github.repository_owner }}/checks:${tag},"
done
push_tags="${push_tags%,*}"
echo "BRANCH=${BRANCH}"
echo "VERSION=${version}"
echo "TAGS=${tags}"
echo "PUSH_TAGS=${push_tags}"
echo "PUSH=${push}" >> $GITHUB_ENV
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
echo "VERSION=${version}" >> $GITHUB_ENV
echo "TAGS=${push_tags}" >> $GITHUB_ENV
# create metadata for image
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ncsa/checks
ghcr.io/ncsa/checks
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
# setup docker build
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Inspect Builder
run: |
Expand All @@ -91,37 +61,34 @@ jobs:
# login to registries
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# build the docker images
- name: Build and push docker image
uses: docker/build-push-action@v2
# update README at DockerHub
- name: Build and push ${{ matrix.name }}
uses: docker/build-push-action@v6
with:
push: ${{ env.PUSH }}
#push: ${{ github.event_name != 'pull_request' }}
push: true
platforms: "linux/amd64,linux/arm64"
cache-from: type=registry,ref=ncsa/checks-cache:${{ env.BRANCH }}
cache-to: type=registry,ref=ncsa/checks-cache:${{ env.BRANCH }},mode=max
tags: ${{ env.TAGS }}
build-args: |
VERSION=${{ env.VERSION }}
GITSHA1=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# update README at DockerHub
- name: Docker Hub Description
if: github.event_name == 'push' && env.BRANCH == 'main'
uses: peter-evans/dockerhub-description@v2
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_REPOSITORY: ncsa/checks
README_FILEPATH: README.md
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: ncsa/checks
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.1.0 - 2024-11-11

### Added
- building arm image

### Changed
- using python 3.11
- updated docker github action

## 1.0.1 - 2022-07-25

### Added
Expand Down
11 changes: 1 addition & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim
FROM python:3.11-slim

ENV TRIES=0 \
RABBITMQ_URI="" \
Expand All @@ -12,15 +12,6 @@ ENV TRIES=0 \
PGTABLE="" \
URL=""

ARG VERSION="unknown"
ARG GITSHA1="unknown"

LABEL org.opencontainers.image.title="Container to be used as init containers to check if the service is ready"
LABEL org.opencontainers.image.authors="Rob Kooper <kooper@illinois.edu"
LABEL org.opencontainers.image.source="https://github.com/ncsa/checks"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.revision="${GITSHA1}"

# Install requirements
WORKDIR /usr/src
COPY requirements.txt /usr/src/
Expand Down

0 comments on commit 92460d1

Please sign in to comment.