10000 example: add docker-image-builds + docker docs by bpmct · Pull Request #1526 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

example: add docker-image-builds + docker docs #1526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into bpmct/add-docker-builds
  • Loading branch information
bpmct committed May 17, 2022
commit 36679ecde54d3fab097073d5af458d3c4f62c4f9
6 changes: 5 additions & 1 deletion cli/cliflag/cliflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ func StringVarP(flagset *pflag.FlagSet, p *string, name string, shorthand string
func StringArrayVarP(flagset *pflag.FlagSet, ptr *[]string, name string, shorthand string, env string, def []string, usage string) {
val, ok := os.LookupEnv(env)
if ok {
def = strings.Split(val, ",")
if val == "" {
def = []string{}
} else {
def = strings.Split(val, ",")
}
}
flagset.StringArrayVarP(ptr, name, shorthand, def, usage)
}
Expand Down
10 changes: 10 additions & 0 deletions cli/cliflag/cliflag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ func TestCliflag(t *testing.T) {
require.Equal(t, []string{"wow", "test"}, got)
})

t.Run("StringArrayEnvVarEmpty", func(t *testing.T) {
var ptr []string
flagset, name, shorthand, env, usage := randomFlag()
t.Setenv(env, "")
cliflag.StringArrayVarP(flagset, &ptr, name, shorthand, env, nil, usage)
got, err := flagset.GetStringArray(name)
require.NoError(t, err)
require.Equal(t, []string{}, got)
})

t.Run("IntDefault", func(t *testing.T) {
var ptr uint8
flagset, name, shorthand, env, usage := randomFlag()
Expand Down
2 changes: 1 addition & 1 deletion cli/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

var autostopPollInterval = 30 * time.Second
var autostopNotifyCountdown = []time.Duration{5 * time.Minute}
var autostopNotifyCountdown = []time.Duration{30 * time.Minute}

func ssh() *cobra.Command {
var (
Expand Down
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-image-builds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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 @@ -93,6 +97,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.home_volume.name
Expand Down
8 changes: 8 additions & 0 deletions examples/docker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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 @@ -86,6 +90,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.home_volume.name
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.
0