Skip to content

Instantly share code, notes, and snippets.

@shadedyin
Created July 9, 2015 00:00
Show Gist options
  • Save shadedyin/6fc82e0ff806a72861bb to your computer and use it in GitHub Desktop.
Save shadedyin/6fc82e0ff806a72861bb to your computer and use it in GitHub Desktop.
resource "aws_instance" "registry" {
ami = "ami-45c53d2e"
key_name = "psev-longsight"
instance_type = "t2.small"
associate_public_ip_address = true
subnet_id = "${aws_subnet.registry-b.id}"
vpc_security_group_ids = [ "${aws_security_group.registry.id}" ]
provisioner "file" {
source = "conf/registry.service"
destination = "/etc/systemd/system/registry.service"
}
provisioner "remote-exec" {
inline = [
"cat <<EOF > /etc/systemd/system/registry.service
[Unit]
Description=Docker Registry Container
Requires=docker.service
After=docker.service
[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker stop registry
ExecStartPre=-/usr/bin/docker rm registry
ExecStartPre=/usr/bin/docker pull psev/s3registry
ExecStart=/usr/bin/docker run \
--name registry \
-p 127.0.0.1:5000:5000 \
-e LOG_SERVICE=vericite \
-e LOG_ENVIRONMENT=production \
-e S3_ACCESSKEY=${aws_iam_access_key.registry.id} \
-e S3_SECRETKEY=${aws_iam_access_key.registry.secret} \
-e S3_REGION=${var.region} \
-e S3_BUCKET=${aws_s3_bucket.registry.bucket} \
-e S3_ROOTDIRECTORY=/registry \
-e LISTEN_ADDRESS=:5000 \
psev/s3registry
ExecStop=/usr/bin/docker rm registry
EOF",
"pacman --noconfirm -Syu",
"pacman --noconfirm -S lxc docker",
"systmectl enable docker",
"systmectl start docker registry"
]
}
tags {
Name = "registry"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment