Build own drone.io docker image
¡Hola, amigos!
In this post, I will quickly descibe how you can build your own drone.io docker image.
Drone is very popular container native CI/CD platform. Not long time ago, there was release of new 1.0 version of drone. Which brang a lot of cool features and new license. The license tells that we can use Enterprise version of drone for free without any limits by building our own docker image if we are individuals or startup (read the licence for more detail).
So, how to build it?
Instructions
First, clone the drone repo to your local machine.
git clone [email protected]:drone/drone.git
Second, checkout to version of drone you want to build. For example, I want to build v1.3.1:
git checkout v1.3.1
We will use single dockerfile to build the image. To do so, we need to add extra step to existing dockerfile which is in docker
directory. Let’s say we want to build docker image for linux
OS and amd64
architecture, then we will edit docker/Dockerfile.server.linux.amd64
.
If you check the dockerfile you will see, that binaries are just copied into docker image during the build and they are built outside of the docker build. So, the step we will add to dockerfile is go build
step.
To build the binary, we need to know what version of go is used for building binary in original docker image. We can find it in drone.yml
build step. For version 1.3.1 of drone golang:1.12.9
docker image is used for building binaries.
Then, we use same image to build binary in our dockerfile:
1 |
|
Also we need to delete .dockerignore file from root of the repo.
rm .dockerignore
Then we build docker image like:
docker build -t alikhil/drone:1.3.1 -f docker/Dockerfile.server.linux.amd64 .
That’s all! Now you can use own newly built docker image instead of official one if your use case meet license conditions.