-
Notifications
You must be signed in to change notification settings - Fork 5
52 lines (49 loc) · 1.65 KB
/
model_serving.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
name: Push Docker Image
on:
push:
branches:
- develop # 또는 배포하려는 브랜치
paths:
- 'Backend/backend_model/**'
env:
DOCKER_REGISTRY: heewoni # Docker Hub 사용시
IMAGE_NAME: model_web # 이미지 이름
IMAGE_TAG: latest # 이미지 태그
DOCKERFILE_PATH: ./Backend/backend_model # 빌드를 원하는 폴더 경로
CONTAINER_NAME: model # 컨테이너 이름
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and Push Docker Image
run: |
docker buildx create --use
docker buildx build -t $DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_TAG $DOCKERFILE_PATH --push
-
name: executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: 22
envs: DOCKER_REGISTRY,IMAGE_NAME,IMAGE_TAG,CONTAINER_NAME
script: |
docker pull $DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_TAG
docker stop $CONTAINER_NAME
docker rm $CONTAINER_NAME
docker rmi $(docker images -f "dangling=true" -q)
docker run --env-file .env -d --name $CONTAINER_NAME -p 8080:8080 $DOCKER_REGISTRY/$IMAGE_NAME:$IMAGE_TAG