-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (137 loc) · 5.09 KB
/
build-and-push-image.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
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
153
154
155
156
157
158
159
160
name: Build the LLM Finetuning Docker image
on:
push:
tags:
- v*
permissions:
id-token: write
contents: read
concurrency:
group: build-llm-finetune-${{ github.ref }}
cancel-in-progress: true
env:
GITHUB_SHA: ${{ github.sha }}
TAG_PREFIX: "v"
jobs:
build_image:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- name: Checkout
uses: actions/checkout@v3
- name: Set version tags
run: |
echo "Ref name is ${{ github.ref_name }}"
echo "TAG_PREFIX is ${{ env.TAG_PREFIX }}"
REF_NAME=${{ github.ref_name }}
TAG_PREFIX=${{ env.TAG_PREFIX }}
VERSION_TAG=$(echo $REF_NAME | awk -F$TAG_PREFIX '{print $2}')
echo "Setting VERSION_TAG equal to $VERSION_TAG"
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV
ALT_VERSION_TAG=$(echo $VERSION_TAG | awk -F- '{print $1}')-${GITHUB_SHA::7}
echo "Setting ALT_VERSION_TAG equal to $ALT_VERSION_TAG"
echo "ALT_VERSION_TAG=$ALT_VERSION_TAG" >> $GITHUB_ENV
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.PUBLIC_ECR_IAM_ROLE_ARN }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set repo uri
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REGISTRY_ALIAS: truefoundrycloud
REPOSITORY: llm-finetune
run: |
REPOSITORY_URI=${{ env.REGISTRY }}/${{ env.REGISTRY_ALIAS }}/${{ env.REPOSITORY }}
echo "Setting REPOSITORY_URI equal to $REPOSITORY_URI"
echo "REPOSITORY_URI=$REPOSITORY_URI" >> $GITHUB_ENV
- name: Build and push image
uses: docker/build-push-action@v5
env:
IMAGE_TAG_1: ${{ env.REPOSITORY_URI }}:${{ env.GITHUB_SHA }}
IMAGE_TAG_2: ${{ env.REPOSITORY_URI }}:${{ env.VERSION_TAG }}
IMAGE_TAG_3: ${{ env.REPOSITORY_URI }}:${{ env.ALT_VERSION_TAG }}
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.IMAGE_TAG_1 }},${{ env.IMAGE_TAG_2 }},${{ env.IMAGE_TAG_3 }}
cache-from: type=registry,ref=${{ env.REPOSITORY_URI }}:buildcache
cache-to: mode=max,image-manifest=true,type=registry,ref=${{ env.REPOSITORY_URI }}:buildcache
build_notebook_image:
name: Build Notebook Image
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- name: Checkout
uses: actions/checkout@v3
- name: Set version tags
run: |
echo "Ref name is ${{ github.ref_name }}"
echo "TAG_PREFIX is ${{ env.TAG_PREFIX }}"
REF_NAME=${{ github.ref_name }}
TAG_PREFIX=${{ env.TAG_PREFIX }}
VERSION_TAG=$(echo $REF_NAME | awk -F$TAG_PREFIX '{print $2}')-jupyter
echo "Setting VERSION_TAG equal to $VERSION_TAG"
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.PUBLIC_ECR_IAM_ROLE_ARN }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set repo uri
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REGISTRY_ALIAS: truefoundrycloud
REPOSITORY: llm-finetune
run: |
REPOSITORY_URI=${{ env.REGISTRY }}/${{ env.REGISTRY_ALIAS }}/${{ env.REPOSITORY }}
echo "Setting REPOSITORY_URI equal to $REPOSITORY_URI"
echo "REPOSITORY_URI=$REPOSITORY_URI" >> $GITHUB_ENV
- name: Build and push image
uses: docker/build-push-action@v5
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REGISTRY_ALIAS: truefoundrycloud
REPOSITORY: llm-finetune
IMAGE_TAG_1: ${{ env.REPOSITORY_URI }}:${{ env.VERSION_TAG }}
with:
context: .
file: Dockerfile-notebook
push: true
tags: ${{ env.IMAGE_TAG_1 }}
cache-from: type=registry,ref=${{ env.REPOSITORY_URI }}:jupyter-buildcache
cache-to: mode=max,image-manifest=true,type=registry,ref=${{ env.REPOSITORY_URI }}:jupyter-buildcache