Skip to content
Merged
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/dev-container-host-ownership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"seamless-templates": patch
---

The Express and FastAPI dev containers no longer write into the bind-mounted source. On a Linux host the generated stack runs them as root, so the Express logger's `logs/app.log` and FastAPI's `__pycache__` directories ended up owned by root and `rm -rf` of the project failed without sudo. The Express dev stage now sets `LOG_DIR=/tmp/logs` (the logger reads `LOG_DIR`, and still writes `./logs` when run on the host), and the FastAPI dev stage sets `PYTHONPYCACHEPREFIX=/tmp/pycache`.
3 changes: 3 additions & 0 deletions templates/api/express/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ CMD ["npm", "run", "start"]

# Last on purpose. See the note at the top of this file before moving it.
FROM deps AS dev
# The generated stack bind-mounts the source over /app and runs this as root. On a
# Linux host, logs/ under /app would be root's and block removing the project.
ENV LOG_DIR=/tmp/logs
COPY . .
EXPOSE 3000
CMD ["npm", "run", "dev"]
2 changes: 1 addition & 1 deletion templates/api/express/src/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function getLogger(moduleName: string): Logger {
);

if (!isProd) {
const logDir = path.resolve("./logs");
const logDir = path.resolve(process.env.LOG_DIR || "./logs");
if (!fs.existsSync(logDir)) {
fs.mkdirSync(logDir, { recursive: true });
}
Expand Down
3 changes: 3 additions & 0 deletions templates/api/fastapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ CMD ["uvicorn", "app.main:build", "--factory", "--host", "0.0.0.0", "--port", "3
# Last on purpose. See the note at the top of this file before moving it.
FROM base AS dev
RUN uv sync --locked
# The generated stack bind-mounts the source over /app and runs this as root. On a
# Linux host, __pycache__ under /app would be root's and block removing the project.
ENV PYTHONPYCACHEPREFIX=/tmp/pycache
COPY . .
EXPOSE 3000
CMD ["uvicorn", "app.main:build", "--factory", "--reload", "--host", "0.0.0.0", "--port", "3000"]
Loading