-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (61 loc) · 2.32 KB
/
docker_build.yml
File metadata and controls
71 lines (61 loc) · 2.32 KB
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
# This workflow should build docker images every time code is pushed to the repository
name: Build and Publish Docker Images
# This workflow is triggered only when called by another workflow
on:
workflow_call:
jobs:
build:
name: Build Docker Images
runs-on: ubuntu-latest
# Use a matrix strategy to run the build process for all our containers
strategy:
matrix:
# Add any future services relative paths from . here
service: [client, gateway, matching, user, genai, userdb, matchdb]
include:
- service: client
context: client
- service: gateway
context: server/gateway
- service: matching
context: server/matching
- service: user
context: server/user
- service: genai
context: server/genai
- service: userdb
context: server/database/userdb
- service: matchdb
context: server/database/matchdb
steps:
# Use pre-existing action to login to GHCR.io
- name: Login to GHCR.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Use a pre-existing action to setup Docker Buildkit
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
# Get tags and lables for publishing image
- name: Get labels and tags for publishing
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.service }} # ex: ghcr.io/aet-devops25/team-devoops/gateway
# Tags pushes to main with :latest, pushes to branches with ex :feature-github-actions-workflow, and PRs with ex :pr-42
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=sha,format=short
# Use a pre-existing action to build docker image
- name: Build and Push Image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
context: "{{ defaultContext }}:${{ matrix.context }}"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}