Docker build context completely empty when using UI-configured Dockerfile path
rickyhopkins
PROOP

3 months ago

Problem:

Railway finding Dockerfile correctly but providing empty build context to Docker - zero files available during build.

Config:

- NO railway.toml file (using UI configuration)

- Dashboard Settings → Dockerfile Path: frontend/Dockerfile

- Monorepo structure with frontend in /frontend subdirectory

Error:

Build fails at COPY package.json package-lock.json ./ with:

ERROR: failed to compute cache key: "/package.json": not found

Diagnostics performed:

- ls -la / in container shows only standard Linux filesystem - no repo files at all

- find / -name "package.json" returns nothing

- Build context is completely empty before any COPY commands

- Local Docker build with docker build -f frontend/Dockerfile frontend/ works perfectly

- Dockerfile IS being found and executed by Railway (confirmed via debug logs)

Debug output from Dockerfile RUN ls -la /:

total 64

drwxr-xr-x 1 root root 4096 bin

drwxr-xr-x 5 root root 360 dev

drwxr-xr-x 1 root root 4096 etc

... (standard Linux filesystem only - NO repository files)

Attempted fixes:

- Tried with and without Root Directory setting

- Verified .dockerignore doesn't block package.json

- Tested explicit paths in COPY commands

- Cleared build cache and rebuilt from scratch

Question:

When setting Dockerfile Path in UI as frontend/Dockerfile, what build context does Railway use? How do I make Railway provide the /frontend directory contents as build context?

**Project structure:**

/

├── api/

│ └── Dockerfile (separate backend service)

├── frontend/

│ ├── Dockerfile

│ ├── package.json

│ ├── package-lock.json

│ └── src/

Expected: Railway uses frontend/ as build context (standard Docker behavior)

Actual: Build context is completely empty

Solved$10 Bounty

3 Replies

Railway
BOT

3 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


Railway

Hey there! We've found the following might help you get unblocked faster: - [🧵 Rust/TS Monorepo](https://station.railway.com/questions/rust-ts-monorepo-37c42b4e) - [🧵 deployment failure - replica never became healthy](https://station.railway.com/questions/deployment-failure-replica-never-beca-5114b651) - [🧵 Unable to deploy from monorepo](https://station.railway.com/questions/unable-to-deploy-from-monorepo-edc16dc5) If you find the answer from one of these, please let us know by solving the thread!

rickyhopkins
PROOP

3 months ago

No useful information in those threads sorry.


Status changed to Awaiting Conductor Response noahd 3 months ago


3 months ago

Hello,

You have your root directory unset, so it defaults to /. The root directory is going to be the build context, and setting a Dockerfile path does not change the build context.


Status changed to Awaiting User Response Railway 3 months ago


Railway
BOT

3 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 3 months ago


Loading...