-
Notifications
You must be signed in to change notification settings - Fork 15
Docker dev server doesn't receive environment variables from .env files #881
Description
Problem
When using Docker-based dev servers (devServer: 'docker'), environment variables from .env files are not passed into the container. This means any dev server that depends on environment variables (e.g., DATABASE_URL, API_KEY) will fail to start or behave correctly in Docker mode.
Root Cause
There are two related gaps:
1. il open / il run never load .env files
ensureServerRunning() in DevServerManager doesn't accept or pass envOverrides. Neither open.ts nor run.ts call loadWorkspaceEnv() — they only use getWorkspacePort() for port calculation.
- In native mode, this accidentally works because the child process inherits
process.envfrom the host shell (which may include sourced.envvars) - In Docker mode, this completely fails — containers are isolated and only receive explicitly passed
-eflags
2. Docker strategy has no .env file mechanism
startDockerServer() calls runContainerDetached() without any envOverrides. The container only receives PORT. There is no --env-file flag or .env volume mount.
What works today
il dev-server <issue> (foreground mode) correctly loads .env files via loadWorkspaceEnv() and passes them as envOverrides — this works in both native and Docker modes.
Suggested fix
- Add
envOverridesparameter toDevServerManager.ensureServerRunning()and plumb it through tostartDockerServer()→runContainerDetached() - Have
open.tsandrun.tscallloadWorkspaceEnv()(whensourceEnvOnStartis enabled) and pass the result through - Consider also supporting Docker's
--env-fileflag as an alternative/complement to individual-eflags
Affected code paths
src/lib/DevServerManager.ts—ensureServerRunning(),startDockerServer()src/lib/DockerDevServerStrategy.ts—runContainerDetached()src/commands/open.ts—ensureServerRunning()callsrc/commands/run.ts—ensureServerRunning()callsrc/utils/env.ts—loadWorkspaceEnv()
Metadata
Metadata
Assignees
Labels
Type
Projects
Status