Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hooks on docker #31

Open
fvanderbiest opened this issue Jul 29, 2017 · 0 comments
Open

hooks on docker #31

fvanderbiest opened this issue Jul 29, 2017 · 0 comments

Comments

@fvanderbiest
Copy link
Contributor

fvanderbiest commented Jul 29, 2017

In my hooks, I've had to use git (among other tools) as a specific user (whose uid is 999).

Since git was not provided by the carlos-jenkins/python-github-webhooks docker image (and I did not want to hack into it) I derived a customized image based on yours, with this Dockerfile.extended:

FROM carlos-jenkins/python-github-webhooks

MAINTAINER "François Van Der Biest" <[email protected]>

# add packages required to run your hooks, eg:
RUN apk update && apk add bash git openssh-client

# create user which will run hooks (group ping has gid=999 in base image)
RUN adduser -S -G ping -s /bin/bash -u 999 sftp

# required here to populate root's known_hosts so that git pull command 
# does not interactively ask to check RSA key fingerprint:
RUN mkdir -p /root/.ssh && \
    chmod 700 /root/.ssh && \
    ssh-keyscan github.com >> /root/.ssh/known_hosts

then: docker build -t fvanderbiest/python-github-webhooks -f Dockerfile.extended .

Finally, I set the setuid bit on my hook, and gave it to user with uid 999:
chmod u+s push-myrepo-mybranch

It works great !
This is not really an issue, but I thought it might be useful to others...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant