We have been using Hashicorp Enterprise to run our packer builds. They are stopping that service and I am looking to see if this can be done with the bitbucket pipelines. I have all the packer files and scripts currently in bitbucket but do not have any pipelines that run the packer build. Can someone point me in the right direction or show me a example of running packer build for AWS AMIs?
We use packer build from within a pipeline all the time, the only exception is when building docker images.
This is because `packer build` actually executes `docker run` in order to provision. `docker run` is prohibited from within a pipeline.
Messy, but it is possible to get a pipeline to kick off an ecs task, which in turn runs the packer docker build (use terraform, and I am unsure if the Fargate type will be possible here because you would need to mount the docker socket).
Another messy workaround... you could run a packer build within a packer build. The outer`packer build` spins up an EC2 instance from an AMI with docker and packer preinstalled, the inner`packer build` runs the docker builder and docker tag/push post-processors. Is there an option for skipping the creation of the AMI? If not, you would need to make the outer `packer build` provisioning script fail.
Messy I know, but it would result in the docker image artifacts you are after from within a bitbucket pipeline. As I said earlier, all other packer artifacts can easily be achieved from within pipelines.
I can send some configurations if that would be helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.