Main idea is to update container instances directly from git repos or artifacts
untillpro/cder:v{ver} and untillpro/cdernode:v{ver} docker containers will be created and pushed to Dockerhub on pushing tag to github (build.sh will be executed by github action). The tag should be v*.
- golang:1.14.0
- node:10.16.1
cdcommand- Watches over git repositories and rebuilds if changed
- Each
--timeoutseconds--repopulled to<--working-dir>/repos/lastURI(<--repo>)folder. The last commit differs from the stored one ->deployAllis executed--extraRepoif processed--extraRepo <url>form is used- is checked out to
--workDir/??? go.mod:replace <url> => ../<lastURI(url)>appended
- is checked out to
--extraRepo <urlFrom>=<urlTo>form is used- is checked out to
--workDir/??? go.mod:replace <urlFrom> => ../<lastURI(urlTo)>appended
- is checked out to
go build -o <--output>- stop currently executing process (if is)
- SIGINT is sent (does nothing on windows (not supported))
- not finished in 30 seconds -> kill
- built exectable is moved to
<--working-dir>and launched--argsare provided in command line
- After deploy all repos (even those which wasn't changed) are reseted using
git reset --hardgo.modis reverted to original state
- each
--extraRepourl is pulled to<--working-dir>/repos/lastURI(<--extraRepo>). The last commit differs from the stored one ->deployis executed- nothing is made for golang repos
deploy.shused instead golang delpyer if exists at--working-dir
cdurlcommand- watches over specified url and executes deploy scripts if changed
- content from
--urlis downloaded each--timeoutseconds- should consist of 2 lines separated by
\n
- should consist of 2 lines separated by
- 1st line changed i.e. new artifact version is released
<--working-dir>/artifacts/<--url>/work-dirdir is recreated- content from 1st line url is downloaded and saved as
<--working-dir>/artifacts/<--url>/<lastURI.ext> - unzipped to
<--working-dir>/artifacts/<--url>/work-dir - assume 2nd line is changed
- 2nd line changed
- content from 2nd line url is downloaded and saved as
<--working-dir>/artifacts/<--url>/work-dir/deploy.shand executed
- content from 2nd line url is downloaded and saved as
cdGotifycommand- watches over Git repositories using Gotify server and rebuilds if changed
- push ->
curl "https://gotify.untill.changeip.com/message?token=<appToken>" -F "title=<lastCommitHash>" - each message from Gotify server is considered as the last commit hash
- Gotify server is pulled each
--timeoutseconds - Could not use websocket poll because Gotify replies on poll if push is made after poll start only. Pushes made right before the poll will be lost.
- push ->
- Each repo is cloned once on start. Further is the same as for
cdcommand --gToken- Gotify token to access to the server--gURL- Gotify server URL
- watches over Git repositories using Gotify server and rebuilds if changed
-vmeans verbose mode--option1 arg1 arg2are passed toout.exe
- deployer is executed using
envcommand - Working directory is one specified by
-wflag - First argument is one of the following:
stopdeploy- Executed for any changed repo
- First argument is absolute path to changed repo
deploy-all- Executed once when any repo is changed
- Absolute paths to ALL repositories folders are passed as arguments
- Environment variables for deployer can be supplied with
--deployer-env <name>=<value>argument
./cder cd --repo https://github.com/untillpro/directcd-test \
-o directcd-test.exe \
-t 10 \
-w .tmp./cder cd \
--repo https://github.com/untillpro/directcd-test \
--extraRepo https://github.com/untillpro/directcd-test-print=https://github.com/maxim-ge/directcd-test-print \
-v \
-o out.exe \
-t 10 \
-w .tmp \
-- --option1 arg1 arg2./cder cdurl \
--url https://github.com/untillpro/url
-v \
-t 10 \
-w .tmp \Hooks
- https://developer.github.com/v3/repos/hooks/#create-a-hook
- https://developer.github.com/v3/activity/events/types/#pushevent
- https://docs.gitea.io/en-us/webhooks
Stop process
- https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/
docker stop ----time=30 foo, SIGTERMdocker kill ----signal=SIGQUIT nginx, if you want to initiate a graceful shutdown of an nginx server, you should send a SIGQUITdocker kill ----signal=SIGWINCH apache, Apache uses SIGWINCH to trigger a graceful shutdown
- https://husobee.github.io/golang/ecs/2016/05/19/ecs-graceful-go-shutdown.html
Misc
- golang url https://play.golang.org/p/6kBtuHvUlQc