Describe the bug
The Dockerfile at the project root uses RUN chown -R node:node . after copying and building the entire application. On Railway, this step alone takes approximately 17 minutes, followed by a 6-minute image export. The total build exceeds Railway's 30-minute activity heartbeat limit, causing the deployment to time out even though the build itself completes successfully.
To Reproduce
- Push any change that triggers a Railway build on service
51327026-1a43-4778-9fcc-c40c2d005d1d
- Observe the build logs
- The build completes
pnpm build successfully
- The
RUN chown -R node:node . step runs for ~17 minutes
- Image export takes ~6 minutes
- Deployment times out during image push
Expected behavior
Build should complete well within the 30-minute platform limit by avoiding expensive recursive ownership changes on large directories like node_modules.
Proposed Fix
Use COPY --chown=node:node and pre-create the workdir with correct ownership before switching to the node user. This eliminates the need for chown -R entirely.
Additional context
- Service ID:
51327026-1a43-4778-9fcc-c40c2d005d1d
- Base image:
node:20-alpine
- The recursive chown is O(n) over every file in
node_modules and build artifacts, which is why it's so slow.
Describe the bug
The Dockerfile at the project root uses
RUN chown -R node:node .after copying and building the entire application. On Railway, this step alone takes approximately 17 minutes, followed by a 6-minute image export. The total build exceeds Railway's 30-minute activity heartbeat limit, causing the deployment to time out even though the build itself completes successfully.To Reproduce
51327026-1a43-4778-9fcc-c40c2d005d1dpnpm buildsuccessfullyRUN chown -R node:node .step runs for ~17 minutesExpected behavior
Build should complete well within the 30-minute platform limit by avoiding expensive recursive ownership changes on large directories like
node_modules.Proposed Fix
Use
COPY --chown=node:nodeand pre-create the workdir with correct ownership before switching to thenodeuser. This eliminates the need forchown -Rentirely.Additional context
51327026-1a43-4778-9fcc-c40c2d005d1dnode:20-alpinenode_modulesand build artifacts, which is why it's so slow.