cd ~/.ssh
ssh-keygen
user add www
cd /home/www
mkdir .ssh
cd .ssh
touch authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
(copy client ~/.ssh/id_rsa.pub string to authorized_keys)
(test connection from client: ssh www@deploy-server-ip)
mkdir ~/git
cd ~/git
git init --bare ./project.git
git clone ./project.git
vi ~/git/project.git/post-receive
(add hook script...)
chmod +x ~/git/project.git/post-receive
-
golang
#!/bin/sh unset GIT_DIR srcpath="/home/www/git/project" dstpath="/usr/local/bin/project" cd $srcpath && git pull cp -f $srcpath/myapp $dstpath cp -f $srcpath/supervisord.conf $dstpath chmod +x $srcpath/myapp supervisorctl -c /etc/supervisord.conf restart myapp
-
java
#!/bin/sh unset GIT_DIR srcpath="/home/www/git/project" dstpath="/usr/local/bin/project" cd $srcpath && git pull cp -f $srcpath/*.jar $dstpath supervisorctl -c /etc/supervisord.conf restart myapp
-
node js
#!/bin/sh unset GIT_DIR srcpath="/home/www/git/project" dstpath="/usr/local/bin/project" cd $srcpath && git pull cp -f $srcpath/*.js $dstpath cp -f $srcpath/*.json $dstpath supervisorctl -c /etc/supervisord.conf restart myapp
-
web
#!/bin/sh unset GIT_DIR srcpath="/home/www/git/project" dstpath="/usr/share/web" cd $srcpath && git pull cp -rf $srcpath/build $dstpath
mkdir ~/git
cd ~/git
git clone www@deploy-server-ip:/home/www/git/project.git
cd ./project
(cp files to ./project)
git add .
git commit -m "commit message"
git push origin master
-
make file content
.PHONY: deploy BUILD_DIR = $(ROOT_DIR)/build DEPLOY_GIT_WORK_DIR = $(HOME)/git/project CURR_TIME = $(shell date +"%Y-%m-%d %H:%M:%S") HOST_NAME = $(shell hostname) deploy: cd $(DEPLOY_GIT_WORK_DIR) && git pull cp -rf $(BUILD_DIR)/myapp $(DEPLOY_GIT_WORK_DIR) cd $(DEPLOY_GIT_WORK_DIR) && git add . && git commit -m "From $(HOST_NAME) auto deploy at: $(CURR_TIME)" && git push origin master
-
make file usage
make deploy