R
Railway8mo ago
Jay

Getting a "prefix not found" error when running railway up

I'm trying to deploy a monorepo via railway CLI but only one of the repos is deployed on railway, so i'm using Docker to do so and using railway.json inside the repo folder for the configuration. When I run railway up --servicename --environment <PATH_TO_RAILWAY_JSON> I'm getting a prefix not found error.
Indexed Compressed [====================] 100% prefix not found
Indexed Compressed [====================] 100% prefix not found
Is there a way to know where the error is/how to fix it? Thanks!
Solution:
yeah that's not a path to a railway.json file either way, there is a far better way to set the path to your dockerfile, delete the railway.json and set this service variable - ``` RAILWAY_DOCKERFILE_PATH=/docker/prod/api/Dockerfile.api...
Jump to solution
25 Replies
Percy
Percy8mo ago
Project ID: 033f39f1-9797-405f-88f8-343ca4ac4254
Jay
JayOP8mo ago
033f39f1-9797-405f-88f8-343ca4ac4254
Brody
Brody8mo ago
can you send your dockerfile and railway.json?
Jay
JayOP8mo ago
Hey @Brody , sorry for the late reply but here it is railway.json
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"dockerfilePath": "docker/prod/api/Dockerfile.api"
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"dockerfilePath": "docker/prod/api/Dockerfile.api"
}
}
Dockerfile
FROM node:20-alpine AS alpine
RUN apk add --no-cache libc6-compat
RUN apk update

# Setup pnpm and turbo on the alpine base
FROM alpine as base
RUN npm install pnpm turbo --global
RUN pnpm config set store-dir ~/.pnpm-store

# Prune projects
FROM base AS pruner

ARG PROJECT="@repo/api"

WORKDIR /app
COPY . .
RUN turbo prune --scope=${PROJECT} --docker

# Build the project
FROM base AS builder
ARG PROJECT="@repo/api"

WORKDIR /app

# Copy lockfile and package.json's of isolated subworkspace
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=pruner /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY --from=pruner /app/out/json/ .

# First install the dependencies (as they change less often)
RUN pnpm install --frozen-lockfile

# Copy source code of isolated subworkspace
COPY --from=pruner /app/out/full/ .

# Env vars required to build the project
ARG DATABASE_URL
ARG RESEND_KEY
ARG BUILD_ENV

RUN turbo build:${BUILD_ENV} --filter=${PROJECT}
RUN rm -rf ./node_modules
RUN pnpm install --prod --frozen-lockfile

# Final image
FROM alpine AS runner

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
USER nodejs

WORKDIR /app
COPY --from=builder --chown=nodejs:nodejs /app .
WORKDIR /app/apps/api

ARG PORT=8080
ENV PORT=${PORT}

CMD ["node","dist/index.js"]
FROM node:20-alpine AS alpine
RUN apk add --no-cache libc6-compat
RUN apk update

# Setup pnpm and turbo on the alpine base
FROM alpine as base
RUN npm install pnpm turbo --global
RUN pnpm config set store-dir ~/.pnpm-store

# Prune projects
FROM base AS pruner

ARG PROJECT="@repo/api"

WORKDIR /app
COPY . .
RUN turbo prune --scope=${PROJECT} --docker

# Build the project
FROM base AS builder
ARG PROJECT="@repo/api"

WORKDIR /app

# Copy lockfile and package.json's of isolated subworkspace
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=pruner /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY --from=pruner /app/out/json/ .

# First install the dependencies (as they change less often)
RUN pnpm install --frozen-lockfile

# Copy source code of isolated subworkspace
COPY --from=pruner /app/out/full/ .

# Env vars required to build the project
ARG DATABASE_URL
ARG RESEND_KEY
ARG BUILD_ENV

RUN turbo build:${BUILD_ENV} --filter=${PROJECT}
RUN rm -rf ./node_modules
RUN pnpm install --prod --frozen-lockfile

# Final image
FROM alpine AS runner

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
USER nodejs

WORKDIR /app
COPY --from=builder --chown=nodejs:nodejs /app .
WORKDIR /app/apps/api

ARG PORT=8080
ENV PORT=${PORT}

CMD ["node","dist/index.js"]
For some more context, this used to work when I only had a single service I wanted to deploy to railway and had the same config in root of the monorepo. But I want to add multiple services to railway with each having their own Dockerfile and thats where it is starting to break.
Brody
Brody8mo ago
can you confirm that the dockerfile above is being used to run the build?
Jay
JayOP8mo ago
how can I do so? the railway up command's first output is the 'prefix not found' message and then it quits before getting to docker build. Is there another way besides it to check it?
Jay
JayOP8mo ago
Sorry but the issue is that the build isn't even getting started since I'm deploying via the CLI only and the service isn't associated with a Git repo.
Brody
Brody8mo ago
I understand, but please open your build logs and if there are logs, download and send them
Jay
JayOP8mo ago
There aren't any build logs when I'm making these changes but here's the previous versions build logs if it helps
Brody
Brody8mo ago
okay can I see a screenshot of the error in the cli? and just to be double clear, does a build even show up in the service when it fails from the cli?
Jay
JayOP8mo ago
Here's the screenshot with some info redacted. And no the build doesn't even show up in the service when it fails from the CLI.
No description
Brody
Brody8mo ago
I understand redacting your terminal location, but the other stuff doesn't help, please send a new screenshot
Jay
JayOP8mo ago
would it be okay to share the service name and environment here? that's the only redacted thing besides the terminal location
Brody
Brody8mo ago
unless you've named it something offensive, I don't see any issues
Jay
JayOP8mo ago
okay, just a sec
Jay
JayOP8mo ago
No description
Brody
Brody8mo ago
specifying a path to the railway.json file isn't valid syntax as far as I know but you are only using it to set the path of the dockerfile right?
Jay
JayOP8mo ago
I found the usage of path from these docs here: https://docs.railway.app/reference/cli-api#up.
Railway Docs
CLI API Reference | Railway Docs
Documentation for Railway
Jay
JayOP8mo ago
Basically yeah the config just holds where the docker file is relative to the project
Brody
Brody8mo ago
sorry where do those docs point out that you can set the path to the railway.json file?
Jay
JayOP8mo ago
No description
Jay
JayOP8mo ago
or is it path to the directory to be deployed? sorry if I might have misunderstood it.
Solution
Brody
Brody8mo ago
yeah that's not a path to a railway.json file either way, there is a far better way to set the path to your dockerfile, delete the railway.json and set this service variable -
RAILWAY_DOCKERFILE_PATH=/docker/prod/api/Dockerfile.api
RAILWAY_DOCKERFILE_PATH=/docker/prod/api/Dockerfile.api
Jay
JayOP8mo ago
ah that's great! thanks @Brody.
Want results from more Discord servers?
Add your server