Updated TF Image

This commit is contained in:
2026-03-29 02:42:18 +00:00
parent 615d41206a
commit df31857258
4 changed files with 79 additions and 53 deletions
+19 -47
View File
@@ -32,57 +32,14 @@ resource "coder_agent" "main" {
os = "linux"
startup_script = <<-EOT
set -e
# 1. Standard Permissions Fix
sudo chown -R $(whoami) /home/coder
# 2. Install Docker CLI (client only) to talk to the socket
if ! command -v docker >/dev/null 2>&1; then
echo "Installing Docker CLI..."
curl -fsSL https://get.docker.com | sh
fi
# 3. Allow user to use the Docker socket (Docker-out-of-Docker)
# 1. Allow user to use the Docker socket (Docker-out-of-Docker)
# We set strict permissions on the socket file to ensure access
if [ -e /var/run/docker.sock ]; then
sudo chmod 666 /var/run/docker.sock
fi
# 4. Install Nixpacks
if ! command -v nixpacks >/dev/null 2>&1; then
echo "Installing Nixpacks..."
curl -sSL https://nixpacks.com/install.sh | bash
fi
# 5. Install Bun
if ! command -v bun >/dev/null 2>&1; then
echo "Installing Bun..."
curl -fsSL https://bun.sh/install | bash
fi
# 6. Update System Packages
echo "Updating system packages..."
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
# 7. Install Golang
if ! command -v go >/dev/null 2>&1; then
echo "Installing Golang..."
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y golang zip unzip
fi
# 8. Install SDKMAN! & Maven
if [ ! -d "$HOME/.sdkman" ]; then
echo "Installing SDKMAN!..."
export SDKMAN_DIR="$HOME/.sdkman"
curl -s "https://get.sdkman.io" | bash
echo "Installing Maven via SDKMAN!..."
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install maven
fi
# 9. Initialize Home Directory
# 2. Initialize Home Directory
if [ ! -f ~/.init_done ]; then
cp -rT /etc/skel ~
touch ~/.init_done
@@ -183,13 +140,28 @@ module "jetbrains" {
tooltip = "You need to [install JetBrains Toolbox](https://coder.com/docs/user-guides/workspace-access/jetbrains/toolbox) to use this app."
}
resource "docker_image" "workspace" {
name = "coder-${data.coder_workspace.me.id}"
build {
context = "."
dockerfile = "Dockerfile"
}
keep_locally = true
}
resource "docker_container" "workspace" {
count = data.coder_workspace.me.start_count
image = "codercom/enterprise-base:ubuntu"
image = docker_image.workspace.name
name = "coder-${data.coder_workspace_owner.me.name}-${lower(data.coder_workspace.me.name)}"
hostname = data.coder_workspace.me.name
entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")]
entrypoint = [
"sh", "-c",
<<EOT
sudo chown -R coder:coder /home/coder
${replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")}
EOT
]
gpus = "all"