2 years ago
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 I'm getting a prefix not found error. Indexed Compressed [====================] 100% prefix not found
Is there a way to know where the error is/how to fix it?
Thanks!
26 Replies
2 years ago
can you send your dockerfile and railway.json?
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"
}
}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"]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.
2 years ago
can you confirm that the dockerfile above is being used to run the build?
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?
2 years ago
full build logs please -
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.
2 years ago
I understand, but please open your build logs and if there are logs, download and send them
There aren't any build logs when I'm making these changes but here's the previous versions build logs if it helps
2 years ago
okay can I see a screenshot of the error in the cli?
2 years ago
and just to be double clear, does a build even show up in the service when it fails from the cli?
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.

2 years ago
I understand redacting your terminal location, but the other stuff doesn't help, please send a new screenshot
would it be okay to share the service name and environment here? that's the only redacted thing besides the terminal location
2 years ago
unless you've named it something offensive, I don't see any issues
2 years ago
specifying a path to the railway.json file isn't valid syntax as far as I know
2 years ago
but you are only using it to set the path of the dockerfile right?
I found the usage of path from these docs here: https://docs.railway.app/reference/cli-api#up.
Basically yeah the config just holds where the docker file is relative to the project
2 years ago
sorry where do those docs point out that you can set the path to the railway.json file?
or is it path to the directory to be deployed? sorry if I might have misunderstood it.
2 years 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
