Menu
blog.headdesk.me
blog.headdesk.me

Automate docker image build and push

Posted on 2020/04/292021/07/25

I’m experimenting with Jenkins and I’m starting to like it. In this page, I’m going to demonstrate how to configure Jenkins to build docker image and push it to my registry automatically.

What you’ll need:

  • A git repository storing the Dockerfile
  • A docker registry to push the image to
  • A machine with Jenkins installed
  • Jenkins needs the git and Docker plugins

On Jenkins console, create a project. For example, amzn2-awscli2. In the Source Code Management section, configure Jenkins to pull from my git repo. In this example, the repo is on https://xpk.headdesk.me/git/xpk/amzn2-awscli2.git and it’s public so no credential required.

In the build trigger section, enable Build periodically and tell Jenkins to perform the build weekly. The dockerfile itself does not change frequently. Otherwise a git webhook would be preferred. I still want the build to happen regularly to keep my awscli current.

In the build section, tell Jenkins where to push the image and what to name it. In this case, it’s registry.one27.cf/amzn2-awscli2

Finally, in the Post-build section, tell Jenkins to clean up the workspace after build.

Click build now in this project and after a few minutes, the image is built and pushed to my registry.

It’s a minimalist demonstration. I’m still learning about Jenkins. Comments are welcomed.

Loading

Full text search

Recent Posts

  • Error 0xc1900101 when updating to Windows 11 22H2
  • Apply changes to all member accounts in an AWS organization
  • RPI4 under voltage
  • Upgrade RockyLinux 8 to 9
  • Terraform and segregated permissions
  • aws (9)
  • coffee (1)
  • headfi (1)
  • linux (8)
  • others (57)
  • security (2)
  • tech (39)
  • wordpress (2)

Loading

apache apigateway aws awscli azure backup cloud coffee docker ec2 EL8 ElasticBeanstalk enpass espresso featured kernel lelit linux lvm meltdown MFA mikrotik nat gateway nginx php power python rdp Redhat RHEL rpm Ryzen s2s scp serverless site-to-site snapshot spectre tech terraform ubuntu ubuntu upgrade vpn wordpress xdotool

©2023 blog.headdesk.me | Powered by SuperbThemes