Skip to content

Instantly share code, notes, and snippets.

@IlyaSemenov
Created June 27, 2017 03:13
Show Gist options
  • Save IlyaSemenov/dffde5535a752405232e2f03e3aecb0c to your computer and use it in GitHub Desktop.
Save IlyaSemenov/dffde5535a752405232e2f03e3aecb0c to your computer and use it in GitHub Desktop.
resource "docker_container" "nginx_proxy" {
image = "${docker_image.nginx_proxy.latest}"
name = "nginx_proxy"
restart = "unless-stopped"
ports {
internal = 80
external = 80
}
ports {
internal = 443
external = 443
}
volumes {
host_path = "/var/run/docker.sock"
container_path = "/tmp/docker.sock"
read_only = true
}
volumes {
host_path = "/srv/nginx_proxy/certs"
container_path = "/etc/nginx/certs"
read_only = true
}
volumes {
volume_name = "${docker_volume.nginx_proxy_vhosts.name}"
container_path = "/etc/nginx/vhost.d"
}
volumes {
volume_name = "${docker_volume.nginx_proxy_html.name}"
container_path = "/usr/share/nginx/html"
}
labels {
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy = "true"
}
}
resource "docker_container" "nginx_proxy_le" {
image = "${docker_image.nginx_proxy_le.latest}"
name = "nginx_proxy_le"
restart = "unless-stopped"
volumes {
host_path = "/var/run/docker.sock"
container_path = "/var/run/docker.sock"
read_only = true
}
volumes {
host_path = "/srv/nginx_proxy/certs"
container_path = "/etc/nginx/certs"
}
volumes {
from_container = "${docker_container.nginx_proxy.name}"
}
}
resource "docker_image" "nginx_proxy" {
name = "jwilder/nginx-proxy:alpine"
}
resource "docker_image" "nginx_proxy_le" {
name = "jrcs/letsencrypt-nginx-proxy-companion"
}
resource "docker_volume" "nginx_proxy_vhosts" {
name = "nginx_proxy_vhosts"
}
resource "docker_volume" "nginx_proxy_html" {
name = "nginx_proxy_html"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment