Build and deploy a docker image using Komodo, automatically
Off topic, again
Lilo Coffee Roasters is good, but not as shockingly great as Glitch.
Coffee bean is a OK for me, bit too light roasted for me.
May be just for the beans next time.
Back to the topic
Recently I built a small project and I want to run the code inside Docker container.
I am going to host this Docker container inside my homelab, but too lazy to do the manual docker build
and docker run
each time I change something.
So again, Komodo comes to the rescue
It takes your code and
Dockerfile
, and build the Docker image for you.
And deploy that for you, all in one git push, no additional Github action.
Add builder in Komodo to build image
- Go to
Resources > Builders
- Click
New Builder
, setname
of your builder and builder Type =Server
- Pick the server you want to build your Docker image at
Add a build profile in Komodo, which automates the build
- Go to
Resources > Builds
- Fill in the necessary information
- Builder
- Version (You can set initial version and auto-increment the version per git push)
- Source, account and repo
- Image Registry (you can push to custom Image Registry like Dockerhub, Nexus…)
- The deployment will find the
Dockerfile
in the root of the git repo
- If you want to change that, change the
Dockerfile path
Yes, your instinct are right. The automation is done by Webhook. Again.
- Just like the automatic stack deployment, enable the webhook function
- Set the secret and copy the url, secret to Gitea project
Then you have an auto-build Docker Image action when you push your changes to git repo.
Final touch, the auto deployment after build
- Go to
Resources > Deployments
- Fill in the necessary information
- Server (that host the docker container, if your build destination is local, please make sure you run on the same machine)
- Build (Select “Build” on the first dropdown, and the build name you have just created last step)
- Turn on “Redeploy on build” to automatically deploy after the build is complete
- Network Mode
After setting these items, you can test your stuff by pushing changes to git repo
And see the container is automatically re-deployed.
Maybe I want a centralized private Docker registry just because it is more convenient to build and deploy in different machine.