Cache mount ID is not prefixed with cache key
galer7
HOBBYOP

10 months ago

Hello, I want to know if I'm using the correct service id (I'm currently using the name)

Dockerfile:
```

ARG NODE_VERSION=20
ARG APP_DIRNAME=nextjs
ARG PROJECT=@formform/nextjs

# 1. Alpine image
FROM node:${NODE_VERSION}-alpine AS alpine

RUN apk update
RUN apk add --no-cache libc6-compat

# Setup pnpm and turbo on the alpine base
FROM alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm install -g corepack@latest
RUN corepack enable
RUN npm install turbo@2.3.3 --global

RUN pnpm config set store-dir ~/.pnpm-store

# 2. Prune projects
FROM base AS pruner
# https://stackoverflow.com/questions/49681984/how-to-get-version-value-of-package-json-inside-of-dockerfile
# RUN export VERSION=$(npm run version)

ARG PROJECT

# Set working directory
WORKDIR /app

# It might be the path to <ROOT> turborepo
COPY . .

# Generate a partial monorepo with a pruned lockfile for a target workspace.
# Assuming "@formform/nextjs" is the name entered in the project's package.json: { name: "@formform/nextjs" }
RUN turbo prune --scope=${PROJECT} --docker

# 3. Build the project
FROM base AS builder
ARG PROJECT

# Environment to skip .env validation on build
ENV CI=true

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 --mount=type=cache,id=s/web-/root/.pnpm-store,target=/root/.pnpm-store pnpm install --frozen-lockfile

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

RUN pnpm build --filter=${PROJECT}

# 4. Final image - runner stage to run the application
FROM base AS runner
ARG APP_DIRNAME

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

WORKDIR /app

ENV NODE_ENV=production

COPY --from=builder --chown=nodejs:nextjs /app .
WORKDIR /app/apps/${APP_DIRNAME}

ARG PORT=3000
ENV PORT=${PORT}

CMD ["pnpm", "start"]
```

railway.toml
```
[build]
dockerfilePath = "apps/nextjs/Dockerfile"
dockerContext = "."

[deploy]
preDeployCommand = "pnpm --filter @formform/db run migrate"
startCommand = "next start"
healthcheckPath = "/api/health"
port = 3000
```

Solved

2 Replies

galer7
HOBBYOP

10 months ago

attaching screenshot

Attachments


brody
EMPLOYEE

10 months ago

Hello,

The service ID is a UUIDv4 string that can be found in the URL when you have a service open -

/service/<serviceId>

Best,

Brody


Status changed to Awaiting User Response Railway 10 months ago


Status changed to Solved galer7 10 months ago


Loading...