Skip to content

fix(docker): Railway build timeout due to recursive chown in Dockerfile #6365

@leomerida15

Description

@leomerida15

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

  1. Push any change that triggers a Railway build on service 51327026-1a43-4778-9fcc-c40c2d005d1d
  2. Observe the build logs
  3. The build completes pnpm build successfully
  4. The RUN chown -R node:node . step runs for ~17 minutes
  5. Image export takes ~6 minutes
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions