Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 16 additions & 1 deletion examples/templates/docker/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
FROM ubuntu

RUN apt-get update && apt-get install -y curl wget git vim golang
RUN apt-get update \
&& apt-get install -y \
curl \
git \
golang \
sudo \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*

ARG USER=coder
RUN useradd --groups sudo --no-create-home ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}
USER ${USER}
WORKDIR /home/${USER}
11 changes: 9 additions & 2 deletions examples/templates/docker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ terraform {
}
}

locals {
username = data.coder_workspace.me.owner
}

data "coder_provisioner" "me" {
}

Expand Down Expand Up @@ -46,7 +50,7 @@ resource "coder_app" "code-server" {
agent_id = coder_agent.main.id
slug = "code-server"
display_name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
url = "http://localhost:13337/?folder=/home/${local.username}"
icon = "/icon/code.svg"
subdomain = false
share = "owner"
Expand Down Expand Up @@ -91,6 +95,9 @@ resource "docker_image" "main" {
name = "coder-${data.coder_workspace.me.id}"
build {
path = "./build"
build_arg = {
USER = local.username
}
}
triggers = {
dir_sha1 = sha1(join("", [for f in fileset(path.module, "build/*") : filesha1(f)]))
Expand All @@ -112,7 +119,7 @@ resource "docker_container" "workspace" {
ip = "host-gateway"
}
volumes {
container_path = "/home/coder/"
container_path = "/home/${local.username}"
volume_name = docker_volume.home_volume.name
read_only = false
}
Expand Down