{"id":16098624,"url":"https://github.com/funnyzak/git-webhook-deploy-docker","last_synced_at":"2025-03-28T21:30:54.759Z","repository":{"id":114592624,"uuid":"256194063","full_name":"funnyzak/git-webhook-deploy-docker","owner":"funnyzak","description":"Pull code is triggered via WebHook, then build the code. And send notifications.","archived":true,"fork":false,"pushed_at":"2021-12-14T04:26:32.000Z","size":48,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-23T19:48:04.031Z","etag":null,"topics":["docker","docker-image","git","nodejs","webhook"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/funnyzak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-16T11:24:26.000Z","updated_at":"2024-11-27T12:51:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"37abdbc5-c1a4-4421-838f-460aa4042993","html_url":"https://github.com/funnyzak/git-webhook-deploy-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fgit-webhook-deploy-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fgit-webhook-deploy-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fgit-webhook-deploy-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fgit-webhook-deploy-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funnyzak","download_url":"https://codeload.github.com/funnyzak/git-webhook-deploy-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246104347,"owners_count":20724125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-image","git","nodejs","webhook"],"created_at":"2024-10-09T18:24:10.822Z","updated_at":"2025-03-28T21:30:54.748Z","avatar_url":"https://github.com/funnyzak.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git Webhook Deploy And Notify Docker\n\nPull code is triggered via WebHook, then build the code. And send notifications.\n\n[![Docker Stars](https://img.shields.io/docker/stars/funnyzak/git-webhook-deploy.svg?style=flat-square)](https://hub.docker.com/r/funnyzak/git-webhook-deploy/)\n[![Docker Pulls](https://img.shields.io/docker/pulls/funnyzak/git-webhook-deploy.svg?style=flat-square)](https://hub.docker.com/r/funnyzak/git-webhook-deploy/)\n\nThis image is based on **[funnyzak/git-webhook](https://github.com/funnyzak/git-webhook-docker.git)** image, which is a 439MB image.\n\nDownload size of this image is:\n\n[![](https://images.microbadger.com/badges/image/funnyzak/git-webhook-deploy.svg)](http://microbadger.com/images/funnyzak/git-webhook-deploy)\n\n[Docker hub image: funnyzak/git-webhook-deploy](https://hub.docker.com/r/funnyzak/git-webhook-deploy)\n\nDocker Pull Command: `docker pull funnyzak/git-webhook-deploy`\n\nVisit Url: [http://hostname:80/](#)\n\nWebhook Url: [http://hostname:9000|80/hooks/git-webhook?token=HOOK_TOKEN](#)\n\n---\n\n## Available Configuration Parameters\n\nThe following flags are a list of all the currently supported options that can be changed by passing in the variables to docker with the -e flag.\n\n### Base\n\n* **USE_HOOK** : The web hook is enabled as long as this is present.\n* **HOOK_TOKEN** : Custom hook security tokens, strings.\n* **GIT_REPO** : If it is a private repository, and is ssh link, set the private key file with the file name ***id_rsa*** must be set. If you use https link, you can also set this format link type: ***https://GIT_TOKEN@GIT_REPO***.\n* **GIT_BRANCH** : Select a branch for clone and auto hook match.\n* **GIT_EMAIL** : Set your email for git (required for git to work).\n* **GIT_NAME** : Set your name for git (required for git to work).\n* **INSTALL_DEPS_COMMAND**: Optional. The command your framework provides for install your code depends.  eg: `npm ci`. left blank, will not execute.\n* **BUILD_COMMAND**: Optional. The command your framework provides for compiling your code. eg: `npm run build`、`yarn build` . left blank, will not execute.\n* **OUTPUT_DIRECTORY**: Optional. The directory in which your compiled will be located. left blank, will not execute.\n* **STARTUP_COMMANDS** : Optional. Add any commands that will be run at the end of the start.sh script. left blank, will not execute.\n* **AFTER_PULL_COMMANDS** : Optional. Add any commands that will be run after pull. left blank, will not execute.\n* **BEFORE_PULL_COMMANDS** : Optional. Add any commands that will be run before pull. left blank, will not execute.\n* **AFTER_PACKAGE_COMMANDS** : Optional. Add any commands that will be run after package. left blank, will not execute.\n\n### Notify\n\n* **NOTIFY_ACTION_LABEL**: Optional. notify action name define. default : `StartUp|BeforePull|AfterPull|AfterPackage`\n* **NOTIFY_ACTION_LIST**: Optional. notify action list. included events will be notified. default : `BeforePull|AfterPackage`\n* **NOTIFY_URL_LIST** : Optional. Notify link array , each separated by **|**\n* **TELEGRAM_BOT_TOKEN**: Optional. telegram Bot Token-chatid setting. eg: **token###chatid|token2###chatid2**. each separated by **|** [Official Site](https://core.telegram.org/api).\n* **IFTTT_HOOK_URL_LIST** : Optional. ifttt webhook url array , each separated by **|** [Official Site](https://ifttt.com/maker_webhooks).\n* **DINGTALK_TOKEN_LIST**: Optional. DingTalk Bot TokenList, each separated by **|** [Official Site](http://www.dingtalk.com).\n* **JISHIDA_TOKEN_LIST**: Optional. JiShiDa TokenList, each separated by **|**. [Official Site](http://push.ijingniu.cn/admin/index/).\n* **APP_NAME** : Optional. When setting notify, it is best to set.\n\n---\n\n## Volume Configuration\n\n* **/root/.ssh** :  ssh key folder.\n* **/app/target** :  builded code files will move to this folder.\n* **/app/code** : git source code dir. docker work dir.\n* **/custom_scripts/on_startup** :  which the scripts are executed at startup, traversing all the scripts and executing them sequentially\n* **/custom_scripts/before_pull** :  which the scripts are executed at before pull\n* **/custom_scripts/after_pull** :  which the scripts are executed at after pull\n* **/custom_scripts/after_package** :  which the scripts are executed at after package.\n\n### ssh-keygen\n\n`ssh-keygen -t rsa -b 4096 -C \"youremail@gmail.com\" -N \"\" -f ./id_rsa`\n\n---\n\n## SendMessage\n\nYou can use notifications by call \"/app/scripts/utils.sh\" in the execution script.\n\n```bash\nsource /app/scripts/utils.sh;\n\nnotify_all \"hello world\"\n```\n\n---\n\n## Display Package Elapsed Time\n\nshow package elapsed second.\n\n```sh\ndocker exec servername cat /tmp/ELAPSED_TIME\n```\n\nshow package elapsed time label.\n\n```sh\ndocker exec servername cat /tmp/ELAPSED_TIME_LABEL\n```\n\nshow git commit hash that currently deployed successfully.\n```sh\ndocker exec servername cat /tmp/CURRENT_GIT_COMMIT_ID\n```\n\n---\n\n## Docker-Compose\n\nBase Demo Yaml.\n\n ```docker\nversion: '3'\nservices:\n  webapp:\n    image: funnyzak/git-webhook-deploy\n    privileged: true\n    container_name: webapp\n    working_dir: /app/code\n    logging:\n      driver: 'json-file'\n      options:\n        max-size: '1g'\n    tty: true\n    environment:\n      - TZ=Asia/Shanghai\n      - LANG=C.UTF-8\n      - USE_HOOK=1\n      - HOOK_TOKEN=hello\n      - GIT_REPO=https://github.com/vuejs/vuepress.git\n      - GIT_BRANCH=master\n      - GIT_EMAIL=abc@gmail.com\n      - GIT_NAME=potato\n      - INSTALL_DEPS_COMMAND=npm install\n      - BUILD_COMMAND=npm run build\n      - OUTPUT_DIRECTORY=.vuepress/dist/\n      - AFTER_PACKAGE_COMMANDS=echo \"elapsed time: $(cat /tmp/ELAPSED_TIME_LABEL)\"\n      - APP_NAME=vuepress_app\n      - NOTIFY_ACTION_LABEL=已启动|准备拉取代码|代码已拉取|打包部署完成\n      - NOTIFY_ACTION_LIST=StartUp|BeforePull|AfterPull|AfterPackage\n      - NOTIFY_URL_LIST=https://request.worktile.com/asdfsfwe\n      - TELEGRAM_BOT_TOKEN=123456789:SDFW33-CbovPM456PUDTLy1uYmN04I###9865587\n      - IFTTT_HOOK_URL_LIST=https://maker.ifttt.com/trigger/event_name/with/keyhelloworld\n      - DINGTALK_TOKEN_LIST=sldfj2hr923rsf2938u4sdfsf|lsdf203sjdf\n      - JISHIDA_TOKEN_LIST=fklsjfklj23094lfjsd\n    restart: on-failure\n    ports:\n      - 80:80\n    volumes:\n      - ./target:/app/target\n      - ./code:/app/code\n      - ./ssh:/root/.ssh\n      - ./after_package:/custom_scripts/after_package\n\n ```\n\nWebHook URL: [http://hostname/hooks/git-webhook?token=hello](#)\n\n---\n\n VuePress YAML.\n\n```Docker\nversion: '3'\nservices:\n  vuepressapp:\n    image: funnyzak/git-webhook-deploy\n    privileged: true\n    container_name: vuepress\n    working_dir: /app/code\n    logging:\n      driver: 'json-file'\n      options:\n        max-size: '1g'\n    tty: true\n    environment:\n      - TZ=Asia/Shanghai\n      - LANG=C.UTF-8\n      - USE_HOOK=1\n      - HOOK_TOKEN=6fcc11ace14c6\n      - APP_NAME=VuePress Docs\n      - GIT_REPO=git@github.com:youanme/reponame.git\n      - GIT_BRANCH=master\n      - GIT_EMAIL=youremail\n      - GIT_NAME=yourname\n      - INSTALL_DEPS_COMMAND=npm install\n      - BUILD_COMMAND=npm run build\n      - OUTPUT_DIRECTORY=.vuepress/dist/\n      - NOTIFY_ACTION_LABEL=已启动|源码拉取中..|源码已拉取最新,开始打包..|部署已完成\n      - NOTIFY_ACTION_LIST=StartUp|BeforePull|AfterPull|AfterPackage\n      - DINGTALK_TOKEN_LIST=dingtoken_one|dingtoken_two\n      - JISHIDA_TOKEN_LIST=jishida_token\n    restart: on-failure\n    ports:\n      - 80:80\n    volumes:\n      - ./code:/app/code\n      - ./target:/app/target\n      - ./ssh:/root/.ssh\n```\n\nWebHook URL: [http://hostname/hooks/git-webhook?token=6fcc11ace14c6](#)\n\nWeb URL: [http://hostname](#)\n\n---\n\n Hexo YAML.\n\n```Docker\nversion: '3'\nservices:\n  hexoapp:\n    image: funnyzak/git-webhook-deploy\n    privileged: true\n    container_name: hexo\n    working_dir: /app/code\n    logging:\n      driver: 'json-file'\n      options:\n        max-size: '1g'\n    tty: true\n    environment:\n      - TZ=Asia/Shanghai\n      - LANG=C.UTF-8\n      - USE_HOOK=1\n      - HOOK_TOKEN=6fcc11ace14c6\n      - APP_NAME=HexoBlog\n      - GIT_REPO=git@github.com:youanme/reponame.git\n      - GIT_BRANCH=master\n      - GIT_EMAIL=youremail\n      - GIT_NAME=yourname\n      - INSTALL_DEPS_COMMAND=npm install\n      - BUILD_COMMAND=npm run build\n      - OUTPUT_DIRECTORY=public/\n      - NOTIFY_ACTION_LABEL=已启动|源码拉取中..|源码已拉取最新,开始打包..|部署已完成\n      - NOTIFY_ACTION_LIST=StartUp|BeforePull|AfterPull|AfterPackage\n      - DINGTALK_TOKEN_LIST=dingtoken_one|dingtoken_two\n      - JISHIDA_TOKEN_LIST=jishida_token\n    restart: on-failure\n    ports:\n      - 80:80\n    volumes:\n      - ./code:/app/code\n      - ./target:/app/target\n      - ./ssh:/root/.ssh\n```\n\nStatic Web YAML.\n\n```Docker\nversion: '3'\nservices:\n  staticapp:\n    image: funnyzak/git-webhook-deploy\n    privileged: true\n    container_name: static\n    working_dir: /app/code\n    logging:\n      driver: 'json-file'\n      options:\n        max-size: '1g'\n    tty: true\n    environment:\n      - TZ=Asia/Shanghai\n      - LANG=C.UTF-8\n      - USE_HOOK=1\n      - HOOK_TOKEN=6fcc11ace14c6\n      - APP_NAME=staticsite\n      - GIT_REPO=git@github.com:youanme/reponame.git\n      - GIT_BRANCH=master\n      - GIT_EMAIL=youremail\n      - GIT_NAME=yourname\n      - OUTPUT_DIRECTORY=./\n      - NOTIFY_ACTION_LABEL=已启动|更新拉取中..|部署已完成|部署已完成\n      - NOTIFY_ACTION_LIST=StartUp|BeforePull|AfterPull\n      - DINGTALK_TOKEN_LIST=dingtoken_one|dingtoken_two\n      - JISHIDA_TOKEN_LIST=jishida_token\n    restart: on-failure\n    ports:\n      - 80:80\n    volumes:\n      - ./code:/app/code\n      - ./ssh:/root/.ssh\n```\n\nWebHook URL: [http://hostname/hooks/git-webhook?token=6fcc11ace14c6](#)\n\nWeb URL: [http://hostname](#)\n\n---\n\nNode App Deploy.\n\n```Docker\nversion: '3'\nservices:\n  nodeapp:\n    image: funnyzak/git-webhook-deploy\n    privileged: true\n    container_name: node\n    working_dir: /app/code\n    logging:\n      driver: 'json-file'\n      options:\n        max-size: '1g'\n    tty: true\n    environment:\n      - TZ=Asia/Shanghai\n      - LANG=C.UTF-8\n      - NODE_ENV=production\n      - USE_HOOK=1\n      - HOOK_TOKEN=6fcc11ace14c6\n      - APP_NAME=nodeapp\n      - GIT_REPO=git@github.com:youanme/reponame.git\n      - GIT_BRANCH=master\n      - GIT_EMAIL=youremail\n      - GIT_NAME=yourname\n      - INSTALL_DEPS_COMMAND=npm install --production # if after pull then  install deps\n      - NOTIFY_ACTION_LABEL=已启动|更新拉取中..|最新更新已拉取|已完成启动\n      - NOTIFY_ACTION_LIST=StartUp|BeforePull|AfterPull|AfterPackage\n      - DINGTALK_TOKEN_LIST=dingtoken_one|dingtoken_two\n      - JISHIDA_TOKEN_LIST=jishida_token\n    restart: on-failure\n    ports:\n      - 9000:9000 # hook url\n      - 168:168 # node app port, Configured according to the actual listening port of the node app\n    volumes:\n      - ./start_app.sh:/custom_scripts/after_package/run_app.sh\n      - ./ssh:/root/.ssh\n      - ./code:/app/code\n```\n\nstart_app.sh\n\n```bash\n#!/bin/bash\n\ncd /app/code\n\nNODE_ENPOINT_SCRIPT=\"index.js\"  # your node enterpont script\n\ntpid=`ps -ef|grep $NODE_ENPOINT_SCRIPT|grep -v grep|grep -v kill|awk '{print $2}'`\nif [ ${tpid} ]; then\n    echo 'Stop App Process...'\n    kill -15 $tpid\nfi\n\nsleep 5\n\necho \"kill app thread.\"\nps ax |grep $NODE_ENPOINT_SCRIPT | awk '{print $1}' |xargs kill -9 ;\n\necho \"clear nohup log.\"\ncat /dev/null \u003e nohup.out\n\nsleep 2\n\necho \"start app ..\"\nnohup node $NODE_ENPOINT_SCRIPT NODE_ENV=production \u0026  # your node run command\n\n```\n\nWebHook URL: [http://hostname:9000/hooks/git-webhook?token=6fcc11ace14c6](#)\n\nNODE App URL: [http://hostname:168](#)\n\n---\n\nJava SpringBoot App Deploy.\n\n```Docker\n  springboot:\n    image: funnyzak/git-webhook-deploy\n    privileged: true\n    container_name: springbootapp\n    working_dir: /app/code\n    logging:\n      driver: 'json-file'\n      options:\n        max-size: '1g'\n    tty: true\n    environment:\n      - spring.config.location=/app/target/application.yaml # your application yaml\n      - spring.profiles.active=prod\n      - TZ=Asia/Shanghai\n      - LANG=C.UTF-8\n      - USE_HOOK=1\n      - HOOK_TOKEN=1234567890\n      - APP_NAME=MySpringBootApp\n      - GIT_REPO=git@github.com:youanme/reponame.git\n      - GIT_BRANCH=master\n      - GIT_EMAIL=youremail\n      - GIT_NAME=yourname\n      - BUILD_COMMAND=mvn -B clean package -Dmaven.test.skip=true -Dautoconfig.skip  # jar package command.\n      - OUTPUT_DIRECTORY=web_modules/target/execute_jar_name.jar # setting your package jar file path\n      - NOTIFY_ACTION_LABEL=已启动|更新拉取中..|最新更新已拉取|已完成启动\n      - NOTIFY_ACTION_LIST=StartUp|BeforePull|AfterPull|AfterPackage\n      - DINGTALK_TOKEN_LIST=dingtoken_one|dingtoken_two\n      - JISHIDA_TOKEN_LIST=jishida_token\n    restart: on-failure\n    ports:\n      - 9000:9000 # hook url\n      - 168:168 # app port, Configured according to the actual listening port of the app\n    volumes:\n      - ./ssh/root/.ssh\n      - ./start_app.sh:/custom_scripts/after_package/start.sh\n      - ./code:/app/code\n      - ./target:/app/target\n```\n\nstart_app.sh\n\n```bash\n#!/bin/bash\n\ncd /app/target\n\nJAR_PACKAGE_NAME = \"execute_jar_name.jar\"\n\ntpid=`ps -ef|grep $JAR_PACKAGE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`\nif [ ${tpid} ]; then\n    echo 'Stop App Process...'\n    kill -15 $tpid\nfi\n\nsleep 5\n\necho \"kill app thread.\"\nps ax |grep $JAR_PACKAGE_NAME | awk '{print $1}' |xargs kill -9 ;\n\necho \"clear nohup log.\"\ncat /dev/null \u003e nohup.out\n\nsleep 2\n\necho \"run java -jar /app/target/$JAR_PACKAGE_NAME\"\nnohup java -jar /app/target/$JAR_PACKAGE_NAME \u0026\n\n```\n\nWebHook URL: [http://hostname:9000/hooks/git-webhook?token=1234567890](#)\n\nNODE App URL: [http://hostname:168](#)\n\n---\n\nPlease configure according to the actual deployment path and port.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnyzak%2Fgit-webhook-deploy-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunnyzak%2Fgit-webhook-deploy-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnyzak%2Fgit-webhook-deploy-docker/lists"}