Skip to content

Instantly share code, notes, and snippets.

@fmarten
Last active July 26, 2018 13:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fmarten/e223cc8b821b317450a64ae043c41664 to your computer and use it in GitHub Desktop.
Save fmarten/e223cc8b821b317450a64ae043c41664 to your computer and use it in GitHub Desktop.
Packer Template for Ubuntu 16.04 with Docker Compose as Amazon Machine Image (AMI)
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_KEY`}}"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "eu-central-1",
"source_ami_filter": {
"filters": {
"name": "*ubuntu-xenial-16.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"instance_type": "t2.micro",
"ssh_username": "ubuntu",
"ami_name": "Ubuntu 16.04 with Docker Compose",
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sudo apt-get update && sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y",
"sudo groupadd docker",
"sudo gpasswd -a ubuntu docker",
"curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -",
"sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"",
"sudo apt-get update && sudo apt-get install docker-ce -y",
"sudo curl -L \"https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose",
"sudo chmod +x /usr/local/bin/docker-compose"
]
}
]
}
@fmarten
Copy link
Author

fmarten commented Mar 13, 2017

Creates an AMI with docker-compose provisioned on it using Packer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment