haystack/.github/workflows/docker_release.yml
Massimiliano Pippi 8ddb6d7821
feat: add multi-platform Docker images (#3354)
* add arm platform to the build

* add a note about multi-platforms build

* test on current branch

* setup qemu on Github actions

* better naming

* Revert "test on current branch"

This reverts commit b0e5ea77b46e3e0bafd579c95e434c6a3c8ef84f.
2022-10-11 12:29:33 +02:00

91 lines
2.5 KiB
YAML

name: Docker image release
on:
workflow_dispatch:
push:
branches:
- main
tags:
- 'v[0-9].*[0-9].*[0-9]?(rc[0-9])'
env:
DOCKER_REPO_NAME: deepset/haystack
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: $DOCKER_REPO_NAME
- name: Build base images
uses: docker/bake-action@v2
env:
IMAGE_TAG_SUFFIX: ${{ steps.meta.outputs.version }}
with:
workdir: docker
targets: base
push: true
- name: Build api images
uses: docker/bake-action@v2
env:
IMAGE_TAG_SUFFIX: ${{ steps.meta.outputs.version }}
BASE_IMAGE_TAG_SUFFIX: ${{ steps.meta.outputs.version }}
with:
workdir: docker
targets: api
push: true
- name: Get latest version of Haystack
id: latest-version
uses: pozetroninc/github-action-get-latest-release@master
if: startsWith(github.ref, 'refs/tags/')
with:
repository: ${{ github.repository }}
excludes: prerelease, draft
- name: Compare current version with latest
uses: madhead/semver-utils@latest
id: version
if: startsWith(github.ref, 'refs/tags/')
with:
# Version being built
version: ${{ github.ref_name }}
# Compare to latest
compare-to: ${{ steps.latest-version.outputs.release }}
# This step should only run when we release a new minor, so
# that we can tag the most recent image without the version number.
# For example, if the previous step builds `deepset/haystack:cpu-1.8.0`,
# this builds `deepset/haystack:cpu`
- name: Build api images no version in tag
uses: docker/bake-action@v2
if: steps.version.outputs.comparison-result == '>'
env:
IMAGE_TAG_SUFFIX: ${{ steps.meta.outputs.version }}
BASE_IMAGE_TAG_SUFFIX: ${{ steps.meta.outputs.version }}
with:
workdir: docker
targets: api-latest
push: true