Build on git push
build your own stuff
- tags
- git
- build
- docker
Contents
I miss the days of git push heroku
. How hard would it be to do this
ourselves?
I did find an old project called git-deploy which integrates very
nicely with the git command, but has a bunch of ruby
and rails
specific stuff inside of the build script itself. I love ruby, but
I'm in more of a docker
based life-style right now. So i took the
opportinity to time travel back into blogs from the early '10s to pick
apart this information for you!
The Basic Plan
Create the app
user
First we are going to setup git on the server. We'll create an app
user that will do the deployment and host the repositories.
Connect to the server and create the user with the docker
group so it
can do builds. We'll copy of the .ssh
keys so that we can log in
without a password.
Finally, lets create a place for the apps to live.
|
|
Create an empty repo and push to it
On the server:
|
|
Adding a post-receive
hook
|
|
Then in /apps/summarize.willschenk.com/hooks/post-receive
:
|
|
Then make sure it's executable
|
|
And also make sure that you've logged into your registry!
|
|
Test it out
Back on your laptop:
Lets pull down a repo, give it a Dockerfile
, and push it to our server
to see if it builds.
|
|
Lets create a Dockerfile
that we'll use to build this up:
|
|
Now push:
|
|
And you should see it build and push to the repository in your git client!
Manual deploy
On the server you can test this with:
|
|
So it works, it builds and is in the registry. This isn't a generalized solution but its a good start.
References
Look at all this going back in time!
1. Ryan Florence: Deploying Websites With a Tiny Git Hook
- https://gist.github.com/ryanflorence/585746
- francoisromain/project-create.sh
- Missing git hooks documentation
- https://githooks.com/
- Dokku Git Deployment
- Digital Ocean: How To Use Git Hooks To Automate Development and Deployment Tasks
- awesome git hooks
- Omer Katz: Git Hooks (Part I) - The Basics
- https://whatthecommit.com/
Previously
Next