diff --git a/.gitignore b/.gitignore index 2ccd459b811b9..b358925145984 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # Common ignore patterns, these rules applies in both root and subdirectories. .DS_Store .eslintcache -.gitpod.yml +# .gitpod.yml .idea **/*.swp gotests.coverage diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000000000..fa950cb3d86bc --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,5 @@ +tasks: + - init: pnpm install && go get && go build ./... && go test ./... && make + command: go run . && curl -L https://coder.com/install.sh | sh && coder login https://qg18kc97m47je.pit-1.try.coder.app +# I will make this fully automated sooner let me study the coder codebase first + diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000000000..052be54cd4fe7 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,35 @@ +--- +name: Develop in Docker +description: Develop inside Docker containers using your local daemon +tags: [local, docker] +icon: /icon/docker.png +--- + +# docker + +To get started, run `coder templates init`. When prompted, select this template. +Follow the on-screen instructions to proceed. + +## Editing the image + +Edit the `Dockerfile` and run `coder templates push` to update workspaces. + +## code-server + +`code-server` is installed via the `startup_script` argument in the `coder_agent` +resource block. The `coder_app` resource is defined to access `code-server` through +the dashboard UI over `localhost:13337`. + +## Extending this template + +See the [kreuzwerker/docker](https://registry.terraform.io/providers/kreuzwerker/docker) Terraform provider documentation to +add the following features to your Coder template: + +- SSH/TCP docker host +- Registry authentication +- Build args +- Volume mounts +- Custom container spec +- More + +We also welcome contributions! diff --git a/docker/main.tf b/docker/main.tf new file mode 100644 index 0000000000000..b4ec8c405707f --- /dev/null +++ b/docker/main.tf @@ -0,0 +1,207 @@ +terraform { + required_providers { + coder = { + source = "coder/coder" + } + docker = { + source = "kreuzwerker/docker" + } + } +} + +locals { + username = data.coder_workspace.me.owner +} + +data "coder_provisioner" "me" { +} + +provider "docker" { +} + +data "coder_workspace" "me" { +} + +resource "coder_agent" "main" { + arch = data.coder_provisioner.me.arch + os = "linux" + startup_script_timeout = 180 + startup_script = <<-EOT + set -e + + # install and start code-server + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.11.0 + /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & + EOT + + # These environment variables allow you to make Git commits right away after creating a + # workspace. Note that they take precedence over configuration defined in ~/.gitconfig! + # You can remove this block if you'd prefer to configure Git manually or using + # dotfiles. (see docs/dotfiles.md) + env = { + GIT_AUTHOR_NAME = "${data.coder_workspace.me.owner}" + GIT_COMMITTER_NAME = "${data.coder_workspace.me.owner}" + GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}" + GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}" + } + + # The following metadata blocks are optional. They are used to display + # information about your workspace in the dashboard. You can remove them + # if you don't want to display any information. + # For basic resources, you can use the `coder stat` command. + # If you need more control, you can write your own script. + metadata { + display_name = "CPU Usage" + key = "0_cpu_usage" + script = "coder stat cpu" + interval = 10 + timeout = 1 + } + + metadata { + display_name = "RAM Usage" + key = "1_ram_usage" + script = "coder stat mem" + interval = 10 + timeout = 1 + } + + metadata { + display_name = "Home Disk" + key = "3_home_disk" + script = "coder stat disk --path $${HOME}" + interval = 60 + timeout = 1 + } + + metadata { + display_name = "CPU Usage (Host)" + key = "4_cpu_usage_host" + script = "coder stat cpu --host" + interval = 10 + timeout = 1 + } + + metadata { + display_name = "Memory Usage (Host)" + key = "5_mem_usage_host" + script = "coder stat mem --host" + interval = 10 + timeout = 1 + } + + metadata { + display_name = "Load Average (Host)" + key = "6_load_host" + # get load avg scaled by number of cores + script = <