Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .changeset/fresh-walls-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roomote/web': minor
---

Allow environments to request a Docker runtime without a placeholder project, and configure the Roomote dogfood environment for authenticated nested task previews.
23 changes: 19 additions & 4 deletions .roomote/environments/roomote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ description:
(Redis, API, BullMQ, controller) plus a local Mintlify preview of the public
docs site (apps/docs) on the `docs` port.
initialUrl: http://127.0.0.1:3000/auth/dev-login
nested_docker: true
ports:
- name: web
port: 3000
initial_path: /auth/dev-login
primary: true
- name: docs
port: 3333
- name: preview
port: 18081
wildcard_prefix: true
services:
- postgres16
repositories:
Expand All @@ -41,7 +45,7 @@ repositories:
timeout: 600
continue_on_error: false
- name: Write local env overrides
run: printf 'DATABASE_URL=postgresql://postgres@localhost:5432/roomote_development\nREDIS_URL=redis://localhost:16379\nR_APP_ENV=development\nWEB_DEV_LOGIN_ENABLED=true\n' > .env.local
run: printf 'DATABASE_URL=postgresql://postgres@localhost:5432/roomote_development\nREDIS_URL=redis://localhost:16379\nR_APP_ENV=development\nWEB_DEV_LOGIN_ENABLED=true\nDEFAULT_COMPUTE_PROVIDER=docker\n' > .env.local
timeout: 600
continue_on_error: false
- name: Create development database
Expand Down Expand Up @@ -77,15 +81,15 @@ repositories:
- name: Build local worker release
run: pnpm --filter @roomote/dev build-worker-release
timeout: 600
continue_on_error: true
continue_on_error: false
- name: Start API server
run: PORT=13001 R_APP_ENV=development pnpm --filter @roomote/api dev
timeout: 600
continue_on_error: true
detached: true
logfile: /tmp/roomote-api.log
- name: Start Next.js web dev server
run: PORT=3000 R_APP_ENV=development WEB_DEV_LOGIN_ENABLED=true pnpm --filter @roomote/web dev
run: bash .roomote/scripts/with-nested-preview-env.sh env PORT=3000 R_APP_ENV=development WEB_DEV_LOGIN_ENABLED=true pnpm --filter @roomote/web dev
timeout: 600
continue_on_error: false
detached: true
Expand All @@ -97,11 +101,22 @@ repositories:
detached: true
logfile: /tmp/roomote-bullmq.log
- name: Start controller
run: R_APP_ENV=development TRPC_URL="${ROOMOTE_API_HOST:-http://localhost:13001}" R_APP_URL="${ROOMOTE_WEB_HOST:-http://localhost:3000}" R_PUBLIC_URL="${ROOMOTE_WEB_HOST:-http://localhost:3000}" pnpm --filter @roomote/controller dev
run: bash .roomote/scripts/with-nested-preview-env.sh env R_APP_ENV=development DEFAULT_COMPUTE_PROVIDER=docker TRPC_URL="http://localhost:13001" R_APP_URL="${ROOMOTE_WEB_HOST:-http://localhost:3000}" R_PUBLIC_URL="${ROOMOTE_WEB_HOST:-http://localhost:3000}" PREVIEW_AUTH_COOKIE_NAME=preview_auth_inner pnpm --filter @roomote/controller dev
timeout: 600
continue_on_error: true
detached: true
logfile: /tmp/roomote-controller.log
- name: Start nested preview proxy
run: bash .roomote/scripts/with-nested-preview-env.sh env PORT=18081 R_APP_ENV=development R_APP_URL="${ROOMOTE_WEB_HOST:-http://localhost:3000}" PREVIEW_AUTH_COOKIE_NAME=preview_auth_inner pnpm --filter @roomote/preview-proxy dev
timeout: 600
continue_on_error: true
detached: true
logfile: /tmp/roomote-preview-proxy.log
- name: Verify task runtime services
run: >-
bash -lc 'set -eu; docker version --format "{{.Server.Version}}" >/dev/null; for endpoint in http://localhost:13001/health/liveness http://localhost:13001/health/controller http://localhost:13002/admin/health http://localhost:18081/health http://localhost:3000/auth/dev-login; do attempts=0; until curl -fsS "$endpoint" >/dev/null; do attempts=$((attempts + 1)); if [ "$attempts" -ge 90 ]; then echo "Timed out waiting for $endpoint" >&2; exit 1; fi; sleep 1; done; done'
timeout: 600
continue_on_error: false
- name: Start Mintlify docs preview
# Mint is needed only for this optional final service.
run: mise install node@22.20.0 && mise exec node@22.20.0 -- npm install -g mint && cd apps/docs && mise exec node@22.20.0 -- mint dev --port 3333 --no-open
Expand Down
34 changes: 34 additions & 0 deletions .roomote/scripts/with-nested-preview-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail

# Deployments without outer preview routing omit named-port host variables.
# Keep the Roomote development stack usable there; only nested preview URLs
# are unavailable.
if [[ -z "${ROOMOTE_PREVIEW_HOST:-}" ]]; then
exec "$@"
fi

preview_url="$ROOMOTE_PREVIEW_HOST"
preview_scheme="${preview_url%%://*}"
preview_host="${preview_url#*://}"
preview_host="${preview_host%%/*}"
preview_suffix="${preview_host%%.*}"
preview_base_host="${preview_host#*.}"

if [[ "$preview_scheme" != "http" && "$preview_scheme" != "https" ]]; then
echo "Unsupported preview URL scheme: $preview_scheme" >&2
exit 1
fi

if [[ "$preview_base_host" == "$preview_host" ]]; then
echo "ROOMOTE_PREVIEW_HOST must contain a task-specific subdomain" >&2
exit 1
fi

export PREVIEW_PROXY_BASE_URL="${preview_scheme}://${preview_base_host}"
export PREVIEW_PROXY_SUBDOMAIN_SUFFIX="$preview_suffix"
export PREVIEW_DOMAINS="${preview_base_host%%:*}"
export NEXT_PUBLIC_PREVIEW_PROXY_BASE_URL="$PREVIEW_PROXY_BASE_URL"
export NEXT_PUBLIC_PREVIEW_PROXY_SUBDOMAIN_SUFFIX="$preview_suffix"

exec "$@"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export async function taskNeedsNestedDocker(
environmentConfig: EnvironmentConfig | undefined,
): Promise<boolean> {
if (environmentConfig) {
return Boolean(environmentConfig.docker_projects?.length);
return (
environmentConfig.nested_docker === true ||
Boolean(environmentConfig.docker_projects?.length)
);
}

const task = await db.query.tasks.findFirst({
Expand Down
14 changes: 14 additions & 0 deletions apps/docs/environments/definition.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,20 @@ All paths must be relative and stay inside the selected repository. Docker
projects are supported by all sandbox providers. Modal runs them in its beta VM
sandbox runtime.

### Docker runtime without a project

Set `nested_docker: true` when the application starts containers dynamically
and therefore needs a Docker daemon without a `docker_projects` entry:

```yaml
nested_docker: true
```

This selects a Docker-capable sandbox and verifies that its daemon is ready
before repository setup commands run. It does not build or start a placeholder
container. Environments that neither set this flag nor declare a Docker project
keep the existing runtime and resource requirements.

## Ports

`ports` declares the human-facing application URLs Roomote should expose as
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions apps/web/src/components/settings/environments/yaml-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export function configToYaml(config: EnvironmentConfig): string {
cleanConfig.docker_projects = config.docker_projects;
}

if (config.nested_docker === true) {
cleanConfig.nested_docker = true;
}

if (config.services && config.services.length > 0) {
cleanConfig.services = config.services;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions apps/worker/src/commands/__tests__/utils.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export async function initializeDockerProjects(

const config = options.workspace.environmentConfig;
const projects = config.docker_projects ?? [];
if (projects.length === 0) return;
if (projects.length === 0 && config.nested_docker !== true) return;

const baseEnv = getDefinedEnv(options.envVars);

Expand All @@ -524,6 +524,11 @@ export async function initializeDockerProjects(
throw new Error(message, { cause: error });
}

if (projects.length === 0) {
logger.userLog.log('Docker runtime is ready');
return;
}

for (const project of projects) {
let resolved: ResolvedDockerProject | undefined;

Expand Down
Loading
Loading