-
-
Notifications
You must be signed in to change notification settings - Fork 149
152 lines (137 loc) · 5.06 KB
/
docker-publish.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Docker Build, Slim, and Publish
on:
push:
branches:
- master
tags: [ 'v*.*.*' ]
# Allow manual trigger from GitHub UI
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
actions: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Set up image names (converting to lowercase)
- name: Set image names
run: |
echo "GPU_IMAGE_NAME=${{ env.REGISTRY }}/$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')-gpu" >> $GITHUB_ENV
echo "CPU_IMAGE_NAME=${{ env.REGISTRY }}/$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')-cpu" >> $GITHUB_ENV
echo "UI_IMAGE_NAME=${{ env.REGISTRY }}/$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')-ui" >> $GITHUB_ENV
# Build GPU version
- name: Build GPU Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/gpu/Dockerfile
push: false
load: true
tags: ${{ env.GPU_IMAGE_NAME }}:v0.1.0
build-args: |
DOCKER_BUILDKIT=1
platforms: linux/amd64
# Slim GPU version
- name: Slim GPU Docker image
run: |
docker pull dslim/slim
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/slim build \
--target ${{ env.GPU_IMAGE_NAME }}:v0.1.0 \
--tag ${{ env.GPU_IMAGE_NAME }}:v0.1.0-slim \
--include-path=/app/models \
--include-path=/app/api/src/voices \
--include-path=/app/.venv \
--include-bin=/usr/local/cuda/lib64 \
--include-bin=/usr/lib/x86_64-linux-gnu/libcudart.so \
--include-bin=/usr/lib/x86_64-linux-gnu/libcuda.so \
--include-shell \
--include-exe=python3,python3.10,espeak-ng \
--exclude-mounts=false \
--http-probe=false
# Push GPU versions
- name: Push GPU Docker images
run: |
docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0
docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0-slim
docker tag ${{ env.GPU_IMAGE_NAME }}:v0.1.0 ${{ env.GPU_IMAGE_NAME }}:latest
docker tag ${{ env.GPU_IMAGE_NAME }}:v0.1.0-slim ${{ env.GPU_IMAGE_NAME }}:latest-slim
docker push ${{ env.GPU_IMAGE_NAME }}:latest
docker push ${{ env.GPU_IMAGE_NAME }}:latest-slim
# Build CPU version
- name: Build CPU Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/cpu/Dockerfile
push: false
load: true
tags: ${{ env.CPU_IMAGE_NAME }}:v0.1.0
build-args: |
DOCKER_BUILDKIT=1
platforms: linux/amd64
# Slim CPU version
- name: Slim CPU Docker image
run: |
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/slim build \
--target ${{ env.CPU_IMAGE_NAME }}:v0.1.0 \
--tag ${{ env.CPU_IMAGE_NAME }}:v0.1.0-slim \
--include-path=/app/models \
--include-path=/app/api/src/voices \
--include-path=/app/.venv \
--include-shell \
--include-exe=python3,python3.10,espeak-ng \
--exclude-mounts=false \
--http-probe=false
# Push CPU versions
- name: Push CPU Docker images
run: |
docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0
docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0-slim
docker tag ${{ env.CPU_IMAGE_NAME }}:v0.1.0 ${{ env.CPU_IMAGE_NAME }}:latest
docker tag ${{ env.CPU_IMAGE_NAME }}:v0.1.0-slim ${{ env.CPU_IMAGE_NAME }}:latest-slim
docker push ${{ env.CPU_IMAGE_NAME }}:latest
docker push ${{ env.CPU_IMAGE_NAME }}:latest-slim
# Build and push UI version
- name: Build and push UI Docker image
uses: docker/build-push-action@v5
with:
context: ./ui
file: ./ui/Dockerfile
push: true
tags: |
${{ env.UI_IMAGE_NAME }}:v0.1.0
${{ env.UI_IMAGE_NAME }}:latest
build-args: |
DOCKER_BUILDKIT=1
platforms: linux/amd64
create-release:
needs: build
runs-on: ubuntu-latest
# Only run this job if we're pushing a tag
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Release
uses: softprops/action-gh-release@v1
env:
IS_PRERELEASE: ${{ contains(github.ref, '-pre') }}
with:
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, '-pre') }}