diff --git a/.gitignore b/.gitignore index c2fe98f2ef..2df3437236 100644 --- a/.gitignore +++ b/.gitignore @@ -31,8 +31,8 @@ site/**/*.typegen.ts site/build-storybook.log # Build -build/ -dist/ +/build/ +/dist/ site/out/ *.tfstate diff --git a/coderd/database/migrations/000054_email_case.down.sql b/coderd/database/migrations/000054_email_case.down.sql index e69de29bb2..d5490c4ea4 100644 --- a/coderd/database/migrations/000054_email_case.down.sql +++ b/coderd/database/migrations/000054_email_case.down.sql @@ -0,0 +1 @@ +DROP INDEX users_email_lower_idx; diff --git a/docs/admin/audit-logs.md b/docs/admin/audit-logs.md index 3dab005701..c19083039d 100644 --- a/docs/admin/audit-logs.md +++ b/docs/admin/audit-logs.md @@ -1,10 +1,11 @@ # Audit Logs -This is an enterprise feature that allows **Admins** and **Auditors** to monitor what is happening in their deployment. +Audit Logs allows **Admins** and **Auditors** to monitor user operations in +their deployment. ## Tracked Events -This feature tracks **create, update and delete** events for the following resources: +We track **create, update and delete** events for the following resources: - GitSSHKey - Template @@ -31,4 +32,4 @@ The supported filters are: ## Enabling this feature -This feature is autoenabled for all enterprise deployments. An Admin can contact us to purchase a license [here](https://coder.com/contact?note=I%20want%20to%20upgrade%20my%20license). +This feature is autoenabled for all enterprise deployments. Admins may contact us to purchase a license [here](https://coder.com/contact?note=I%20want%20to%20upgrade%20my%20license). diff --git a/docs/images/quickstart/docker/create-workspace.png b/docs/images/quickstart/docker/create-workspace.png old mode 100755 new mode 100644 index 04f1232539..1c8d7cb5c2 Binary files a/docs/images/quickstart/docker/create-workspace.png and b/docs/images/quickstart/docker/create-workspace.png differ diff --git a/docs/quickstart/docker.md b/docs/quickstart/docker.md index c9d659ce93..9eee190e24 100644 --- a/docs/quickstart/docker.md +++ b/docs/quickstart/docker.md @@ -15,54 +15,29 @@ Coder with Docker has the following advantages: 1. [Install and launch Coder](../install) - You will specify `CODER_ACCESS_URL=http://localhost:7080` since we're using - local Docker workspaces exclusively. `CODER_ACCESS_URL` is the external URL - to access Coder. The rest of the Docker quickstart guide will assume that - this is your Access URL. - - You will also specify `CODER_ADDRESS=0.0.0.0:7080` which is the address to - serve the API and dashboard. + Next, we export the `CODER_ADDRESS` and `CODER_ACCESS_URL` environment + variables. We can use localhost for the Access URL since the workspaces + all run on the same machine. `CODER_ADDRESS` is where coder server binds + while `CODER_ACCESS_URL` is where it's accessed. We use `:7080` to bind + to all interfaces. ```bash - coder server --address $CODER_ADDRESS --access-url $CODER_ACCESS_URL + $ export CODER_ADDRESS=:7080 + $ export CODER_ACCESS_URL=http://localhost:7080 + $ coder server --address $CODER_ADDRESS --access-url $CODER_ACCESS_URL ``` 1. Run `coder login http://localhost:7080` in a new terminal and follow the interactive instructions to create your user. -1. Pull the example template: +1. Pull the "Docker" example template using the interactive `coder templates init`: ```bash - echo "docker" | coder templates init - cd docker - # You should see a `main.tf` file in this directory + $ coder templates init + $ cd docker ``` -1. Open up `main.tf` in your preferred editor to edit the images - - You can skip this step if you're fine with our default, generic OS images. - - Search for the following section in `main.tf`: - - ```hcl - ... - variable "docker_image" { - description = "Which Docker image would you like to use for your workspace?" - # The codercom/enterprise-* images are only built for amd64 - default = "codercom/enterprise-base:ubuntu" - validation { - condition = contains(["codercom/enterprise-base:ubuntu", "codercom/enterprise-node:ubuntu", - "codercom/enterprise-intellij:ubuntu", "codercom/enterprise-golang:ubuntu"], var.docker_image) - error_message = "Invalid Docker image!" - } - } - ... - ``` - - And edit the strings in `condition = contains([...])` and `default = ...` - with your preferred images. - -1. Push up the template to Coder with `coder templates create` +1. Push up the template with `coder templates create` 1. Open the dashboard in your browser (http://localhost:7080) to create your first workspace: @@ -72,16 +47,20 @@ Coder with Docker has the following advantages: - Now wait a few moments for the workspace to build... After the first build + Now wait a few moments for the workspace to build... After the first build, the image is cached and subsequent builds will take a few seconds. -1. All done! +1. Your workspace is ready to go! Open up a web application or [SSH in](../ides.md#ssh-configuration). +1. If you want to modify the Docker image or template, edit the files in the + previously created `./docker` directory, then run `coder templates push`. + ## Next Steps +- [Port-forward](../networking/port-forwarding.md.md) - [Learn more about template configuration](../templates.md) - [Configure more IDEs](../ides/web-ides.md) diff --git a/examples/templates/docker/README.md b/examples/templates/docker/README.md index f1a5e3c848..850007f424 100644 --- a/examples/templates/docker/README.md +++ b/examples/templates/docker/README.md @@ -9,39 +9,9 @@ tags: [local, docker] To get started, run `coder templates init`. When prompted, select this template. Follow the on-screen instructions to proceed. -## Adding/removing images +## Editing the image -After building and pushing an image to an image registry (e.g., DockerHub), edit -the template to make the image available to users: - -```sh -# Open the template -vim main.tf -``` - -Modify your file to match the following: - -```diff -variable "docker_image" { - description = "What Docker image would you like to use for your workspace?" - default = "codercom/enterprise-base:ubuntu" - validation { - condition = contains(["codercom/enterprise-base:ubuntu", "codercom/enterprise-node:ubuntu", -- "codercom/enterprise-intellij:ubuntu"], var.docker_image) -+ "codercom/enterprise-intellij:ubuntu", "codercom/enterprise-golang:ubuntu"], var.docker_image) - error_message = "Invalid Docker image!" - } -} -``` - -Update the template: - -```sh -coder template push docker -``` - -You can also remove images from the validation list. Workspaces using older template versions will continue using -the removed image until you update the workspace to the latest version. +Edit the `Dockerfile` and run `coder templates push` to update workspaces. ## code-server @@ -49,30 +19,6 @@ the removed image until you update the workspace to the latest version. resource block. The `coder_app` resource is defined to access `code-server` through the dashboard UI over `localhost:13337`. -## Updating images - -To reduce drift, we recommend versioning images in your registry by creating tags. To update the image tag in the template: - -```sh -variable "docker_image" { - description = "What Docker image would you like to use for your workspace?" - default = "codercom/enterprise-base:ubuntu" - validation { -- condition = contains(["my-org/base-development:v1.1", "myorg-java-development:v1.1"], var.docker_image) -+ condition = contains(["my-org/base-development:v1.1", "myorg-java-development:v1.2"], var.docker_image) - - error_message = "Invalid Docker image!" - } -} -``` - -Optional: Update workspaces to the latest template version: - -```sh -coder ls -coder update [workspace name] -``` - ## Extending this template See the [kreuzwerker/docker](https://registry.terraform.io/providers/kreuzwerker/docker) Terraform provider documentation to diff --git a/examples/templates/docker/build/Dockerfile b/examples/templates/docker/build/Dockerfile new file mode 100644 index 0000000000..fc429d5a2b --- /dev/null +++ b/examples/templates/docker/build/Dockerfile @@ -0,0 +1,3 @@ +FROM ubuntu + +RUN apt-get update && apt-get install -y curl wget git vim golang diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index 36ce85da7f..bace09af9b 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -6,7 +6,7 @@ terraform { } docker = { source = "kreuzwerker/docker" - version = "~> 2.20.2" + version = "~> 2.22" } } } @@ -55,24 +55,24 @@ resource "coder_app" "code-server" { } -variable "docker_image" { - description = "Which Docker image would you like to use for your workspace?" - # The codercom/enterprise-* images are only built for amd64 - default = "codercom/enterprise-base:ubuntu" - validation { - condition = contains(["codercom/enterprise-base:ubuntu", "codercom/enterprise-node:ubuntu", - "codercom/enterprise-intellij:ubuntu", "codercom/enterprise-golang:ubuntu"], var.docker_image) - error_message = "Invalid Docker image!" - } -} - resource "docker_volume" "home_volume" { name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}-home" } + +resource "docker_image" "main" { + name = "coder-${data.coder_workspace.me.id}" + build { + path = "./build" + } + triggers = { + dir_sha1 = sha1(join("", [for f in fileset(path.module, "build/*") : filesha1(f)])) + } +} + resource "docker_container" "workspace" { count = data.coder_workspace.me.start_count - image = var.docker_image + image = docker_image.main.name # Uses lower() to avoid Docker restriction on container names. name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}" # Hostname makes the shell more user friendly: coder@my-workspace:~$ @@ -80,7 +80,12 @@ resource "docker_container" "workspace" { dns = ["1.1.1.1"] # Use the docker gateway if the access URL is 127.0.0.1 command = [ - "sh", "-c", replace(coder_agent.main.init_script, "localhost", "host.docker.internal")] + "sh", "-c", + <