Skip to content

Commit

Permalink
fix: example: update docker-local to use host-gateway (#1507)
Browse files Browse the repository at this point in the history
* fix: example: update docker-local to use host-gateway
* docker-compose.yaml: Add POSTGRES_ environment variables to CODER_PG_CONNECTION_URL

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
  • Loading branch information
johnstcn and mafredri committed May 17, 2022
1 parent fc9efc2 commit 75dc8f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ services:
ports:
- "7080:7080"
environment:
CODER_PG_CONNECTION_URL: "postgresql://username:password@database/coder?sslmode=disable"
CODER_PG_CONNECTION_URL: "postgresql://${POSTGRES_USER:-username}:${POSTGRES_PASSWORD:-password}@database/${POSTGRES_DB:-coder}?sslmode=disable"
CODER_ADDRESS: "0.0.0.0:7080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
database:
condition: service_healthy
Expand Down
8 changes: 8 additions & 0 deletions examples/docker-local/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ provider "docker" {
host = "unix:///var/run/docker.sock"
}

provider "coder" {
url = "http://host.docker.internal:7080"
}

data "coder_workspace" "me" {
}

Expand Down Expand Up @@ -43,6 +47,10 @@ resource "docker_container" "workspace" {
dns = ["1.1.1.1"]
command = ["sh", "-c", coder_agent.dev.init_script]
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
host {
host = "host.docker.internal"
ip = "host-gateway"
}
volumes {
container_path = "/home/coder/"
volume_name = docker_volume.coder_volume.name
Expand Down

0 comments on commit 75dc8f5

Please sign in to comment.