-
Notifications
You must be signed in to change notification settings - Fork 231
100 lines (85 loc) · 3.59 KB
/
build_and_push_docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: "Build Docker Images"
on:
workflow_call:
inputs:
image:
type: string
required: true
description: Docker Image
version:
type: string
required: true
description: Version
build_from:
type: string
required: true
description: Original version to build from
default: ""
build_comet_image:
type: boolean
required: true
description: If to build a Comet integration image
default: false
comet_build_args:
type: string
required: false
default: ""
description: Arguments for cloud docker build
push_latest:
type: string
required: true
description: If to push docker image with latest tag
default: "false"
env:
DOCKER_REGISTRY: "ghcr.io/comet-ml/opik"
jobs:
build-n-push-image:
runs-on: ubuntu-latest
defaults:
run:
working-directory: apps/${{ inputs.image }}/
steps:
- name: Checkout
uses: actions/[email protected]
with:
ref: ${{inputs.build_from}}
- name: Build Docker Image
run: |
DOCKER_IMAGE_NAME=${{env.DOCKER_REGISTRY}}/${{ inputs.image }}:${{inputs.version}}
echo "DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME}" | tee -a $GITHUB_ENV
DOCKER_BUILDKIT=1 docker build --build-arg OPIK_VERSION=${{inputs.version}} -t ${DOCKER_IMAGE_NAME} .
- name: Build Docker Image for Comet integration
if: inputs.build_comet_image
run: |
DOCKER_IMAGE_NAME_COMET=${{env.DOCKER_REGISTRY}}/${{inputs.image}}-comet:${{inputs.version}}
echo "DOCKER_IMAGE_NAME_COMET=${DOCKER_IMAGE_NAME_COMET}" | tee -a $GITHUB_ENV
DOCKER_BUILDKIT=1 docker build --build-arg ${{inputs.comet_build_args}} --build-arg OPIK_VERSION=${{inputs.version}} -t ${DOCKER_IMAGE_NAME_COMET} .
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{env.DOCKER_REGISTRY}}
username: "github-actions"
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker Image
run: |
docker push ${{env.DOCKER_IMAGE_NAME}}
echo "Docker image pushed: ${{env.DOCKER_IMAGE_NAME}}" >> $GITHUB_STEP_SUMMARY
- name: Push Docker Image with latest tag
if: inputs.push_latest == 'true'
run: |
DOCKER_IMAGE_NAME_LATEST=${{env.DOCKER_REGISTRY}}/${{ inputs.image }}:latest
docker tag ${{env.DOCKER_IMAGE_NAME}} ${DOCKER_IMAGE_NAME_LATEST}
docker push ${DOCKER_IMAGE_NAME_LATEST}
echo "Docker image pushed: ${DOCKER_IMAGE_NAME_LATEST}" >> $GITHUB_STEP_SUMMARY
- name: Push Docker Image for Comet integration
if: inputs.build_comet_image
run: |
docker push ${{env.DOCKER_IMAGE_NAME_COMET}}
echo "Docker image pushed: ${{env.DOCKER_IMAGE_NAME_COMET}}" >> $GITHUB_STEP_SUMMARY
- name: Push Docker Image for Comet integration with latest tag
if: inputs.build_comet_image && inputs.push_latest == 'true'
run: |
DOCKER_IMAGE_NAME_COMET_LATEST=${{env.DOCKER_REGISTRY}}/${{ inputs.image }}-comet:latest
docker tag ${{env.DOCKER_IMAGE_NAME_COMET}} ${DOCKER_IMAGE_NAME_COMET_LATEST}
docker push ${DOCKER_IMAGE_NAME_COMET_LATEST}
echo "Docker image pushed: ${DOCKER_IMAGE_NAME_COMET_LATEST}" >> $GITHUB_STEP_SUMMARY