-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (81 loc) · 2.59 KB
/
Copy pathdocker-deploy.yml
File metadata and controls
91 lines (81 loc) · 2.59 KB
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
name: Build and Deploy to Docker Hub
on:
push:
branches: [main]
workflow_dispatch:
env:
APP_IMAGE: notebot-lm-app
WORKER_IMAGE: notebot-lm-worker
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata for app
id: meta-app
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_IMAGE }}
tags: |
type=raw,value=latest
type=sha,prefix=
- name: Build and push app image
uses: docker/build-push-action@v6
with:
context: .
target: app
push: true
tags: ${{ steps.meta-app.outputs.tags }}
labels: ${{ steps.meta-app.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
NEXT_PUBLIC_SUPABASE_URL=${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
- name: Extract Docker metadata for worker
id: meta-worker
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.WORKER_IMAGE }}
tags: |
type=raw,value=latest
type=sha,prefix=
- name: Build and push worker image
uses: docker/build-push-action@v6
with:
context: .
target: worker
push: true
tags: ${{ steps.meta-worker.outputs.tags }}
labels: ${{ steps.meta-worker.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: build-and-push
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
set -e
cd ~/NoteBotLM
git pull origin main
if [ ! -f .env ]; then
echo "ERROR: ~/NoteBotLM/.env missing. Copy .env.production.example to .env on EC2 first."
exit 1
fi
docker compose -f docker-compose.prod.yml pull
docker compose -f docker-compose.prod.yml up -d --remove-orphans
docker image prune -f