This repo is used to create a automatic synchronization git repo. It is a key component in online devleopment runtime project. You can run build this the image with your puhlic SSH key.
cd /to/your/workspace
git clone https://github.com/yanqiw/gitsyn
cd gitsyn
mv sshkeys/authorized_keys.sample sshkeys/authorized_keys
echo path/your/sshpubilckey > sshkeys/authorized_keys
docker build -t project-name-git-repo .
If you build the image in your laptop, you need push the image to your cloud, and run the image in cloud.
In your could server, run command
docker run --name project-name-git -v your/host/workdir:/workspace -p YOUR_HOST_PORT:22 project-name-git-repo
YOUR_HOST_PORT is the port on your host which you want to expose.
You need to add the git remote to your local git
git remote add runtime ssh://git@YOUR_HOST:YOUR_PORT/repo/runtime.git
YOUR_PROJECT_GIT_REPO is the git repo on your cloud.
In your local workspace, run:
git push runtime master
If the push is successful, open your cloud server to check the code in your host workdir which is used in the container
Go to your project folder.
touch .git/hooks/post-commit
echo "#/bin/bash" > .git/hooks/post-commit
echo "git push runtime master" >> .git/hooks/post-commit
After add the hooks you the push is automatic run about commit
If you want to auto-push after file save, you need to run some file monitor script or task.
Put this file in your project root, and run it by
python git-auto-add.py YOUR_AUTO_COMMENTS
This is a quick demo to running runtime container on cloud. In cloud server, go to the work folder run below command:
docker run --name nginx_runtime -v "$PWD":/usr/share/nginx/html:ro -p 8080:80 -d nginx
Open yourdomian.com:8080