2

I was attempting to dockerize my node project backed by AWS lambda, But when I actually run the file, it gives me the following error.

 => CACHED [build 3/6] COPY . .                                                                                                         0.0s
 => CACHED [build 4/6] RUN npm install                                                                                                  0.0s
 => CACHED [build 5/6] RUN npm run build:ts                                                                                             0.0s
 => CACHED [build 6/6] RUN npm prune --production                                                                                       0.0s
 => ERROR [serve 3/6] COPY --from=build /usr/src/app/dist/ /usr/src/app/dist/                                                           0.0s
 => ERROR [serve 4/6] COPY --from=build /usr/src/app/views/ /usr/src/app/views/                                                         0.0s
 => ERROR [serve 5/6] COPY --from=build /usr/src/app/node_modules/ /usr/src/app/node_modules/                                           0.0s
 => ERROR [serve 6/6] COPY --from=build /usr/src/app/package.json /usr/src/app/package.json                                             0.0s
------
 > [serve 3/6] COPY --from=build /usr/src/app/dist/ /usr/src/app/dist/:
------
------
 > [serve 4/6] COPY --from=build /usr/src/app/views/ /usr/src/app/views/:
------
------
 > [serve 5/6] COPY --from=build /usr/src/app/node_modules/ /usr/src/app/node_modules/:
------
------
 > [serve 6/6] COPY --from=build /usr/src/app/package.json /usr/src/app/package.json:
------
failed to compute cache key: failed to walk /var/lib/docker/tmp/buildkit-mount486916116/usr/src/app: lstat /var/lib/docker/tmp/buildkit-mount486916116/usr/src/app: no such file or directory

here is the code for my docker file

FROM node:12 as build

WORKDIR /usr/scr/app
COPY . .
RUN npm install
RUN npm run build:ts
RUN npm prune --production

FROM node:12 as serve

WORKDIR /usr/src/app
COPY --from=build "/usr/src/app/dist/" "/usr/src/app/dist/"
COPY --from=build "/usr/src/app/views/" "/usr/src/app/views/"
COPY --from=build "/usr/src/app/node_modules/" "/usr/src/app/node_modules/"
COPY --from=build "/usr/src/app/package.json" "/usr/src/app/package.json"

EXPOSE 8080
CMD ["node", "dist/app.js"]

as well as the package.json under the same package dockerfile resides

{
    "name": "express-webserver",
    "version": "1.0.0",
    "description": "",
    "main": "",
    "scripts": {
        "build:ts": "tsc",
        "docker:build": "docker build -t dtuckernet/poc-webserver .",
        "docker:run" : "docker run -p 8080:8080 -e SERVER_PORT=8080 -e API_BASE=https://id6ualpxkc.execute-api.us-east-1.amazonaws.com/ -d dtuckernet/poc-webserver"
    },
    "author": "",
    "license": "ISC",
    "dependencies": {
        "axios": "^0.19.0",
        "ejs": "^3.1.8",
        "express": "^4.18.1"
    },
    "devDependencies": {
        "@types/express": "^4.17.13",
        "@types/node": "^17.0.35",
        "typescript": "^4.6.4"
    }
}

The folder structure of my code looks like:

enter image description here

Can anyone help me to see what happened? I can include github link for this project as well if the above info is not adequate. https://github.com/jaydenyen123/typescript-cdk/tree/master/containers/webserver

1 Answer 1

4

You've misspelled src in the first WORKDIR statement in the Dockerfile.

WORKDIR /usr/scr/app
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.