From fa6c47abb846f1e7e13afe60803836abd0880ba0 Mon Sep 17 00:00:00 2001 From: Dan-George Filimon Date: Wed, 4 Nov 2026 14:23:54 +0100 Subject: [PATCH] Add customizable Coder development Compose setup --- scripts/dev/coder/compose.yaml | 61 ++++++++++++++++++++++++++++++++++ scripts/dev/coder/dev.sh | 9 +++++ scripts/dev/compose.test.mjs | 24 +++++++++++++ scripts/dev/lib/common.sh | 2 +- scripts/dev/stack.mjs | 2 +- 5 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 scripts/dev/coder/compose.yaml create mode 100755 scripts/dev/coder/dev.sh create mode 100644 scripts/dev/compose.test.mjs diff --git a/scripts/dev/coder/compose.yaml b/scripts/dev/coder/compose.yaml new file mode 100644 index 000000000..483841ada --- /dev/null +++ b/scripts/dev/coder/compose.yaml @@ -0,0 +1,61 @@ +# Replace the image defaults below with your internal registry references. +# Images must provide the same executables as the upstream counterparts. +# Start through ./scripts/dev/coder/dev.sh so databases, bucket and Temporal +# search attributes are initialized by the normal development launcher. +name: ${COMPOSE_PROJECT_NAME:-lightspeed-dev} + +services: + postgres: + extends: + file: ../docker-compose.yaml + service: postgres + image: ${POSTGRES_IMAGE:-postgres:17} + + pgadmin: + extends: + file: ../docker-compose.yaml + service: pgadmin + image: ${PGADMIN_IMAGE:-dpage/pgadmin4:8} + + minio: + extends: + file: ../docker-compose.yaml + service: minio + image: ${MINIO_IMAGE:-chainguard/minio:latest} + # Override MINIO_USER if the internal image requires a non-root identity. + # That identity must have write access to the minio-data volume. + user: ${MINIO_USER:-0:0} + + mc: + extends: + file: ../docker-compose.yaml + service: mc + image: ${MINIO_MC_IMAGE:-chainguard/minio-client:latest} + entrypoint: ["mc"] + + temporal: + extends: + file: ../docker-compose.yaml + service: temporal + image: ${TEMPORAL_IMAGE:-temporalio/admin-tools:latest} + # Use an image containing the Temporal CLI, not just temporal-server. + # Explicitly replace any image entrypoint; the launcher also invokes + # `temporal operator ...` via docker compose exec during initialization. + entrypoint: ["temporal"] + command: + - server + - start-dev + - --ip + - 0.0.0.0 + - --ui-ip + - 0.0.0.0 + - --db-filename + - /home/temporal/temporal.db + # Adjust the database path and inherited volume mount together if your + # internal image uses another writable home. This is a development server. + +volumes: + postgres-data: + pgadmin-data: + minio-data: + temporal-data: diff --git a/scripts/dev/coder/dev.sh b/scripts/dev/coder/dev.sh new file mode 100755 index 000000000..eaac2d072 --- /dev/null +++ b/scripts/dev/coder/dev.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +CODER_DEV_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +export LIGHTSPEED_DEV_COMPOSE_FILE="${CODER_DEV_DIR}/compose.yaml" + +# All normal launcher commands are supported, including status, stop and down. +# Registry authentication uses your existing Docker configuration. +exec bash "${CODER_DEV_DIR}/../../../dev.sh" "$@" diff --git a/scripts/dev/compose.test.mjs b/scripts/dev/compose.test.mjs new file mode 100644 index 000000000..914fe1f0f --- /dev/null +++ b/scripts/dev/compose.test.mjs @@ -0,0 +1,24 @@ +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { fileURLToPath } from "node:url"; +import test from "node:test"; + +const root = fileURLToPath(new URL("../../", import.meta.url)); + +for (const override of ["", "/tmp/internal images/compose.yaml"]) { + test(`infrastructure commands use ${override ? "the selected" : "the default"} Compose file`, () => { + const result = spawnSync("bash", ["-c", ` + source scripts/dev/lib/common.sh + docker() { printf '%s\\n' "$@"; } + compose ps + `], { + cwd: root, + encoding: "utf8", + env: { ...process.env, LIGHTSPEED_DEV_COMPOSE_FILE: override }, + }); + assert.equal(result.status, 0, result.stderr); + assert.deepEqual(result.stdout.trim().split("\n"), [ + "compose", "-f", override || `${root}scripts/dev/docker-compose.yaml`, "ps", + ]); + }); +} diff --git a/scripts/dev/lib/common.sh b/scripts/dev/lib/common.sh index 8fde110e0..52f2ff231 100644 --- a/scripts/dev/lib/common.sh +++ b/scripts/dev/lib/common.sh @@ -11,7 +11,7 @@ fi LIGHTSPEED_DEV_COMMON_DIR="$(cd "$(dirname "${LIGHTSPEED_DEV_COMMON_PATH}")" && pwd)" DEV_DIR="$(cd "${LIGHTSPEED_DEV_COMMON_DIR}/.." && pwd)" REPO_ROOT="$(cd "${DEV_DIR}/../.." && pwd)" -COMPOSE_FILE="${DEV_DIR}/docker-compose.yaml" +COMPOSE_FILE="${LIGHTSPEED_DEV_COMPOSE_FILE:-${DEV_DIR}/docker-compose.yaml}" COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-lightspeed-dev}" diff --git a/scripts/dev/stack.mjs b/scripts/dev/stack.mjs index c505545fa..2190c42c7 100644 --- a/scripts/dev/stack.mjs +++ b/scripts/dev/stack.mjs @@ -592,7 +592,7 @@ async function runDevelopmentAction(options, env) { "--project-name", env.COMPOSE_PROJECT_NAME ?? "lightspeed-dev", "-f", - path.join(devDir, "docker-compose.yaml"), + env.LIGHTSPEED_DEV_COMPOSE_FILE ?? path.join(devDir, "docker-compose.yaml"), "ps", ], env,