W
Wasp3mo ago
LifeTaker

error on deploy /dist not found

, on the server side u get : [stage-4 1/2] FROM docker.io/pierrezemb/gostatic:latest@sha256:7e5718f98f2172f7c8dffd152ef0b203873ba889c8d838b2e730484fc71f6acd ✔ 0ms [stage-4 1/2] FROM docker.io/pierrezemb/gostatic:latest@sha256:7e5718f98f2172f7c8dffd152ef0b203873ba889c8d838b2e730484fc71f6acd [internal] load build context ✔ 13ms [stage-4 1/2] FROM docker.io/pierrezemb/gostatic:latest@sha256:7e5718f98f2172f7c8dffd152ef0b203873ba889c8d838b2e730484fc71f6acd ✔ 6ms ✕ [stage-4 2/2] COPY ./dist/ /srv/http/ failed to calculate checksum of ref ki4rmfvuev4mx1ktya54coh54::4w8m9v4xu023sy84jqzw0y8n8: "/dist": not found Dockerfile:73 ------------------- 71 | FROM pierrezemb/gostatic 72 | CMD [ "-fallback", "index.html" ] 73 | >>> COPY ./dist/ /srv/http/ 74 | 75 | ------------------- ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref ki4rmfvuev4mx1ktya54coh54::4w8m9v4xu023sy84jqzw0y8n8: "/dist": not found
3 Replies
kapa.ai
kapa.ai3mo ago
Hi @LifeTaker. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error you're seeing, COPY ./dist/ /srv/http/ ... "/dist": not found, means that the Docker build process cannot find the dist directory in the build context. This is a common issue when deploying the Wasp frontend, especially if you follow the manual deployment or Railway static hosting instructions. Why this happens: - The dist directory is not present in the build context when Docker runs, because you need to create it after building the frontend. - Each time you run wasp build, the .wasp/build/web-app directory (where you build the frontend) is recreated, so any previous dist directory or Dockerfile you placed there is removed. How to fix: 1. After running wasp build, go to .wasp/build/web-app. 2. Run npm install && REACT_APP_API_URL=<your_backend_url> npm run build to generate the build directory. 3. Copy the build directory to dist: cp -r build dist. 4. Make sure your Dockerfile and .dockerignore are present in .wasp/build/web-app. 5. Only then run your Docker build command from inside .wasp/build/web-app. Example steps:
wasp build
cd .wasp/build/web-app
npm install && REACT_APP_API_URL=<your_backend_url> npm run build
cp -r build dist
# Ensure Dockerfile and .dockerignore are here
docker build -t your-frontend-image .
wasp build
cd .wasp/build/web-app
npm install && REACT_APP_API_URL=<your_backend_url> npm run build
cp -r build dist
# Ensure Dockerfile and .dockerignore are here
docker build -t your-frontend-image .
If you skip the cp -r build dist step, or if you run Docker build from the wrong directory, Docker will not find the dist directory and you'll get the error you posted. Automating this:
The Wasp docs provide a deploy_client.sh script that automates these steps. You can use it to avoid manual mistakes. Make sure to run it from your project root and set the REACT_APP_API_URL environment variable as needed. See the full script and instructions in the docs for more details Deploying the Client (Railway). Summary:
The error is because the dist directory does not exist in your Docker build context. Make sure to create it (by copying build to dist) before running Docker build, and do all of this inside .wasp/build/web-app after running wasp build. This will resolve the error. If you need to repeat this process often, consider using the provided shell script to automate it, as every wasp build will remove the previous web-app directory and its contents, including dist and your Dockerfile if you placed them there manually. Deploying the Client (Railway) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @LifeTaker, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
LifeTaker
LifeTakerOP3mo ago
i actually use this to deploy the front : #!/usr/bin/env bash if [ -z "$REACT_APP_API_URL" ] then echo "REACT_APP_API_URL is not set" exit 1 fi wasp build cd .wasp/build/web-app npm install && REACT_APP_API_URL=$REACT_APP_API_URL npm run build cp -r build dist dockerfile_contents=$(cat <<EOF FROM pierrezemb/gostatic CMD [ "-fallback", "index.html" ] COPY ./dist/ /srv/http/ EOF ) dockerignore_contents=$(cat <<EOF node_modules/ EOF ) echo "$dockerfile_contents" > Dockerfile echo "$dockerignore_contents" > .dockerignore railway up. and the problem is from the server not the client and the problem is from the server not the client solved, a friend pushed a docker file in the solution
toticozeni
toticozeni3mo ago
Glad it got solved in the end :)

Did you find this page helpful?