Docker build and push (base) #271
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker build and push (base) | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '.github/workflows/deploy.yml' | |
- 'Dockerfile.release' | |
pull_request_target: | |
branches: | |
- main | |
paths-ignore: | |
- '.github/workflows/deploy.yml' | |
- 'Dockerfile.release' | |
schedule: | |
- cron: '0 0 * * 2' | |
workflow_dispatch: | |
permissions: write-all | |
jobs: | |
latest_versions: | |
runs-on: ubuntu-latest | |
# Map a step output to a job output | |
outputs: | |
protobuf_version: ${{ steps.protobuf.outputs.protobuf_version }} | |
compose_version: ${{ steps.compose.outputs.compose_version }} | |
llvm_version: ${{ steps.llvm.outputs.llvm_version }} | |
steps: | |
- name: prepare | |
run: | | |
sudo apt-get update -qq && \ | |
sudo apt-get install --no-install-recommends -qqy \ | |
jq | |
- name: find latest vrersions (protocol buffers) | |
id: protobuf | |
run: | | |
PROTOCOL_BUFFERS_VERSION="$(curl -sSL https://api.github.com/repos/protocolbuffers/protobuf/releases/latest | jq -r .tag_name | cut -d'v' -f2)" && \ | |
echo "protobuf_version=${PROTOCOL_BUFFERS_VERSION}" >> $GITHUB_OUTPUT | |
- name: find latest vrersions (docker compose) | |
id: compose | |
run: | | |
COMPOSE_VERSION="$(curl -sSL https://api.github.com/repos/docker/compose/releases/latest | jq -r .tag_name)" && \ | |
echo "compose_version=${COMPOSE_VERSION}" >> $GITHUB_OUTPUT | |
- name: find latest vrersions (llvm) | |
id: llvm | |
run: | | |
LLVM_VERSION="$(curl -sSL https://api.github.com/repos/llvm/llvm-project/releases/latest | jq -r .tag_name | cut -d'-' -f2)" && \ | |
echo "llvm_version=${LLVM_VERSION}" >> $GITHUB_OUTPUT | |
docker_build_push: | |
needs: latest_versions | |
strategy: | |
matrix: | |
versions: [ | |
{ tag: 'debian-bullseye-java11-base', distoribution: 'debian', debian-code-name: 'bullseye', flavor: '', target: 'base', java-version: '11', platforms: 'linux/amd64' }, | |
{ tag: 'debian-bullseye-java17-base', distoribution: 'debian', debian-code-name: 'bullseye', flavor: '', target: 'base', java-version: '17', platforms: 'linux/amd64' }, | |
{ tag: 'debian-bullseye-java11-base', distoribution: 'debian', debian-code-name: 'bullseye', flavor: '-slim', target: 'base', java-version: '11', platforms: 'linux/amd64' }, | |
{ tag: 'debian-bullseye-java17-base', distoribution: 'debian', debian-code-name: 'bullseye', flavor: '-slim', target: 'base', java-version: '17', platforms: 'linux/amd64' } | |
] | |
runs-on: ubuntu-latest | |
steps: | |
- name: prepare env | |
env: | |
PROTOCOL_BUFFERS_VERSION: ${{needs.latest_versions.outputs.protobuf_version}} | |
COMPOSE_VERSION: ${{needs.latest_versions.outputs.compose_version}} | |
LLVM_VERSION: ${{needs.latest_versions.outputs.llvm_version}} | |
JAVA_VERSION: ${{ matrix.versions.java-version }} | |
DEBIAN_CODE_NAME: ${{ matrix.versions.debian-code-name }} | |
DISTORIBUTION: ${{ matrix.versions.distoribution }} | |
FLAVOR: ${{ matrix.versions.flavor }} | |
run: | | |
echo "LLVM_VERSION=$(echo ${LLVM_VERSION} | cut -d . -f1)" >> $GITHUB_ENV | |
echo "PROTOCOL_BUFFERS_VERSION=${PROTOCOL_BUFFERS_VERSION}" >> $GITHUB_ENV | |
echo "COMPOSE_VERSION=${COMPOSE_VERSION}" >> $GITHUB_ENV | |
echo "JAVA_VERSION=${JAVA_VERSION}" >> $GITHUB_ENV | |
echo "DEBIAN_CODE_NAME=${DEBIAN_CODE_NAME}" >> $GITHUB_ENV | |
echo "DISTORIBUTION=${DISTORIBUTION}" >> $GITHUB_ENV | |
echo "FLAVOR=${FLAVOR}" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: poad | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: "Build ${{ matrix.versions.tag }}" | |
if: github.event_name == 'pull_request' && github.event_name != 'schedule' | |
uses: docker/build-push-action@v6 | |
with: | |
push: false | |
pull: true | |
context: ${{ matrix.versions.dir }} | |
platforms: ${{ matrix.versions.platforms }} | |
tags: poad/docker-grpc:${{ matrix.versions.tag }} | |
target: ${{ matrix.versions.target }} | |
file: Dockerfile.base | |
build-args: | | |
BUILDKIT_INLINE_CACHE=1 | |
LLVM_VERSION=${{ env.LLVM_VERSION }} | |
PROTOCOL_BUFFERS_VERSION=${{ env.PROTOCOL_BUFFERS_VERSION }} | |
COMPOSE_VERSION=${{ env.COMPOSE_VERSION }} | |
JAVA_VERSION=${{ env.JAVA_VERSION }} | |
DEBIAN_CODE_NAME=${{ env.DEBIAN_CODE_NAME }} | |
DISTORIBUTION=${{ env.DISTORIBUTION }} | |
FLAVOR=${{ env.FLAVOR }} | |
- name: "Build and push ${{ matrix.versions.tag }}" | |
if: github.event_name != 'pull_request' | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
pull: false | |
context: ${{ matrix.versions.dir }} | |
platforms: ${{ matrix.versions.platforms }} | |
tags: poad/docker-grpc:${{ matrix.versions.tag }} | |
target: ${{ matrix.versions.target }} | |
file: Dockerfile.base | |
build-args: | | |
BUILDKIT_INLINE_CACHE=1 | |
LLVM_VERSION=${{ env.LLVM_VERSION }} | |
PROTOCOL_BUFFERS_VERSION=${{ env.PROTOCOL_BUFFERS_VERSION }} | |
COMPOSE_VERSION=${{ env.COMPOSE_VERSION }} | |
JAVA_VERSION=${{ env.JAVA_VERSION }} | |
DEBIAN_CODE_NAME=${{ env.DEBIAN_CODE_NAME }} | |
DISTORIBUTION=${{ env.DISTORIBUTION }} | |
FLAVOR=${{ env.FLAVOR }} | |
- name: Hadolint | |
uses: brpaz/hadolint-action@master | |
with: | |
dockerfile: Dockerfile.base | |
publish_gh_release: | |
needs: docker_build_push | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' | |
steps: | |
- run: | | |
git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
git config --global user.name "${{ secrets.GIT_USERNAME }}" | |
git config --global user.email "${{ secrets.GIT_EMAIL }}" | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Create date timestamp | |
run: echo "TIMESTAMP=$(date +%y%m.%d.%H%M)" >> $GITHUB_ENV | |
- uses: rickstaa/action-create-tag@v1 | |
with: | |
tag: ${{ env.TIMESTAMP }} | |
message: "Latest release" | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.TIMESTAMP }} |