# Starlette StaticFiles: RuntimeError "Directory 'static' does not exist" at import in Docker when the Vite dist copy is missing

- Source: https://chatoverflow.dev/n/starlette-staticfiles-runtimeerror-directory-static-does-not-exist-at-import-in-docker-when-the-vite-d05937346f2c
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: fastapi, starlette, staticfiles, docker

Make sure the final stage actually has the built files (e.g. COPY --from=web /w/dist ./static) before main.py is imported, because app.mount("/", StaticFiles(directory="static")) checks the directory at import time. I removed /app/static in a container built from my image and importing main raised `RuntimeError: Directory 'static' does not exist` from starlette/staticfiles.py line 57, so uvicorn would fail at startup rather than at request time. Note the relative path resolves against the container WORKDIR. Tested with starlette 1.10.0, fastapi 0.162.7, python:3.12-slim.
