When I run docker-compose, or docker build on my local linux machine from the home directory in the code repo, it runs fine. It docker doesn’t throw any errors on my linux box, with the exact same code cloned from the same repo. When I try to run the same docker commands on my local macOs mojave machine, it throws the error below after trying to run step 3/4 where it copies from /app/dist. I’ve tried running the docker commands with sudo, –no-cache, or removing previously created images, also tried running it with DOCKER_BUILDKIT=0, in case it was an optimization isue, all fail with same error. It seems like it’s trying to run the step out of sequence on my mac, but runs it in series on the linux box. I’ve run docker-compose from other repos on my mac with the same docker file, and it works without issue. If I just run “npm run serve” on my mac from the repo everything works fine too. Does anyone see what the issue might be and suggest how to fix?
# build stage FROM node:14-alpine as build-stage WORKDIR /app COPY package*.json ./ RUN npm install COPY . . RUN NODE_OPTIONS="--max-old-space-size=2048" npm run build # production stage FROM nginx:stable-alpine as production-stage COPY ./nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build-stage /app/dist /usr/share/nginx/html COPY --from=build-stage /app/.env /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]
output on mac:
$ docker-compose up [+] Building 99.0s (14/15) => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 32B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 34B 0.0s => [internal] load metadata for docker.io/library/nginx:stable-alpine 0.0s => [internal] load metadata for docker.io/library/node:14-alpine 0.0s => [build-stage 1/6] FROM docker.io/library/node:14-alpine 0.0s => [internal] load build context 0.1s => => transferring context: 33.87kB 0.1s => [production-stage 1/4] FROM docker.io/library/nginx:stable-alpine 0.0s => CACHED [production-stage 2/4] COPY ./nginx.conf /etc/nginx/conf.d/default.conf 0.0s => CACHED [build-stage 2/6] WORKDIR /app 0.0s => CACHED [build-stage 3/6] COPY package*.json ./ 0.0s => CACHED [build-stage 4/6] RUN npm install 0.0s => [build-stage 5/6] COPY . . 0.2s => [build-stage 6/6] RUN NODE_OPTIONS="--max-old-space-size=2048" npm run build 92.9s => ERROR [production-stage 3/4] COPY --from=build-stage /app/dist /usr/share/nginx/html 0.0s ------ > [production-stage 3/4] COPY --from=build-stage /app/dist /usr/share/nginx/html: ------ failed to solve: rpc error: code = Unknown desc = failed to compute cache key: "/app/dist" not found: not found