a month ago
The backend build (Dockerfile) consistently fails with the same cache error,
regardless of the builder used, the Dockerfile content, recreating the service from scratch,
or explicitly disabling the cache with NO_CACHE=1. An identical build works
without errors on local Docker Desktop (Windows, WSL2 backend) every time.
Exact error
failed to solve: failed to compute cache key: failed to calculate checksum of ref
::: "/app": not found
Different hashes observed across different attempts:
ar916b9tu63jsekp12mo837io
htwozrsgh66c3537nnpm8l6vn
irn0giy6hxq8632zttsakh54i
What has been tested so far (all resulting in the same error):
Original Dockerfile (WORKDIR /app + apt-get install gcc).
Same Dockerfile, apt-get with retry flags (-o Acquire::Retries=3).
Complete removal of apt-get/gcc (bcrypt/cryptography
use pre-compiled wheels); error started occurring immediately after WORKDIR /app.
Pinning the base image tag (python:3.12-slim → python:3.12.8-slim, including
the specific digest); same error.
Removing WORKDIR entirely, using absolute paths (/app/...) in every
COPY/RUN; same error, though now failing at the last COPY instead of the first.
Renaming the entire path from /app to /srv/app; the Dockerfile no longer
contains any occurrence of the string /app, yet the error **still cites `"/app": not
found`** — indicating that the broken cache reference does not stem from the
Dockerfile content, but rather from something internal to the builder. 7. Delete the entire service and recreate it from scratch (new New → GitHub Repo, same
Root Directory/Builder configuration), new builder (builder-uxoeww), new
cache hash, same error.
Set the environment variable NO_CACHE=1 (officially documented); the log
explicitly shows "Caching Disabled - build performance will be
impacted", yet the FROM ... step still appears marked as cached and the build
fails with the identical error.
Current Dockerfile (reproduces the error)
dockerfile
FROM python:3.12.8-slim
COPY pyproject.toml /srv/app/
COPY alembic.ini /srv/app/
COPY alembic /srv/app/alembic
COPY app /srv/app/app
RUN pip install --no-cache-dir /srv/app
EXPOSE 8000
CMD ["sh", "-c", "cd /srv/app && alembic upgrade head && exec uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8000}"]
Confirmation that the issue is not the repository content
The same Dockerfile, at the same commit, builds successfully locally (Docker
Desktop, docker build . inside backend/) repeatedly, without any errors.
1 Replies
a month ago
The service's Dockerfile is at /backend/Dockerfile, but no Root Directory is configured, so the build context defaults to the repository root. The COPY instructions in the Dockerfile reference paths like pyproject.toml, alembic/, and app/ that exist inside the backend/ subdirectory, not at the repo root, which is why BuildKit cannot find them when computing checksums. Locally this works because you run docker build . from inside backend/, making backend/ the context. Set the Root Directory to backend in the service's Settings so the build context matches what the Dockerfile expects.
Status changed to Awaiting User Response Railway • about 1 month ago
Status changed to Solved krispimentel • about 1 month ago