Skip to content

Commit 29ce56a

Browse files
authored
Merge pull request #73 from teacoder-team/dev
ci: switch to remote build via ssh
2 parents 52c8d7f + 2ff2bfa commit 29ce56a

2 files changed

Lines changed: 47 additions & 33 deletions

File tree

.github/workflows/release.yaml

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,23 @@ on:
66
- main
77
workflow_dispatch:
88

9-
permissions:
10-
contents: read
11-
packages: write
12-
id-token: write
13-
149
jobs:
15-
build-and-push:
16-
name: Build and Push
10+
deploy:
1711
runs-on: ubuntu-latest
1812
steps:
19-
- name: Checkout repository
20-
uses: actions/checkout@v4
13+
- name: Deploy via SSH
14+
uses: appleboy/ssh-action@v1.0.3
2115
with:
22-
fetch-depth: 0
23-
24-
- name: Set up Docker Buildx
25-
uses: docker/setup-buildx-action@v3
16+
host: ${{ secrets.REMOTE_HOST }}
17+
port: ${{ secrets.REMOTE_PORT }}
18+
username: ${{ secrets.REMOTE_USER }}
19+
key: ${{ secrets.SSH_PRIVATE_KEY }}
20+
script: |
21+
cd /opt/teacoder/apps/frontend
22+
git pull origin main
2623
27-
- name: Log in to Docker Hub
28-
uses: docker/login-action@v3
29-
with:
30-
username: ${{ secrets.DOCKERHUB_USERNAME }}
31-
password: ${{ secrets.DOCKERHUB_TOKEN }}
32-
33-
- name: Build and push Docker image
34-
uses: docker/build-push-action@v6
35-
with:
36-
context: .
37-
file: ./Dockerfile
38-
push: true
39-
build-args: |
40-
NEXT_PUBLIC_APP_URL=${{ secrets.NEXT_PUBLIC_APP_URL }}
41-
NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}
42-
tags: |
43-
${{ secrets.DOCKERHUB_USERNAME }}/frontend:latest
44-
${{ secrets.DOCKERHUB_USERNAME }}/frontend:${{ github.sha }}
45-
cache-from: type=gha
46-
cache-to: type=gha,mode=max
24+
docker compose build \
25+
--build-arg NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }} \
26+
--build-arg NEXT_PUBLIC_APP_URL=${{ secrets.NEXT_PUBLIC_APP_URL }}
27+
28+
docker compose up -d

docker-compose.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
services:
2+
frontend:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
args:
7+
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
8+
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL}
9+
container_name: frontend
10+
restart: always
11+
ports:
12+
- '127.0.0.1:14702:14702'
13+
networks:
14+
- teacoder_network
15+
deploy:
16+
resources:
17+
limits:
18+
cpus: '0.60'
19+
memory: 1200M
20+
healthcheck:
21+
test:
22+
[
23+
'CMD-SHELL',
24+
'node -e ''require("http").get("http://localhost:14702/", (r) => process.exit(r.statusCode === 200 ? 0 : 1))'''
25+
]
26+
interval: 30s
27+
timeout: 10s
28+
retries: 3
29+
30+
networks:
31+
teacoder_network:
32+
external: true

0 commit comments

Comments
 (0)