I frequently have to test code on Amazon Linux 2 - both for work and for the PowerShell Core universal install script install-powershell.sh that I help maintain on the PowerShell Open Source project.
Spinning up an instance on Amazon is not a hassle, unless of course, you compare it to spinning up a container. Amazon Linux 2 container images are necessarily super-optimized to run as a container host for applications - so they have many packages removed compared to an Amazon Linux 2 EC2 AMI build.
But when I am testing something that will run on the full EC2 build, I’d still like to use a container.
Full EC2 Build in a Container For Testing (Builds Monthly)
To satisfy this requirement I have created a full ec2 build container that has all the same packages. It can be pulled with this command:
docker pull darwinjs/amazonlinux2ec2build
To be quite clear, I would never use this container as a foundation for building a containerized application using Amazon Linux 2 containers. Following standard container engineering practices, the base amazon container should be leveled up with the minimum possible packages to get it ready for an given microservice.
This approach is strictly for quick and dirty testing - usually of shell scripts that don’t have dependencies on an full amazon environment being available.
Minimal EC2 Container Build with PowerShell (Builds Monthly)
Under the same approach - testing only - I have also put together an Amazon Linux 2 PowerShell Core container that layers on the bare minimum to get PowerShell Core operational. It can be accessed as such:
docker pull darwinjs/amazonlinux2powershell
Full EC2 Build with PowerShell (Builds Monthly)
I have to create PowerShell Core scripts that can run on my team mates Macs. For this scenario a full Ec2 Build Container along with PowerShell suites the purpose well:
docker pull darwinjs/amazonlinux2powershell
An alternative to this prepared container is to run the following one command on the full Amazon Linux 2 EC2 Build Container to ensure you are getting the very latest version of PowerShell core:
curl -s https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/installpsh-amazonlinux.sh | bash
Build Schedule
Gitlab CI is scheduled to build these images on the third day of the month.
The Power Of Stars
If you find any of the images useful, please let me know by adding a star to it in the docker repository so I know to keep investing in it :)
Code for this Article
The below repositories contain the images and the source files for building them using Gitlab CI.
Docker Image Repos
https://hub.docker.com/r/darwinjs/amazonlinux2ec2build https://hub.docker.com/r/darwinjs/amazonlinux2powershell https://hub.docker.com/r/darwinjs/amazonlinux2ec2buildpowershell
Source Repos:
https://gitlab.com/DarwinJS/amazon-linux-2-ec2-build https://gitlab.com/DarwinJS/amazon-linux-2-container-with-powershell https://gitlab.com/DarwinJS/amazon-linux-2-ec2-build-container-with-powershell