Docker errors when deploying Turborepo application

ianmitchellHOBBY

6 months ago

Hello! I'm relatively new to Docker, and am trying to figure out how to correctly configure a new service to deploy. I've tried following advice from Railway docs and Turborepo docs but I think they both expect slightly different situations and aren't exactly compatible.

When I deploy, I'm seeing the Dockerfile fail with these errors:

#9 ERROR: failed to calculate checksum of ref kejf4w0mdb0avf096x2aemhwz::x4pxm5rhocxskoqbdv2joedda: "/apps/0x57-api/package.json": not found
#10 ERROR: failed to calculate checksum of ref kejf4w0mdb0avf096x2aemhwz::x4pxm5rhocxskoqbdv2joedda: "/bun.lockb": not found

My Dockerfile is located in apps/0x57-api/Dockerfile and looks like this:

FROM oven/bun:1
WORKDIR /usr/src/app

ENV NODE_ENV=production

# Turbo Remote Cache Setup
ARG TURBO_TEAM
ENV TURBO_TEAM=$TURBO_TEAM
ARG TURBO_TOKEN
ENV TURBO_TOKEN=$TURBO_TOKEN

# Once Turbo supports Bun Prune, we can do additional performance improvements here.
# https://turbo.build/repo/docs/guides/tools/docker

# Copy files
COPY package.json ./
COPY bun.lockb ./
COPY apps/0x57-api/package.json ./apps/0x57-api/package.json
COPY . .

RUN bun install --frozen-lockfile --production

EXPOSE 3030/tcp

WORKDIR /usr/src/app/apps/0x57-api
RUN [ "bun", "start" ]

My Railway configuration file is located in apps/0x57-api/railway.json:

{
    "$schema": "https://railway.com/railway.schema.json",
    "build": {
        "builder": "DOCKERFILE",
        "dockerfilePath": "apps/0x57-api/Dockerfile",
        "watchPatterns": ["apps/0x57-api/**/*", "packages/**/*"]
    },
    "deploy": {
        "numReplicas": 1,
        "restartPolicyType": "ON_FAILURE",
        "restartPolicyMaxRetries": 3,
        "healthcheckPath": "/health",
        "healthcheckTimeout": 50
    }
}

The error makes me think file paths are wrong. The dockerfile builds locally.

Solved

0 Replies

ianmitchellHOBBY

6 months ago

e02f202e-ad40-4835-b143-01be7acd7c59


ianmitchellHOBBY

6 months ago

More information now that I'm free of the character limit lol: I have the Root Directory set to /. From the Railway docs, I think this may not be recommended, but because I'm reading the bun.lockb file in the root directory, I think I need to? Changing it to apps/0x57-api did not change the issue.


ianmitchellHOBBY

6 months ago

My file structure looks like this:

├── apps
│   ├── 0x57-api
│     ├── Dockerfile
│     ├── package.json
│     ├── railway.json
│     └── src
│   └── 0x57-app
│       └── package.json
├── bun.lockb
├── docker-compose.yml
├── package.json
├── packages
│   ├── database
│     ├── package.json
│     └── src
│   ├── internal-webauthn
│     ├── package.json
│     └── src
└── turbo.json

ianmitchellHOBBY

6 months ago

Huh, for whatever reasoning lifting my docker ignore file to the root seems to have fixed it. I'm unclear why, but I'll take it


6 months ago

awesome, glad you solved it!


6 months ago

!s


Status changed to Solved brody 6 months ago


Docker errors when deploying Turborepo application - Railway Help Station