docs: simplify Docker quickstart (#4257)

This commit is contained in:
Ammar Bandukwala 2022-09-29 17:55:15 -05:00 committed by GitHub
parent e49ef68ebc
commit 4b540b7c42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 124 deletions

4
.gitignore vendored
View File

@ -31,8 +31,8 @@ site/**/*.typegen.ts
site/build-storybook.log
# Build
build/
dist/
/build/
/dist/
site/out/
*.tfstate

View File

@ -0,0 +1 @@
DROP INDEX users_email_lower_idx;

View File

@ -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).

BIN
docs/images/quickstart/docker/create-workspace.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 906 KiB

After

Width:  |  Height:  |  Size: 729 KiB

View File

@ -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:
<img src="../images/quickstart/docker/create-workspace.png">
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!
<img src="../images/quickstart/docker/ides.png">
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)

View File

@ -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

View File

@ -0,0 +1,3 @@
FROM ubuntu
RUN apt-get update && apt-get install -y curl wget git vim golang

View File

@ -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",
<<EOT
trap '[ $? -ne 0 ] && echo === Agent script exited with non-zero code. Sleeping infinitely to preserve logs... && sleep infinity' EXIT
${replace(coder_agent.main.init_script, "localhost", "host.docker.internal")}
EOT
]
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
host {
host = "host.docker.internal"
@ -92,13 +97,3 @@ resource "docker_container" "workspace" {
read_only = false
}
}
resource "coder_metadata" "container_info" {
count = data.coder_workspace.me.start_count
resource_id = docker_container.workspace[0].id
item {
key = "image"
value = var.docker_image
}
}