Skip to content

Commit 59d789b

Browse files
adding ghcr.io container building action (#15)
* adding ghcr.io container building action * Build client and server images * Use same context for server and client * Build on pushes to main and new tags * Use :latest tag for django/client service in prod * Leave build context in config for now --------- Co-authored-by: naglepuff <mike.nagler@kitware.com>
1 parent 4d901bd commit 59d789b

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

.github/workflows/cd.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CD
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
tags:
7+
- "v*"
8+
release:
9+
types:
10+
- published
11+
concurrency:
12+
# Only run the latest workflow.
13+
# If a build is already happening, cancel it to avoid a race
14+
# condition where an older image overwrites a newer one.
15+
group: ${{ github.workflow }}
16+
cancel-in-progress: true
17+
jobs:
18+
build:
19+
name: Build [batai]
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
image: [server, client]
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
- name: Login to GHCR
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.repository_owner }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Generate image tags
36+
uses: docker/metadata-action@v5
37+
id: image-tags
38+
with:
39+
images:
40+
ghcr.io/Kitware/batai/${{ matrix.image }}
41+
tags: |
42+
type=ref,event=branch
43+
type=semver,pattern={{version}}
44+
- name: Build and push Docker image
45+
uses: docker/build-push-action@v5
46+
with:
47+
cache-from: type=gha
48+
cache-to: type=gha,mode=max
49+
file: ${{ matrix.image == 'server' && 'dev/django.Dockerfile' || 'dev/client.Dockerfile' }}
50+
context: .
51+
platforms: linux/amd64
52+
push: true
53+
tags: ${{ steps.image-tags.outputs.result }}

docker-compose.prod.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ services:
3939
- "443:443"
4040

4141
django:
42+
# Specifying both image and build without pull_policy will default to
43+
# attempting to pull the image first, then build from source if that fails.
44+
image: ghcr.io/Kitware/batai/server:latest
4245
build:
4346
context: .
4447
dockerfile: ./dev/django.Dockerfile
@@ -85,6 +88,9 @@ services:
8588
- rabbitmq
8689
- minio
8790
client:
91+
# Specifying both image and build without pull_policy will default to
92+
# attempting to pull the image first, then build from source if that fails.
93+
image: ghcr.io/Kitware/batai/client:latest
8894
build:
8995
context: .
9096
dockerfile: ./dev/client.Dockerfile

0 commit comments

Comments
 (0)