fix(docker): let the node user create the turbo cache dir - #79
Conversation
The USER node switch (PR #74) crash-looped production on boot: WORKDIR creates /calcom as root-owned, so turbo could not create /calcom/.turbo and 'yarn start' (turbo run start) exited with 'Permission denied'. Pre-create the directory for the node user. Production was rolled back to the previous image while this builds.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request modifies the Dockerfile to pre-create the /calcom/.turbo directory and change its ownership to the node user, preventing permission issues at runtime. The reviewer suggested a more robust alternative: changing the ownership of the /calcom directory itself non-recursively, which allows the node user to dynamically create any necessary runtime cache directories.
| # WORKDIR created /calcom itself as root-owned, so the node user cannot create | ||
| # turbo's runtime cache dir there - `yarn start` (turbo run start) died with | ||
| # "failed to create directory /calcom/.turbo" and crash-looped the container. | ||
| RUN mkdir -p /calcom/.turbo && chown node:node /calcom/.turbo |
There was a problem hiding this comment.
Instead of pre-creating specific directories like /calcom/.turbo, it is more robust and future-proof to change the ownership of the /calcom directory itself. Since WORKDIR creates /calcom as root-owned, changing its ownership non-recursively to node:node allows the node user to create any necessary runtime cache directories or files (including .turbo) dynamically at runtime without duplicating layers.
# WORKDIR created /calcom itself as root-owned, so the node user cannot write
# to it. Changing ownership of the directory itself (non-recursively) allows
# the node user to create runtime cache directories like .turbo.
RUN chown node:node /calcom
What
PR #74's USER node switch crash-looped production on boot. Root cause verified on the server: WORKDIR creates /calcom itself as root-owned (the COPY --chown covers the contents, not the pre-existing directory), so turbo cannot create /calcom/.turbo and
yarn start(turbo run start) exits with Permission denied.Fix: pre-create /calcom/.turbo owned by node before switching to USER node.
Incident handling
Production cal.crove.com was rolled back to the previous image (docker tag swap on crove-server) and is stable. Once this merges and the image builds, it gets re-deployed and verified end-to-end.
Evidence
failed to create directory /calcom/.turbofrom turbo.🤖 Generated by ZCode