본문 바로가기
Q&A2023년 4월 1일1분 읽기

쿠버네티스 없이 서버 배포 자동화하기

한
한동욱
조회 508댓글 1

쿠버네티스는 과한데, 서버 배포를 자동화하는 간단한 방법이 있나요?

댓글 1

김김영삼3년 전

경량 배포 자동화 방법:

1. 쉘 스크립트 + SSH:

#!/bin/bash
# deploy.sh
HOST="user@server"
APP_DIR="/var/www/myapp"

ssh $HOST "cd $APP_DIR && git pull && npm install && npm run build && pm2 restart all"

echo "배포 완료!"

2. GitHub Actions + SSH:

- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: deploy
key: ${{ secrets.SSH_KEY }}
script: |
cd /var/www/myapp
git pull
npm ci && npm run build
pm2 restart app

3. Docker + Watchtower:

# 이미지 푸시하면 자동 업데이트
docker run -d --name watchtower \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower --interval 300
Ctrl+Enter로 등록