Skip to content

Commit 8814da0

Browse files
committed
Merge branch 'chore/docker-cicd'
2 parents a14ed56 + 3fb5454 commit 8814da0

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

.dockerignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Python cache
2+
__pycache__/
3+
*.pyc
4+
*.pyo
5+
*.pyd
6+
7+
# Packaging
8+
*.egg-info/
9+
.eggs/
10+
11+
# Test / coverage
12+
.pytest_cache/
13+
.mypy_cache/
14+
.coverage
15+
htmlcov/
16+
17+
# Virtualenv
18+
env/
19+
venv/
20+
.venv/
21+
ENV/
22+
23+
# Git / IDE
24+
.git
25+
.gitignore
26+
.gitattributes
27+
.idea/
28+
.vscode/
29+
.DS_Store
30+
31+
# Logs / temp
32+
*.log
33+
logs/
34+
tmp/
35+
36+
# Secrets
37+
.env
38+
*.pem
39+
*.key
40+
*.crt

.github/workflows/build-push.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: recsys-agent - build & push (multi-arch) + deploy
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
tags: [ "v*" ]
7+
8+
jobs:
9+
build-push:
10+
runs-on: ubuntu-latest
11+
env:
12+
IMAGE: ${{ vars.DOCKERHUB_USERNAME }}/winear-recsys-agent
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: QEMU 설치
18+
uses: docker/setup-qemu-action@v3
19+
20+
- name: Buildx 설치
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Docker Hub 로그인
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ vars.DOCKERHUB_USERNAME }}
27+
password: ${{ secrets.DOCKERHUB_TOKEN }}
28+
29+
- name: Compute tags
30+
id: meta
31+
run: |
32+
SHA=${GITHUB_SHA::7}
33+
echo "sha=${SHA}" >> $GITHUB_OUTPUT
34+
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
35+
echo "is_tag=true" >> $GITHUB_OUTPUT
36+
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
37+
else
38+
echo "is_tag=false" >> $GITHUB_OUTPUT
39+
fi
40+
41+
- name: Build & Push (edge + sha; multi-arch)
42+
uses: docker/build-push-action@v6
43+
with:
44+
context: .
45+
file: ./Dockerfile
46+
push: true
47+
platforms: linux/amd64,linux/arm64
48+
tags: |
49+
${{ env.IMAGE }}:${{ steps.meta.outputs.sha }}
50+
${{ env.IMAGE }}:edge
51+
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
52+
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
53+
54+
- name: Promote for release (version + latest)
55+
if: steps.meta.outputs.is_tag == 'true'
56+
run: |
57+
docker buildx imagetools create \
58+
-t ${{ env.IMAGE }}:${{ steps.meta.outputs.version }} \
59+
-t ${{ env.IMAGE }}:latest \
60+
${{ env.IMAGE }}:${{ steps.meta.outputs.sha }}
61+
62+
deploy:
63+
needs: build-push
64+
runs-on: ubuntu-latest
65+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
66+
steps:
67+
- name: SSH deploy (compose pull & up -d)
68+
uses: appleboy/ssh-action@v1.0.3
69+
with:
70+
host: ${{ vars.SSH_HOST }}
71+
username: ${{ vars.SSH_USER }}
72+
key: ${{ secrets.SSH_PRIVATE_KEY }}
73+
script: |
74+
set -e
75+
cd /home/ubuntu/stack
76+
docker compose pull
77+
docker compose up -d
78+
docker image prune -f

0 commit comments

Comments
 (0)