-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (95 loc) · 3.38 KB
/
docker.yml
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
name: Docker
on:
push:
# branches:
# - 'main'
tags:
- "v*.*.*"
release:
types: [published]
jobs:
docker_build_and_push:
name: "Build and push Docker image"
runs-on: ubuntu-latest
strategy:
# Prevent a failure in one image from stopping the other builds
fail-fast: false
matrix:
include:
- context: "m4t_server"
file: "m4t_server/Dockerfile"
image: "m4t-server"
platforms: "linux/amd64"
base: "nvidia/cuda:12.2.2-base-ubuntu22.04" # GPU enabled
image_type: "gpu"
- context: "m4t_server"
file: "m4t_server/Dockerfile"
image: "m4t-server"
platforms: "linux/amd64,linux/arm64"
base: "nvidia/cuda:12.2.2-base-ubuntu22.04" # CPU only
image_type: "cpu"
- context: "."
file: "Dockerfile"
image: "omnigram-server"
platforms: "linux/arm64,linux/amd64"
image_type: "alpine"
steps:
- name: Checkout
uses: actions/checkout@main
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Commit hash
id: commit
uses: prompt/actions-commit-hash@v3
- name: Generate docker image tags
id: metadata
uses: docker/metadata-action@v5
env:
SUFFIX: ${{ format('-{0}', matrix.image_type) }}
with:
flavor: |
# Disable latest tag
latest=false
images: |
name=lxpio/${{matrix.image}}
tags: |
# Tag with branch name
type=ref,event=branch,suffix=${{ env.SUFFIX }}
# Tag with pr-number
type=ref,event=pr,suffix=${{ env.SUFFIX }}
# Tag with git tag on release
type=ref,event=tag,suffix=${{ env.SUFFIX }}
type=raw,value=release,enable=${{ github.event_name == 'release' }},suffix=${{ env.SUFFIX }}
# latest
type=raw,event=tag,value=latest,enable=${{ matrix.image_type != 'cpu' }},suffix=
type=raw,event=tag,value=latest,enable=${{ matrix.image_type == 'cpu' }},suffix=${{ env.SUFFIX }}
labels: |
com.lxpio.image.authors="@LxpioTeam"
com.lxpio.image.licenses=Apache-2.0
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d_%I_%M_%S%p')"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.file }}
platforms: ${{ matrix.platforms }}
push: ${{ !github.event.pull_request.head.repo.fork }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
BUILD_DATE=${{ steps.date.outputs.date }}
BUILD_HASH=${{ steps.commit.outputs.short }}
BASE=${{ matrix.base }}
DEVICE=${{ matrix.image_type }}
BUILD_VERSION=${{ env.RELEASE_VERSION }}