-
Notifications
You must be signed in to change notification settings - Fork 5
76 lines (73 loc) · 2.38 KB
/
deploy_extraction_model.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
name: Extraction model Build and Deploy
on:
push:
branches: [ main ]
paths:
- 'QA_model/**'
- 'api/extraction-mrc/**'
env:
DOCKER_IMAGE: ghcr.io/keemdy/final-project-level3-nlp-09
VERSION: ${{ github.sha }}
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v2
- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ env.VERSION }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}
- name: Copy Diretory
run: |
rm -rf api/extraction-mrc/QA_model
cp -r QA_model/data api/extraction-mrc/QA_model
ls api/extraction-mrc
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./api/extraction-mrc
file: ./api/extraction-mrc/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.DOCKER_IMAGE }}:${{ env.VERSION }}
# tags: ${{ env.DOCKER_IMAGE }}
deploy:
needs: build
name: Deploy
runs-on: [ self-hosted, label-development ]
steps:
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}
- name: Docker run
run: |
pwd
docker ps -a
docker ps -q --filter "name=em-api-server" | grep -q . && docker stop em-api-server && docker rm -fv em-api-server
docker run --gpus all -d -p 9090:9090 --name em-api-server --restart always ${{ env.DOCKER_IMAGE }}:${{ env.VERSION }}
cleanup:
needs: [ build, deploy ]
name: Clean up docker images
runs-on: [ self-hosted, development ]
steps:
- name: Clean up docker images
run:
docker rmi $(docker images --filter "before=${{ env.DOCKER_IMAGE }}:${{ env.VERSION }}" --filter=reference="${{ env.DOCKER_IMAGE }}:*" -q)