|
| 1 | +# docker-compose.dev.yml — Development environment |
| 2 | +services: |
| 3 | + database: |
| 4 | + labels: |
| 5 | + - "com.coder.dev" |
| 6 | + networks: |
| 7 | + - coder-dev |
| 8 | + image: postgres:17 |
| 9 | + environment: |
| 10 | + POSTGRES_USER: coder |
| 11 | + POSTGRES_PASSWORD: coder |
| 12 | + POSTGRES_DB: coder |
| 13 | + ports: |
| 14 | + - "5432:5432" |
| 15 | + volumes: |
| 16 | + - coder_dev_data:/var/lib/postgresql/data |
| 17 | + healthcheck: |
| 18 | + test: ["CMD-SHELL", "pg_isready -U coder"] |
| 19 | + interval: 2s |
| 20 | + timeout: 5s |
| 21 | + retries: 10 |
| 22 | + |
| 23 | + # Ensure named volumes are owned by the coder user (uid 1000) |
| 24 | + # since Docker creates them as root by default. |
| 25 | + init-volumes: |
| 26 | + labels: |
| 27 | + - "com.coder.dev" |
| 28 | + image: codercom/oss-dogfood:latest |
| 29 | + user: "0:0" |
| 30 | + volumes: |
| 31 | + - go_cache:/go-cache |
| 32 | + - coder_cache:/cache |
| 33 | + - bootstrap_token:/bootstrap |
| 34 | + - site_node_modules:/app/site/node_modules |
| 35 | + command: > |
| 36 | + chown -R 1000:1000 |
| 37 | + /go-cache |
| 38 | + /cache |
| 39 | + /bootstrap |
| 40 | + /app/site/node_modules |
| 41 | +
|
| 42 | + build-slim: |
| 43 | + labels: |
| 44 | + - "com.coder.dev" |
| 45 | + network_mode: "host" |
| 46 | + image: codercom/oss-dogfood:latest |
| 47 | + depends_on: |
| 48 | + init-volumes: |
| 49 | + condition: service_completed_successfully |
| 50 | + database: |
| 51 | + condition: service_healthy |
| 52 | + working_dir: /app |
| 53 | + # Add the Docker group so coderd can access the Docker socket. |
| 54 | + # If your Docker group is not 999, the below should work: |
| 55 | + # export DOCKER_GROUP=$(getent group docker | cut -d: -f3) |
| 56 | + group_add: |
| 57 | + - "${DOCKER_GROUP:-999}" |
| 58 | + environment: |
| 59 | + GOMODCACHE: /go-cache/mod |
| 60 | + GOCACHE: /go-cache/build |
| 61 | + DOCKER_HOST: "${CODER_DEV_DOCKER_HOST:-unix:///var/run/docker.sock}" |
| 62 | + volumes: |
| 63 | + - .:/app |
| 64 | + - go_cache:/go-cache |
| 65 | + - coder_cache:/cache |
| 66 | + - "${DOCKER_SOCKET:-/var/run/docker.sock}:/var/run/docker.sock" |
| 67 | + command: > |
| 68 | + sh -c ' |
| 69 | + if [ "${CODER_BUILD_AGPL:-0}" = "1" ]; then |
| 70 | + make -j build-slim CODER_BUILD_AGPL=1 |
| 71 | + else |
| 72 | + make -j build-slim |
| 73 | + fi && |
| 74 | + mkdir -p /cache/site/orig/bin && |
| 75 | + cp site/out/bin/coder-* /cache/site/orig/bin/ |
| 76 | + ' |
| 77 | +
|
| 78 | + coderd: |
| 79 | + labels: |
| 80 | + - "com.coder.dev" |
| 81 | + networks: |
| 82 | + - coder-dev |
| 83 | + image: codercom/oss-dogfood:latest |
| 84 | + depends_on: |
| 85 | + database: |
| 86 | + condition: service_healthy |
| 87 | + build-slim: |
| 88 | + condition: service_completed_successfully |
| 89 | + environment: |
| 90 | + CODER_PG_CONNECTION_URL: "postgresql://coder:coder@database:5432/coder?sslmode=disable" |
| 91 | + CODER_HTTP_ADDRESS: "0.0.0.0:3000" |
| 92 | + CODER_ACCESS_URL: "${CODER_DEV_ACCESS_URL:-http://localhost:3000}" |
| 93 | + CODER_DEV_ADMIN_PASSWORD: "${CODER_DEV_ADMIN_PASSWORD:-SomeSecurePassword!}" |
| 94 | + CODER_SWAGGER_ENABLE: "true" |
| 95 | + CODER_DANGEROUS_ALLOW_CORS_REQUESTS: "true" |
| 96 | + CODER_TELEMETRY_ENABLE: "false" |
| 97 | + GOMODCACHE: /go-cache/mod |
| 98 | + GOCACHE: /go-cache/build |
| 99 | + CODER_CACHE_DIRECTORY: /cache |
| 100 | + DOCKER_HOST: "${CODER_DEV_DOCKER_HOST:-unix:///var/run/docker.sock}" |
| 101 | + # Add the Docker group so coderd can access the Docker socket. |
| 102 | + # Override DOCKER_GROUP if your host's docker group is not 999. |
| 103 | + group_add: |
| 104 | + - "${DOCKER_GROUP:-999}" |
| 105 | + ports: |
| 106 | + - "3000:3000" |
| 107 | + healthcheck: |
| 108 | + test: ["CMD-SHELL", "curl -sf http://localhost:3000/healthz || exit 1"] |
| 109 | + interval: 5s |
| 110 | + timeout: 5s |
| 111 | + retries: 30 |
| 112 | + start_period: 120s |
| 113 | + working_dir: /app |
| 114 | + volumes: |
| 115 | + - .:/app |
| 116 | + - go_cache:/go-cache |
| 117 | + - coder_cache:/cache |
| 118 | + - "${DOCKER_SOCKET:-/var/run/docker.sock}:/var/run/docker.sock" |
| 119 | + command: > |
| 120 | + sh -c ' |
| 121 | + CMD_PATH="./enterprise/cmd/coder" |
| 122 | + [ "${CODER_BUILD_AGPL:-0}" = "1" ] && CMD_PATH="./cmd/coder" |
| 123 | + exec go run "$$CMD_PATH" server \ |
| 124 | + --http-address 0.0.0.0:3000 \ |
| 125 | + --access-url "${CODER_DEV_ACCESS_URL:-http://localhost:3000}" \ |
| 126 | + --swagger-enable \ |
| 127 | + --dangerous-allow-cors-requests=true \ |
| 128 | + --enable-terraform-debug-mode |
| 129 | + ' |
| 130 | +
|
| 131 | + setup-init: |
| 132 | + labels: |
| 133 | + - "com.coder.dev" |
| 134 | + networks: |
| 135 | + - coder-dev |
| 136 | + image: codercom/oss-dogfood:latest |
| 137 | + depends_on: |
| 138 | + coderd: |
| 139 | + condition: service_healthy |
| 140 | + working_dir: /app |
| 141 | + environment: |
| 142 | + CODER_URL: "http://coderd:3000" |
| 143 | + CODER_DEV_ADMIN_PASSWORD: "${CODER_DEV_ADMIN_PASSWORD:-SomeSecurePassword!}" |
| 144 | + GOMODCACHE: /go-cache/mod |
| 145 | + GOCACHE: /go-cache/build |
| 146 | + volumes: |
| 147 | + - .:/app |
| 148 | + - go_cache:/go-cache |
| 149 | + - bootstrap_token:/bootstrap |
| 150 | + - ./scripts/docker-dev:/scripts:ro |
| 151 | + command: ["sh", "/scripts/setup-init.sh"] |
| 152 | + |
| 153 | + setup-users: |
| 154 | + labels: |
| 155 | + - "com.coder.dev" |
| 156 | + networks: |
| 157 | + - coder-dev |
| 158 | + image: codercom/oss-dogfood:latest |
| 159 | + depends_on: |
| 160 | + setup-init: |
| 161 | + condition: service_completed_successfully |
| 162 | + working_dir: /app |
| 163 | + environment: |
| 164 | + CODER_URL: "http://coderd:3000" |
| 165 | + CODER_DEV_MEMBER_PASSWORD: "${CODER_DEV_MEMBER_PASSWORD:-SomeSecurePassword!}" |
| 166 | + GOMODCACHE: /go-cache/mod |
| 167 | + GOCACHE: /go-cache/build |
| 168 | + volumes: |
| 169 | + - .:/app |
| 170 | + - go_cache:/go-cache |
| 171 | + - bootstrap_token:/bootstrap:ro |
| 172 | + - ./scripts/docker-dev:/scripts:ro |
| 173 | + command: ["sh", "/scripts/setup-users.sh"] |
| 174 | + |
| 175 | + setup-template: |
| 176 | + labels: |
| 177 | + - "com.coder.dev" |
| 178 | + networks: |
| 179 | + - coder-dev |
| 180 | + image: codercom/oss-dogfood:latest |
| 181 | + depends_on: |
| 182 | + setup-init: |
| 183 | + condition: service_completed_successfully |
| 184 | + working_dir: /app |
| 185 | + environment: |
| 186 | + CODER_URL: "http://coderd:3000" |
| 187 | + DOCKER_HOST: "${CODER_DEV_DOCKER_HOST:-unix:///var/run/docker.sock}" |
| 188 | + GOMODCACHE: /go-cache/mod |
| 189 | + GOCACHE: /go-cache/build |
| 190 | + volumes: |
| 191 | + - .:/app |
| 192 | + - go_cache:/go-cache |
| 193 | + - bootstrap_token:/bootstrap:ro |
| 194 | + - ./scripts/docker-dev:/scripts:ro |
| 195 | + - "${DOCKER_SOCKET:-/var/run/docker.sock}:/var/run/docker.sock" |
| 196 | + command: ["sh", "/scripts/setup-template.sh"] |
| 197 | + |
| 198 | + site: |
| 199 | + labels: |
| 200 | + - "com.coder.dev" |
| 201 | + networks: |
| 202 | + - coder-dev |
| 203 | + image: codercom/oss-dogfood:latest |
| 204 | + depends_on: |
| 205 | + setup-template: |
| 206 | + condition: service_completed_successfully |
| 207 | + working_dir: /app/site |
| 208 | + environment: |
| 209 | + CODER_HOST: "http://coderd:3000" |
| 210 | + ports: |
| 211 | + - "8080:8080" |
| 212 | + volumes: |
| 213 | + - ./site:/app/site |
| 214 | + - site_node_modules:/app/site/node_modules |
| 215 | + command: sh -c "pnpm install --frozen-lockfile && pnpm dev --host" |
| 216 | + |
| 217 | + wsproxy: |
| 218 | + profiles: ["proxy"] |
| 219 | + labels: |
| 220 | + - "com.coder.dev" |
| 221 | + networks: |
| 222 | + - coder-dev |
| 223 | + image: codercom/oss-dogfood:latest |
| 224 | + depends_on: |
| 225 | + setup-init: |
| 226 | + condition: service_completed_successfully |
| 227 | + working_dir: /app |
| 228 | + environment: |
| 229 | + CODER_URL: "http://coderd:3000" |
| 230 | + GOMODCACHE: /go-cache/mod |
| 231 | + GOCACHE: /go-cache/build |
| 232 | + volumes: |
| 233 | + - .:/app |
| 234 | + - go_cache:/go-cache |
| 235 | + - bootstrap_token:/bootstrap:ro |
| 236 | + ports: |
| 237 | + - "3010:3010" |
| 238 | + command: > |
| 239 | + sh -c ' |
| 240 | + export CODER_SESSION_TOKEN=$$(cat /bootstrap/token) && |
| 241 | + go run ./cmd/coder wsproxy delete local-proxy --yes 2>/dev/null || true |
| 242 | + PROXY_TOKEN=$$(go run ./cmd/coder wsproxy create \ |
| 243 | + --name=local-proxy \ |
| 244 | + --display-name="Local Proxy" \ |
| 245 | + --icon="/emojis/1f4bb.png" \ |
| 246 | + --only-token) |
| 247 | + exec go run ./cmd/coder wsproxy server \ |
| 248 | + --dangerous-allow-cors-requests=true \ |
| 249 | + --http-address=0.0.0.0:3010 \ |
| 250 | + --proxy-session-token="$$PROXY_TOKEN" \ |
| 251 | + --primary-access-url=http://coderd:3000 |
| 252 | + ' |
| 253 | +
|
| 254 | + setup-multi-org: |
| 255 | + profiles: ["multi-org"] |
| 256 | + labels: |
| 257 | + - "com.coder.dev" |
| 258 | + networks: |
| 259 | + - coder-dev |
| 260 | + image: codercom/oss-dogfood:latest |
| 261 | + depends_on: |
| 262 | + setup-users: |
| 263 | + condition: service_completed_successfully |
| 264 | + setup-template: |
| 265 | + condition: service_completed_successfully |
| 266 | + working_dir: /app |
| 267 | + environment: |
| 268 | + CODER_URL: "http://coderd:3000" |
| 269 | + DOCKER_HOST: "${CODER_DEV_DOCKER_HOST:-unix:///var/run/docker.sock}" |
| 270 | + LICENSE_FILE: "${CODER_DEV_LICENSE_FILE:-./license.txt}" |
| 271 | + GOMODCACHE: /go-cache/mod |
| 272 | + GOCACHE: /go-cache/build |
| 273 | + volumes: |
| 274 | + - .:/app |
| 275 | + - go_cache:/go-cache |
| 276 | + - bootstrap_token:/bootstrap:ro |
| 277 | + - ./scripts/docker-dev:/scripts:ro |
| 278 | + - "${CODER_DEV_LICENSE_FILE:-./license.txt}:/license.txt:ro" |
| 279 | + command: ["sh", "/scripts/setup-multi-org.sh"] |
| 280 | + |
| 281 | + ext-provisioner: |
| 282 | + profiles: ["multi-org"] |
| 283 | + labels: |
| 284 | + - "com.coder.dev" |
| 285 | + networks: |
| 286 | + - coder-dev |
| 287 | + healthcheck: |
| 288 | + test: ["CMD", "curl", "--fail", "http://localhost:2112"] |
| 289 | + image: codercom/oss-dogfood:latest |
| 290 | + depends_on: |
| 291 | + setup-multi-org: |
| 292 | + condition: service_completed_successfully |
| 293 | + group_add: |
| 294 | + - "${DOCKER_GROUP:-999}" |
| 295 | + working_dir: /app |
| 296 | + environment: |
| 297 | + CODER_URL: "http://coderd:3000" |
| 298 | + DOCKER_HOST: "${CODER_DEV_DOCKER_HOST:-unix:///var/run/docker.sock}" |
| 299 | + GOMODCACHE: /go-cache/mod |
| 300 | + GOCACHE: /go-cache/build |
| 301 | + CODER_PROMETHEUS_ENABLE: "1" |
| 302 | + volumes: |
| 303 | + - .:/app |
| 304 | + - go_cache:/go-cache |
| 305 | + - bootstrap_token:/bootstrap:ro |
| 306 | + - "${DOCKER_SOCKET:-/var/run/docker.sock}:/var/run/docker.sock" |
| 307 | + command: > |
| 308 | + sh -c ' |
| 309 | + export CODER_SESSION_TOKEN=$$(cat /bootstrap/token) && |
| 310 | + exec go run ./enterprise/cmd/coder provisionerd start \ |
| 311 | + --tag "scope=organization" \ |
| 312 | + --name second-org-daemon \ |
| 313 | + --org second-organization |
| 314 | + ' |
| 315 | +
|
| 316 | + setup-multi-org-template: |
| 317 | + profiles: ["multi-org"] |
| 318 | + labels: |
| 319 | + - "com.coder.dev" |
| 320 | + networks: |
| 321 | + - coder-dev |
| 322 | + image: codercom/oss-dogfood:latest |
| 323 | + depends_on: |
| 324 | + setup-multi-org: |
| 325 | + condition: service_completed_successfully |
| 326 | + ext-provisioner: |
| 327 | + condition: service_healthy |
| 328 | + working_dir: /app |
| 329 | + environment: |
| 330 | + CODER_URL: "http://coderd:3000" |
| 331 | + GOMODCACHE: /go-cache/mod |
| 332 | + GOCACHE: /go-cache/build |
| 333 | + volumes: |
| 334 | + - .:/app |
| 335 | + - go_cache:/go-cache |
| 336 | + - bootstrap_token:/bootstrap:ro |
| 337 | + - ./scripts/docker-dev:/scripts:ro |
| 338 | + command: ["sh", "-c", "/scripts/setup-template.sh second-organization"] |
| 339 | + |
| 340 | + |
| 341 | +volumes: |
| 342 | + coder_dev_data: |
| 343 | + labels: |
| 344 | + - "com.coder.dev" |
| 345 | + go_cache: |
| 346 | + labels: |
| 347 | + - "com.coder.dev" |
| 348 | + coder_cache: |
| 349 | + labels: |
| 350 | + - "com.coder.dev" |
| 351 | + site_node_modules: |
| 352 | + labels: |
| 353 | + - "com.coder.dev" |
| 354 | + bootstrap_token: |
| 355 | + labels: |
| 356 | + - "com.coder.dev" |
| 357 | + |
| 358 | +networks: |
| 359 | + coder-dev: |
| 360 | + labels: |
| 361 | + - "com.coder.dev" |
| 362 | + name: coder-dev |
| 363 | + driver: bridge |
0 commit comments