A simple Packer script to create an Ubuntu based AMI to run Docker Compose applications from a cloud-init user-data.
EC2 tags will become environment variables
(written to a .env
file).
A docker login
will be done if a value is found for docker.username
and docker.password
into
EC2 Systems Manager
using GetParameters.
$ git clone https://github.com/pierredavidbelanger/cloud-compose
$ cd cloud-compose
$ packer build \
-var 'aws_region=us-east-2' \
-var 'aws_source_ami=ami-618fab04' \
ami.json
Launch an EC2 instance with the AMI created above and this user-data content:
#cloud-config
write_files:
- path: /var/lib/cloud-compose/docker-compose.yml
content: |
version: '3'
services:
hello-world:
image: tutum/hello-world
restart: always
ports:
- 8080:80