Coder on fly.io
Hello, I'm trying to setup coder on fly.io with tailscale/caddy/magicdns. I have the control plane setup and running fine(?). I have created what seems like a reasonable template and a docker image for the workstations but I'm not able to get a workstation connected to the control plane. I'm trying to use docker locally and have started the "workstation" in the control plane. I have the agent key and am following all the instructions I can find but I continue to get a 401 attempting to attach an workspace / agent on startup. Is what I'm trying to do reasonable? I feel like I'm missing something on the provision step. It sort of seems like the console plane workspace creation might not be completing as I am not able to open the "build timeline" and the pulsing spinner on the right side continues indefinitely. Thank you everyone in advance.
3 Replies
<#1423909195178053712>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
terraform {
required_providers {
coder = {
source = "coder/coder"
version = ">= 0.14.0"
}
}
}
data "coder_workspace" "me" {}
# Your agent (the process in your image will start code-server on port 13337)
resource "coder_agent" "worker" {
os = "linux"
arch = "amd64"
# (optional) you can add startup_script etc. here, but you're starting
# code-server inside the container already (boot.sh), so no need.
}
output "CODER_AGENT_TOKEN" {
value = coder_agent.worker.token
sensitive = true
}
# Web IDE tile: code-server at 13337
resource "coder_app" "code" {
agent_id = coder_agent.worker.id
slug = "code"
display_name = "VS Code (Web)"
icon = "/icon/code.svg"
url = "http://localhost:13337/?folder=/home/coder/workspace"
subdomain = false
# Optional healthcheck (code-server provides /healthz)
healthcheck {
url = "http://localhost:13337/healthz"
interval = 2
threshold = 10
}
}
# VS Code Desktop tile via official module
module "vscode_desktop" {
source = "registry.coder.com/modules/vscode-desktop/coder"
# pin a version from the registry; example:
# version = "1.0.14"
agent_id = coder_agent.worker.id
}
# Cursor Desktop tile via official module
module "cursor" {
source = "registry.coder.com/modules/cursor/coder"
# version = "1.0.x" # pin an appropriate version
agent_id = coder_agent.worker.id
}
terraform {
required_providers {
coder = {
source = "coder/coder"
version = ">= 0.14.0"
}
}
}
data "coder_workspace" "me" {}
# Your agent (the process in your image will start code-server on port 13337)
resource "coder_agent" "worker" {
os = "linux"
arch = "amd64"
# (optional) you can add startup_script etc. here, but you're starting
# code-server inside the container already (boot.sh), so no need.
}
output "CODER_AGENT_TOKEN" {
value = coder_agent.worker.token
sensitive = true
}
# Web IDE tile: code-server at 13337
resource "coder_app" "code" {
agent_id = coder_agent.worker.id
slug = "code"
display_name = "VS Code (Web)"
icon = "/icon/code.svg"
url = "http://localhost:13337/?folder=/home/coder/workspace"
subdomain = false
# Optional healthcheck (code-server provides /healthz)
healthcheck {
url = "http://localhost:13337/healthz"
interval = 2
threshold = 10
}
}
# VS Code Desktop tile via official module
module "vscode_desktop" {
source = "registry.coder.com/modules/vscode-desktop/coder"
# pin a version from the registry; example:
# version = "1.0.14"
agent_id = coder_agent.worker.id
}
# Cursor Desktop tile via official module
module "cursor" {
source = "registry.coder.com/modules/cursor/coder"
# version = "1.0.x" # pin an appropriate version
agent_id = coder_agent.worker.id
}
# Use Coder's enterprise Node.js base image
FROM codercom/enterprise-node
# Set Volta path for Node toolchains
ENV VOLTA_HOME=/home/coder/.volta \
PATH=/home/coder/.volta/bin:/home/coder/.local/bin:$PATH
# Install additional tools as root
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
xz-utils unzip jq \
build-essential pkg-config \
python3 python3-pip \
postgresql-client sqlite3 redis-tools \
&& rm -rf /var/lib/apt/lists/*
# Switch to coder user
USER coder
WORKDIR /home/coder
# Install Node 20 via Volta + enable Corepack (pnpm/yarn)
RUN curl -fsSL https://get.volta.sh | bash \
&& volta install node@20 \
&& corepack enable \
&& corepack prepare pnpm@latest --activate \
&& corepack prepare yarn@stable --activate
# Prewarm some global CLIs used in Lovable/v0 style stacks
RUN npm -g i prisma vercel wrangler
# Install Supabase CLI locally (doesn't support global install)
RUN npm install supabase
# Install code-server (browser IDE)
RUN curl -fsSL https://code-server.dev/install.sh | sh
# Install Coder CLI/agent
RUN curl -fsSL https://coder.com/install.sh | sh
# Add Tailscale binaries
USER root
COPY --from=docker.io/tailscale/tailscale:stable /usr/local/bin/tailscaled /usr/local/bin/tailscaled
COPY --from=docker.io/tailscale/tailscale:stable /usr/local/bin/tailscale /usr/local/bin/tailscale
RUN mkdir -p /var/run/tailscale /var/lib/tailscale && chown -R coder:coder /var/lib/tailscale /var/run/tailscale
# Switch back to coder user
USER coder
# Install VS Code extensions (minimal set)
RUN code-server --install-extension dbaeumer.vscode-eslint || true
# Install tini for proper signal handling
USER root
RUN apt-get update && apt-get install -y tini && rm -rf /var/lib/apt/lists/*
# Copy in start script
COPY start.sh /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh
USER coder
EXPOSE 13337
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/start.sh"]
# Use Coder's enterprise Node.js base image
FROM codercom/enterprise-node
# Set Volta path for Node toolchains
ENV VOLTA_HOME=/home/coder/.volta \
PATH=/home/coder/.volta/bin:/home/coder/.local/bin:$PATH
# Install additional tools as root
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
xz-utils unzip jq \
build-essential pkg-config \
python3 python3-pip \
postgresql-client sqlite3 redis-tools \
&& rm -rf /var/lib/apt/lists/*
# Switch to coder user
USER coder
WORKDIR /home/coder
# Install Node 20 via Volta + enable Corepack (pnpm/yarn)
RUN curl -fsSL https://get.volta.sh | bash \
&& volta install node@20 \
&& corepack enable \
&& corepack prepare pnpm@latest --activate \
&& corepack prepare yarn@stable --activate
# Prewarm some global CLIs used in Lovable/v0 style stacks
RUN npm -g i prisma vercel wrangler
# Install Supabase CLI locally (doesn't support global install)
RUN npm install supabase
# Install code-server (browser IDE)
RUN curl -fsSL https://code-server.dev/install.sh | sh
# Install Coder CLI/agent
RUN curl -fsSL https://coder.com/install.sh | sh
# Add Tailscale binaries
USER root
COPY --from=docker.io/tailscale/tailscale:stable /usr/local/bin/tailscaled /usr/local/bin/tailscaled
COPY --from=docker.io/tailscale/tailscale:stable /usr/local/bin/tailscale /usr/local/bin/tailscale
RUN mkdir -p /var/run/tailscale /var/lib/tailscale && chown -R coder:coder /var/lib/tailscale /var/run/tailscale
# Switch back to coder user
USER coder
# Install VS Code extensions (minimal set)
RUN code-server --install-extension dbaeumer.vscode-eslint || true
# Install tini for proper signal handling
USER root
RUN apt-get update && apt-get install -y tini && rm -rf /var/lib/apt/lists/*
# Copy in start script
COPY start.sh /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh
USER coder
EXPOSE 13337
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/start.sh"]
#!/usr/bin/env bash
set -euo pipefail
log(){ echo "[$(date --iso-8601=seconds)] $*"; }
# Start Coder agent
if [[ -n "${CODER_URL:-}" && -n "${CODER_AGENT_TOKEN:-}" ]]; then
log "Starting Coder agent..."
mkdir -p /home/coder/workspace
cd /home/coder/workspace
CODER_AGENT_AUTH="token" CODER_AGENT_TOKEN="${CODER_AGENT_TOKEN}" CODER_AGENT_URL="${CODER_URL}" \
coder agent &
else
log "CODER_URL or CODER_AGENT_TOKEN missing; agent will not start."
fi
# Start code-server (foreground)
WORKDIR="/home/coder/workspace"
mkdir -p "${WORKDIR}"
AUTH_MODE="${CODE_SERVER_AUTH:-none}"
CS_ARGS=( "--bind-addr" "127.0.0.1:13337" "--disable-telemetry" "--auth" "${AUTH_MODE}" )
if [[ "${AUTH_MODE}" = "password" ]]; then
: "${CODE_SERVER_PASSWORD:?}"
export PASSWORD="${CODE_SERVER_PASSWORD}"
fi
log "Starting code-server on 127.0.0.1:13337 (auth=${AUTH_MODE}) in ${WORKDIR}"
cd "${WORKDIR}"
exec code-server "${CS_ARGS[@]}"
#!/usr/bin/env bash
set -euo pipefail
log(){ echo "[$(date --iso-8601=seconds)] $*"; }
# Start Coder agent
if [[ -n "${CODER_URL:-}" && -n "${CODER_AGENT_TOKEN:-}" ]]; then
log "Starting Coder agent..."
mkdir -p /home/coder/workspace
cd /home/coder/workspace
CODER_AGENT_AUTH="token" CODER_AGENT_TOKEN="${CODER_AGENT_TOKEN}" CODER_AGENT_URL="${CODER_URL}" \
coder agent &
else
log "CODER_URL or CODER_AGENT_TOKEN missing; agent will not start."
fi
# Start code-server (foreground)
WORKDIR="/home/coder/workspace"
mkdir -p "${WORKDIR}"
AUTH_MODE="${CODE_SERVER_AUTH:-none}"
CS_ARGS=( "--bind-addr" "127.0.0.1:13337" "--disable-telemetry" "--auth" "${AUTH_MODE}" )
if [[ "${AUTH_MODE}" = "password" ]]; then
: "${CODE_SERVER_PASSWORD:?}"
export PASSWORD="${CODE_SERVER_PASSWORD}"
fi
log "Starting code-server on 127.0.0.1:13337 (auth=${AUTH_MODE}) in ${WORKDIR}"
cd "${WORKDIR}"
exec code-server "${CS_ARGS[@]}"