Continuous Integration is about building your apps on every change and on a regular schedule. It used to mean maintaining and managing build servers and complex build scripts - where the build for production was nothing like the developer workflow. Not any more…
In this episode we’ll combine multi-stage Dockerfiles with a build infrastructure running in containers, to make for a simple and portable approach to CI. We’ll use Jenkins and run all the components locally using Docker.
Here it is on YouTube - ECS-C1: Continuous Integration with Docker and Jenkins
Gogs - “a painless self-hosted Git service”
Jenkins - the world’s favourite automation server…
Registry - Docker registry image
Using Declarative Jenkins Pipelines - Pluralsight
We’ll run a full build stack - Git server, automation server and container registry.
Spin up the infrastructure:
docker-compose -f ./infrastructure/docker-compose.yml up -d
Check the registry server:
And setup Gogs:
Finish the configuration and create a user and repo:
ecs- Gogs has issues & wiki like GitHub
Add the local Git server as a remote:
git remote add local http://localhost:3000/ecs/ecs.git git push -u local
See Diamol ep. 10 for automation options
We have a distributed app to build in the
Build arguments get used as labels to provide an audit trail from the final image.
Build the app locally:
docker-compose -f ./src/docker-compose.yml build docker image inspect sixeyed/image-of-the-day:ecs-c1
Default label values for the local build
Check Jenkins is up and running:
docker logs infrastructure_jenkins_1
Browse to Jenkins at http://localhost:8080
* * * * *
Configure the source repo to use Gogs:
Build now and check the logs
Jenkins is using this Jenkinsfile. It runs Docker commands using the local Docker Engine - from the bind mounted socket.
Check the images it builds are in the local image cache:
docker image ls registry.local:5000/*/* docker image inspect registry.local:5000/ecs/image-gallery:ecs-c1
Your CI process can run end-to-end tests in containers and push the app images to a local registry.
Then it would go on to do security scanning and signing before pushing to a production repo for release.
There’s a simple test container in e2e-test/Dockerfile - it connects to the image API container using the container name.
Change the Jenkins job at http://localhost:8080/job/ecs-c1/configure
Build now and check logs
The new pipeline uses the job in Jenkinsfile.v2.
Verify the new build:
docker image inspect registry.local:5000/ecs/image-gallery:ecs-c1
And check the images in the local registry:
curl http://registry.local:5000/v2/_catalog curl http://registry.local:5000/v2/ecs/access-log/tags/list