This is a repo for Docker image creation using Packer and CICD build for docker image using Jenkins on Google Cloud Platform
Config-file | Description |
---|---|
Dockerfile |
To create a Docker agent/base image with OpenJDK, packer package & SSH for Jenkins Slave/agent node configuration |
Build-Base-Docker-Image-cmds |
Commands to build a Docker agent/base image and push to your Docker hub account for publicly available |
2. Manually Build a Ulta Golden Docker image and upload an artifact to Google container registry using Packer Script
Config-file | Description |
---|---|
Packer.json |
To create/build a Golden Docker base image with ulta's quazi packages |
- Commands to manually build GKE - Golden Docker image using packer
Step 1: Make sure, you have Team Libraries( install-package.sh shell script) and Python packages( python_requirements.txt) are specified under "teams" folder.
Step 2: cat packer.json
Step 3: To validate packer script
$ ./packer validate packer.json
Step 2: To build using packer script
$ ./packer build -var "image_name=<your_image_type>" -var "team_name=<quazi_or_ccp>" -var "project_id=<your_project_id>" -var "gcp_container_reg_name=<name_for_gcp_container_reg>" -var "docker_hub_id=<your_docker_hub_id>" -var "docker_hub_password=<your_docker_hub_password>" packer.json
Example outputs from Packer script
Config-file | Description |
---|---|
Packer.josn |
Automate CICD to create/build a Golden Docker base image with ulta's quazi packages |
configure-docker-host |
On docker host, to expose docker’s TCP port so DockerPlugin can access docker host and create build slave container |
- Step 1: Integrate/Configure Jenkins with Github repo and Google cloud platform.
- Step 2: Configure Jenkins with required plugins
- Step 3: Configure Jenkins slave/agent node
- Step 4: Create a GCP firewall rule for Docker TCP port
- Setp 5: Create a jenkins job to build process for docker golden image
GCP Firewall Rule to docker’s TCP port:
- Command to build GKE - Golden Docker image using automation
$ packer build -var "build_number=$BUILD_NUMBER" -var "job_name=$JOB_NAME" -var "team_name=quazi" packer.json
Verification on Google Container Registry
$ packer build -var "team_name=quazi" -var "build_number=$BUILD_NUMBER" -var "job_name=$JOB_NAME" -var "image_name=<your_image_type>" -var "project_id=<your_project_id>" -var "gcp_container_reg_name=<name_for_gcp_container_reg>" -var "docker_hub_id=<your_docker_hub_id>" -var "docker_hub_password=<your_docker_hub_password>" packer.json
$ packer build -var "team_name=ccp" -var "build_number=$BUILD_NUMBER" -var "job_name=$JOB_NAME" -var "image_name=<your_image_type>" -var "project_id=<your_project_id>" -var "gcp_container_reg_name=<name_for_gcp_container_reg>" -var "docker_hub_id=<your_docker_hub_id>" -var "docker_hub_password=<your_docker_hub_password>" packer.json