Skip to content

Commit

Permalink
feat: add build-push-docker.yml workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmbmb committed Jul 18, 2023
1 parent 65decaf commit fc85cef
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 58 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/build-push-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build Argilla Docker image

on:
workflow_call:
inputs:
download-python-package:
description: "True if python package should be downloaded"
type: boolean
default: false
image-name:
description: "Name of the image to build"
required: true
type: string
dockerfile:
description: "Path to the Dockerfile to build"
required: true
type: string
platforms:
description: "Platforms to build for"
required: true
type: string
build-args:
description: "Build arguments"
required: false
type: string
default: ""
readme:
description: "Path to the README file"
required: false
type: string
default: "README.md"
outputs:
version:
description: "Version of the Docker image"
value: ${{ steps.meta.outputs.version }}

jobs:
build:
name: Build Docker image
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Download python package
uses: actions/download-artifact@v3
if: ${{ inputs.download-python-package }}
with:
name: python-package
path: docker/dist
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ inputs.image-name }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: docker
file: ${{ inputs.dockerfile }}
platforms: ${{ inputs.platforms }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ${{ inputs.build-args }}
load: true
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
if: github.event_name == 'release'
with:
username: ${{ secrets.AR_DOCKER_USERNAME }}
password: ${{ secrets.AR_DOCKER_PASSWORD }}
repository: ${{ inputs.image-name }}
readme-filepath: ${{ inputs.readme }}
83 changes: 25 additions & 58 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ jobs:
if: needs.deployable_check.outputs.isDeployable == 'true'
secrets: inherit

deploy_docker:
name: Build docker image
runs-on: ubuntu-latest
build_server_docker_image:
name: Build Argilla server docker image
uses: ./.github/workflows/build-push-docker.yml
needs:
- build_python_package
- run_tests
Expand All @@ -132,60 +132,27 @@ jobs:
needs.deployable_check.outputs.isDeployable == 'true' &&
needs.run_tests.result != 'failure' &&
needs.run_tests_extra.result != 'failure'
strategy:
matrix:
include:
- image: argilla/argilla-server
dockerfile: docker/Dockerfile
readme: README.md
platforms: linux/amd64
- image: argilla/argilla-quickstart
dockerfile: docker/quickstart.Dockerfile
readme: docker/quickstart.README.md
platforms: linux/amd64,linux/arm64
max-parallel: 1
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout Code 🛎
uses: actions/checkout@v2
- name: Download python package
uses: actions/download-artifact@v3
with:
name: python-package
path: docker/dist
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: crazy-max/ghaction-docker-meta@v2
with:
images: ${{ matrix.image }}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.AR_DOCKER_USERNAME }}
password: ${{ secrets.AR_DOCKER_PASSWORD }}
- name: Build & push Docker image
uses: docker/build-push-action@v2
with:
context: docker
file: ${{ matrix.dockerfile }}
platforms: ${{ matrix.platforms }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
if: github.event_name == 'release'
with:
username: ${{ secrets.AR_DOCKER_USERNAME }}
password: ${{ secrets.AR_DOCKER_PASSWORD }}
repository: ${{ matrix.image }}
readme-filepath: ${{ matrix.readme }}
with:
download-python-package: true
image-name: argilla/argilla-server
dockerfile: docker/Dockerfile
readme: README.md
platforms: linux/amd64
secrets: inherit

build_quickstart_docker_image:
name: Build Argilla quickstart docker image
uses: ./.github/workflows/build-push-docker.yml
needs: build_server_docker_image
with:
download-python-package: false
image-name: argilla/argilla-quickstart
dockerfile: docker/quickstart.Dockerfile
readme: docker/quickstart.README.md
platforms: linux/amd64,linux/arm64
build-args: |
ARGILLA_VERSION=${{ needs.build_server_docker_image.outputs.version }}
# This job will upload a Python Package using Twine when a release is created
# For more information see:
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
Expand All @@ -194,7 +161,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
needs:
- deploy_docker
- build_quickstart_docker_image
defaults:
run:
shell: bash -l {0}
Expand Down

0 comments on commit fc85cef

Please sign in to comment.