This is a walkthrough on how you can put The Amazon Q Developer CLI inside a docker container for use inside your CI/CD Pipelines
Thing's you'll need.
An Amazon Q Developer Pro Subscription
Alternatively you can use your Amazon Builder ID if you want to use the free version!
A local installation of the Amazon Q Developer CLI
Access to Docker and a Private Docker Registry
A CI/CD Orchestration tool that supports containers - I'll be using GitHub Actions for this Walkthrough
Pre-Authenticating Your Container
Before we build a container - we need to log in to the Amazon Q Developer CLI
You can install the Amazon Q CLI by following the installation instructions here
Once installed, initiate the login process with q login
Select Your License Type, and fill out the instructions.
Once Logged in you should be able to run the command q chat to get a similar output like this
Building your Container
Awesome! we are logged in. Now to build our docker image.
Before we build the docker image, we need to copy the authentication files into our local docker context. We can do this by running cp -r ~/.local/share/amazon-q ./auth
After our auth is copied over - lets create a Dockerfile with the following contents
Now lets run docker build -t amazon-q-authenticated . to build our docker image.
Once built - let's jump in to confirm it works! Run docker run --rm -it --entrypoint=/bin/bash amazon-q-authenticated then validate your login works with q chat
Publishing Your Image
Publishing your image can be done by tagging your image and running docker push to push it to a pre-authenticated docker registry.
Here's an example of pushing it to ECR - see this link on how to authenticate with an ECR repository
Using Your Image in the CI/CD Context
Once your ECR Image is pushed, you can now use Amazon Q in the CI/CD context! Here's an example GitHub action of using the /doc command to generate release notes for all the changes between the last tag.
What next?
Now we've got our AI assistant working alongside our automation, the sky is the limit! Let me know what you use this for!