티스토리 뷰
git 저장소에 올린 프로젝트를 Web Server에 배포할 일이 생겨서 찾아보았더니 git hook을 이용한 간단한 배포 방법이 있네요.
그럼 이번에는 git hook을 이용한 자동배포를 설정해보겠습니다.
일단 git server의 저장소로 이동한 후에
$ cd hooks
$ mv post-update.sample post-update
$ chmod +x post-update
$ vi post-update
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
. /var/www/html/pull.sh # git 서버와 배포 서버가 같을 경우 사용
ssh <user_id>@<server_ip> "/var/www/html/pull.sh" # git 서버와 배포 서버가 다를 경우 사용
exec git update-server-info
git 서버와 배포 서버가 다를 경우에는 비번 없이 ssh 접속을 하기 위해 다음과 같은 작업을 수행합니다.
git 서버에서 다음 명령어를 통해 ssh key를 생성하고
$ ssh-keygen -t rsa
~/.ssh/id_rsa.pub 파일의 내용을 복사해서 배포 서버에 authorized_keys 파일을 생성해서 붙여넣습니다.
$ scp ~/.ssh/id_rsa.pub <user_id>@<release_server_ip>:/home/<user_id>/.ssh/authorized_keys
배포 server의 저장소로 이동한 후에
$ vi pull.sh
#!/bin/sh
unset GIT_DIR
cd /var/www/html/
echo "start git pull"
exec git pull origin master
echo "finish"
이제 local에서 push를 해보면 다음과 같이 잘 동작되는 것을 확인할 수 있습니다.
'linux' 카테고리의 다른 글
[Ubuntu build server 4] jenkins 설치 및 기본 설정 (0) | 2016.12.17 |
---|---|
[Ubuntu build server 3] git 설치 및 ssh, http, https 설정 (0) | 2016.12.04 |
[Ubuntu build server 2] apache 설치 (0) | 2016.12.04 |
[Ubuntu build server 1] 자동 빌드 서버를 구축해보자.. (0) | 2016.12.04 |
[Ubuntu 16.04] Git server 구축 (Git + Gitolite) (0) | 2016.11.21 |
- Total
- Today
- Yesterday
- Jenkins
- android serialization
- serializable
- kotlin
- RecyclerView
- publish opensource
- remove item
- delete item
- weak_ptr
- auto depoly
- git hook
- build server
- swip
- kotlinx serialization
- Git
- qtwebengine
- security.ubuntu.com
- C++
- expandable recyclerview
- 자동 배포
- 리사이클러뷰 확장
- jitpack
- data transfer
- type inference
- Apache
- android open source
- ubuntu 16.04
- git server
- 오픈 소스 배포
- Parcelable
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |