{"id":22615637,"url":"https://github.com/marcellodesales/github-prereceive-base-docker","last_synced_at":"2026-01-07T06:47:42.668Z","repository":{"id":142072587,"uuid":"112236325","full_name":"marcellodesales/github-prereceive-base-docker","owner":"marcellodesales","description":"Base Docker Image for development of Hooks for Github Enterprise","archived":false,"fork":false,"pushed_at":"2019-11-26T10:11:54.000Z","size":13,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T10:46:23.071Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcellodesales.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-11-27T19:03:42.000Z","updated_at":"2017-11-27T19:36:59.000Z","dependencies_parsed_at":"2023-07-09T05:31:17.320Z","dependency_job_id":null,"html_url":"https://github.com/marcellodesales/github-prereceive-base-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/marcellodesales%2Fgithub-prereceive-base-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcellodesales%2Fgithub-prereceive-base-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcellodesales%2Fgithub-prereceive-base-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcellodesales%2Fgithub-prereceive-base-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcellodesales","download_url":"https://codeload.github.com/marcellodesales/github-prereceive-base-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246122247,"owners_count":20726822,"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":[],"created_at":"2024-12-08T19:08:42.007Z","updated_at":"2026-01-07T06:47:42.629Z","avatar_url":"https://github.com/marcellodesales.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Github Pre-receive Hook: Base Image\n\nThis is the base image from the Dockerfile https://help.github.com/enterprise/2.6/admin/guides/developer-workflow/creating-a-pre-receive-hook-script/#testing-pre-receive-scripts-locally\n\n[![resolution](http://dockeri.co/image/marcellodesales/github-enterprise-prereceive-hook-base \"Github Enterprise Pre-Receive Hook Base Image\")](https://hub.docker.com/r/intuit/spring-cloud-config-validator/)\n\n# Build\n\n```\n$ docker build -t github-enterprise-pre-receive-hook-base .\nSending build context to Docker daemon 208.9 kB\nStep 1 : FROM pre-receive.dev\n ---\u003e 174b3be1d2c9\nStep 2 : MAINTAINER Marcello_deSales@intuit.com\n ---\u003e Running in e3965f484166\n ---\u003e 5cafeb0f185b\nRemoving intermediate container e3965f484166\nStep 3 : RUN apk add --no-cache py-pip \u0026\u0026   pip install pyyaml pyjavaproperties\n ---\u003e Running in 38674126a032\nfetch http://alpine.gliderlabs.com/alpine/v3.3/main/x86_64/APKINDEX.tar.gz\nfetch http://alpine.gliderlabs.com/alpine/v3.3/community/x86_64/APKINDEX.tar.gz\n(1/7) Installing libbz2 (1.0.6-r4)\n(2/7) Installing libffi (3.2.1-r2)\n(3/7) Installing gdbm (1.11-r1)\n(4/7) Installing sqlite-libs (3.9.2-r0)\n(5/7) Installing python (2.7.12-r0)\n(6/7) Installing py-setuptools (18.8-r0)\n(7/7) Installing py-pip (7.1.2-r0)\nExecuting busybox-1.24.2-r0.trigger\nOK: 81 MiB in 33 packages\nCollecting pyyaml\n  Downloading PyYAML-3.12.tar.gz (253kB)\nCollecting pyjavaproperties\n  Downloading pyjavaproperties-0.6.tar.gz\nInstalling collected packages: pyyaml, pyjavaproperties\n  Running setup.py install for pyyaml\n  Running setup.py install for pyjavaproperties\nSuccessfully installed pyjavaproperties-0.6 pyyaml-3.12\nYou are using pip version 7.1.2, however version 8.1.2 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\n ---\u003e 96d7af8e0851\nRemoving intermediate container 38674126a032\nSuccessfully built 96d7af8e0851\n```\n\n# Extensions\n\nYou can create your own Github Pre-receive hook. Just create another image `FROM` this image.\nThe example below shows adding `python` to the docker image in order to execute a python script.\n\n```\n$ docker build -f Dockerfile.spring-cloud-config-validation -t springboot-config-verification . \nSending build context to Docker daemon 210.4 kB\nStep 1 : FROM github-enterprise-pre-receive-hook-base\n ---\u003e 174b3be1d2c9\nStep 2 : MAINTAINER Marcello_deSales@intuit.com\n ---\u003e Using cache\n ---\u003e 5cafeb0f185b\nStep 3 : RUN apk add --no-cache py-pip \u0026\u0026   pip install pyyaml pyjavaproperties\n ---\u003e Using cache\n ---\u003e 96d7af8e0851\nSuccessfully built 96d7af8e0851\n```\n\n# Setup for Verification\n\nYou must run a container that holds the data, which means, having a script that does the validation.\n\n```\n$ docker run --name data springboot-config-verification /bin/true\n```\n\nAfter that, you can simply copy the verification script to the running container. This is step 7 from the\ngithub Enterprise documentation https://help.github.com/enterprise/2.6/admin/guides/developer-workflow/creating-a-pre-receive-hook-script/#testing-pre-receive-scripts-locally.\n\n```\n$ docker cp validate-config-files.py data:/home/git/test.git/hooks/pre-receive\n```\n\nAt this point, you can start a github server that mimics Github Enterprise as follows:\n\n```\n$ docker run -d -p 52311:22 --volumes-from data springboot-config-verification \n7966ae3a6b83184cb38b6cbd1bbef22b35a52955f035f87b4f7a53b541352c2b\n\n$ docker ps\nCONTAINER ID        IMAGE                            COMMAND               CREATED             STATUS              PORTS                   NAMES\n7966ae3a6b83        springboot-config-verification   \"/usr/sbin/sshd -D\"   7 seconds ago       Up 6 seconds        0.0.0.0:52311-\u003e22/tcp   ecstatic_panini\n```\n\nBefore you can push to the server, copy the ssh keys from the Git server locally so you can connect to it.\n\n```\n$ docker cp data:/home/git/.ssh/id_rsa id_rsa_from_container\n```\n\n* Make sure to remember that commands that needs to connect to the Git server requires the relative or full path to `id_rsa_from_container`.\n\n## Subsequent Work\n\nAnd finally, you can quickly iterate and test your verification script using the following:\n\n```\n$ docker run --name gitrepo -e GITHUB_PULL_REQUEST_HEAD=534b172 -e GITHUB_PULL_REQUEST_BASE=f394274 -d -p 52311:22 --volumes-from data -e GIT_DIR=/home/git/test.git springboot-config-verification\n```\n\nAnd then, you can quickly re-execute using:\n\n```\ndocker stop gitrepo \u0026\u0026 docker rm gitrepo \u0026\u0026 docker run --name gitrepo -e GITHUB_PULL_REQUEST_HEAD=534b172 -e GITHUB_PULL_REQUEST_BASE=f394274 -d -p 52311:22 --volumes-from data -e GIT_DIR=/home/git/test.git springboot-config-verification\ngitrepo\ngitrepo\nafe70ca2e5b51757a5cf8ea2126c662a94b6ba49a6bb093080666baaf7e02551\n```\n\nThis is the point where you have an ssh server simulating a git server and ready to execute the `pre-receive` hook you can create.\n\n# Executing checks locally\n\nAfter setting up the ssh server above, you are ready to verify your script. You need to add the ssh server as a test remote origin to any directory from a cloned Github repository.\n\nDetermine which ip address locally represents your machine. ifconfig can help you.\n\n* Linux: try eth0 or eth1\n\n```\n$ git remote add test git@$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'):test.git\n```\n\n* Mac: try en0 or en1 depending on wifi or ethernet.\n\n```\n$ git remote add test git@$(ipconfig getifaddr en0):test.git\n```\n\nThe command gets the ip address of the host and adds as the server. You can verify if the server is reachable using the following command.\n\n\u003e Note that you need to `id_rsa_from_container` you copied from the data container described in previous section.\n\n```\n$ GIT_SSH_COMMAND=\"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 52311 -i PATH_TO_ID/id_rsa_from_container\" git remote show test\nWarning: Permanently added '[172.16.188.135]:52311' (ECDSA) to the list of known hosts.\n* remote test\n  Fetch URL: git@172.16.188.135:test.git\n  Push  URL: git@172.16.188.135:test.git\n  HEAD branch: (unknown)\n```\n\nAt this point, you are ready to proceed. Execute the push command and the pre-commit hook you developed will be automatically verifying your code. Note that if the pre-receive hook fails, the commit won't be accepted.\n\n```\n$ GIT_SSH_COMMAND=\"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 52311 -i PATH_TO_ID/id_rsa_from_container\" git push -u test master        \nWarning: Permanently added '[172.16.188.135]:52311' (ECDSA) to the list of known hosts.\nCounting objects: 214, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (100/100), done.\nWriting objects: 100% (214/214), 21.71 KiB | 0 bytes/s, done.\nTotal 214 (delta 126), reused 184 (delta 109)\nremote: ##################################################\nremote: ###### Intuit Spring Cloud Config Validator ######\nremote: ##################################################\nremote: Processing base=0000000000000000000000000000000000000000 commit=6ff408ac89564c994925c46847d775fff940caa3 ref=refs/heads/master\nremote: =\u003e Validating SHA 6ff408ac89564c994925c46847d775fff940caa3\nremote: ✘ File .matrix-android.json is NOT valid: Extra data: line 2 column 11 - line 29 column 1 (char 11 - 394)\nremote: ✔ File .matrix-ios.json is valid!\nTo git@172.16.188.135:test.git\n ! [remote rejected] master -\u003e master (pre-receive hook declined)\nerror: failed to push some refs to 'git@172.16.188.135:test.git'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcellodesales%2Fgithub-prereceive-base-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcellodesales%2Fgithub-prereceive-base-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcellodesales%2Fgithub-prereceive-base-docker/lists"}