R
Railway15mo ago
rob

Cache mount ID is not prefixed with cache key when deploying test instance

Hello all, today I tried to boot up my test instance but every attempt at doing so lead the deploys to fail immediately with the error Cache mount ID is not prefixed with cache key (no further information are present in build logs). The Dockerfile used to build the project is the following (as copied from GitHub https://github.com/Stickerifier/Stickerify/blob/migrate-to-telegram-bot-api/Dockerfile):
FROM gradle:8.0-jdk19 AS builder
WORKDIR /app
COPY settings.gradle build.gradle ./
COPY gradle/libs.versions.toml ./gradle/
RUN \
--mount=type=cache,id=cache-dependencies,target=/home/gradle/.gradle/caches \
gradle dependencies --no-daemon
COPY . .
RUN gradle shadowJar --no-daemon

FROM eclipse-temurin:19 AS bot
RUN \
--mount=type=cache,id=cache-apt,target=/var/cache/apt \
apt-get -y update && apt-get -y upgrade && \
apt-get install -y --no-install-recommends ffmpeg
ARG STICKERIFY_TOKEN
ENV STICKERIFY_TOKEN $STICKERIFY_TOKEN
WORKDIR /app
COPY --from=builder /app/build/libs .
CMD ["java", "-jar", "Stickerify-shadow.jar"]
FROM gradle:8.0-jdk19 AS builder
WORKDIR /app
COPY settings.gradle build.gradle ./
COPY gradle/libs.versions.toml ./gradle/
RUN \
--mount=type=cache,id=cache-dependencies,target=/home/gradle/.gradle/caches \
gradle dependencies --no-daemon
COPY . .
RUN gradle shadowJar --no-daemon

FROM eclipse-temurin:19 AS bot
RUN \
--mount=type=cache,id=cache-apt,target=/var/cache/apt \
apt-get -y update && apt-get -y upgrade && \
apt-get install -y --no-install-recommends ffmpeg
ARG STICKERIFY_TOKEN
ENV STICKERIFY_TOKEN $STICKERIFY_TOKEN
WORKDIR /app
COPY --from=builder /app/build/libs .
CMD ["java", "-jar", "Stickerify-shadow.jar"]
It's also worth keeping in mind I configured the shared environment variable (used both by Production and Test) RAILWAY_DOCKERFILE_PATH with value Railway.dockerfile where I'd execute the following instructions:
FROM rob93c/stickerify
ARG STICKERIFY_TOKEN
ENV STICKERIFY_TOKEN $STICKERIFY_TOKEN
FROM rob93c/stickerify
ARG STICKERIFY_TOKEN
ENV STICKERIFY_TOKEN $STICKERIFY_TOKEN
This failure seems strange to me since everything works properly in my production environment. The project ID is f6d25e17-9bb2-457f-8ce2-e55b5ce1dcd8
13 Replies
Percy
Percy15mo ago
Project ID: f6d25e17-9bb2-457f-8ce2-e55b5ce1dcd8,8c4e4e87-7cf3-4ab2-9ec2-b6cc41db7b5b
rob
rob14mo ago
Is there any news about this? I just tried and it's still happening in my test environment To me it's very strange since Railway on that instance should be picking Railway.dockerfile (but no logs are shown in the build view, apart from the error I reported) Also, if I don't change my Dockerfile to add ,id=cache-dependencies and ,id=cache-apt I get the error Cache mounts MUST be in the format --mount=type=cache,id=<cache-id>
Brody
Brody14mo ago
okay so I have asked jr myself about this, the id needs to be prefixed with your service id, anything else won't work at the moment. so when it gives you that error, this is the format it wants for the id.. id=s/<service-id>-/root/.gradle
rob
rob14mo ago
I must say I'm confused by that but I see it works Do you think this it a bug at some level on the tools I'm using or is it simply a wrong Dockerfile configuration on my side?
Brody
Brody14mo ago
its just how railway wants the cache id formatted
jetpackjoe
jetpackjoe12mo ago
I hit this error too. What exactly is the format it wants? I have the following line in my Dockerfile and still got the error "Cache mount ID is not prefixed with cache key"
RUN --mount=type=cache,id=cache-pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN --mount=type=cache,id=cache-pnpm,target=/pnpm/store pnpm install --frozen-lockfile
jetpackjoe
jetpackjoe12mo ago
sorry, what is <service-id> here?
Brody
Brody12mo ago
your railway service id
jetpackjoe
jetpackjoe12mo ago
RUN --mount=type=cache,id=c23befe0-e87a-42f6-a6d5-c4a5c738679d-cache-pnpm,target=/pnpm/store pnpm install --frozen-lockfile still fails with the same error its fine, I don't need to cache there.
jetpackjoe
jetpackjoe12mo ago
I don't understand what format it wants. I have it prefixed with the service id.
Brody
Brody12mo ago
the format is shown in that message