Skip to content

Commit

Permalink
example: docker: support Windows hosts (#1880)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpmct committed May 28, 2022
1 parent da7ed8b commit 7ad68ca
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
13 changes: 12 additions & 1 deletion examples/templates/docker-image-builds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,20 @@ variable "step2_arch" {
}
sensitive = true
}
variable "step3_OS" {
description = <<-EOF
What operating system is your Coder host on?
EOF

validation {
condition = contains(["MacOS", "Windows", "Linux"], var.step3_OS)
error_message = "Value must be MacOS, Windows, or Linux."
}
sensitive = true
}

provider "docker" {
host = "unix:///var/run/docker.sock"
host = var.step3_OS == "Windows" ? "npipe:////.//pipe//docker_engine" : "unix:///var/run/docker.sock"
}

provider "coder" {
Expand Down
16 changes: 13 additions & 3 deletions examples/templates/docker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ terraform {
# host on the "docker" provider below.
variable "step1_docker_host_warning" {
description = <<-EOF
Is Docker running on the Coder host?
This template will use the Docker socket present on
the Coder host, which is not necessarily your local machine.
Expand All @@ -45,10 +43,22 @@ variable "step2_arch" {
}
sensitive = true
}
variable "step3_OS" {
description = <<-EOF
What operating system is your Coder host on?
EOF

validation {
condition = contains(["MacOS", "Windows", "Linux"], var.step3_OS)
error_message = "Value must be MacOS, Windows, or Linux."
}
sensitive = true
}

provider "docker" {
host = "unix:///var/run/docker.sock"
host = var.step3_OS == "Windows" ? "npipe:////.//pipe//docker_engine" : "unix:///var/run/docker.sock"
}

provider "coder" {
}

Expand Down

0 comments on commit 7ad68ca

Please sign in to comment.