Skip to content

Fix Docker build and .env discovery broken by the workspace migration#272

Open
carlosplanchon wants to merge 1 commit into
benavlabs:mainfrom
carlosplanchon:fix/workspace-env-and-docker-build
Open

Fix Docker build and .env discovery broken by the workspace migration#272
carlosplanchon wants to merge 1 commit into
benavlabs:mainfrom
carlosplanchon:fix/workspace-env-and-docker-build

Conversation

@carlosplanchon

Copy link
Copy Markdown
Collaborator

Two quickstart-breaking leftovers from the uv-workspace migration: (1) the generated compose builds with ./backend as context but uv.lock lives at the workspace root, so docker compose up --build fails on a clean clone; fixed by building from the workspace root with uv export --package (dev/prod/migrate targets verified). (2) settings never look for backend/.env, the location the README tells you to create, so running without Docker silently falls back to defaults; fixed by adding it to the search list, plus skipping .env loading under pytest so a developer's real .env can't leak into the unit tests that assert code defaults.

…tion

Two quickstart-breaking leftovers from the uv-workspace migration, plus a
test-isolation consequence of the second fix.

Docker build: the generated compose built with ./backend as context while
uv.lock now lives at the workspace root, so `docker compose up --build`
failed on a clean clone ("/uv.lock": not found). The build context is now
the workspace root: the Dockerfile copies the root manifest + lock plus
the member pyprojects and exports with `uv export --package
fastapi-boilerplate` (the local project line is now "./backend", filter
adjusted; dev requirements export the backend's `dev` extra). The compose
templates gain build_context/backend_dockerfile variables, while
host-side paths such as volume mounts keep using backend_context. A root
.dockerignore keeps the context lean and free of secrets (.env excluded).
Verified: dev, prod and migrate targets all build.

.env discovery: the README says `cp backend/.env.example backend/.env`,
but settings searched /app/.env, the workspace root, and /, silently
ignoring the documented location when running outside Docker (everything
fell back to defaults). backend/.env now comes right after /app/.env in
the search list.

Since backend/.env is now reliably discovered, a developer's real .env
would leak into unit tests that assert code defaults, so settings skip
.env loading under pytest: the suite already declares ENVIRONMENT=pytest,
and PYTEST_VERSION covers runs where the pytest-env plugin is absent.

181 unit + 17 auth integration tests green.

Signed-off-by: Carlos Andrés Planchón Prestes <carlosandresplanchonprestes@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant