Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot build a Dockerfile –path not found error

I am trying to build a docker file and I am getting an error "failed to compute cache key: "/source" not found: not found"

This is my directory structure

myapp

 - deployment

   -- Dockerfile

 
 - source

   -- public

   -- view

   -- app.js

package.json

package-lock.json

This is my docker file

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

FROM node:18-alpine

ENV NODE_ENV=production

WORKDIR /usr/src/app

COPY ../package*.json /usr/src/app/

RUN npm install --production --silent 

COPY ../source /usr/src/app/dist

ENV PORT 3001

EXPOSE ${PORT}

ENV SERVICE_VERSION 1.0.2

ENV NODE-ENV=production

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

>Solution :

stay in root of your project(myapp directory) and use --file instead of using ../ for your files.
so you will run your build command like this:

cd myapp
docker build -t image:tag --file deployment/Dockerfile .

you also need to change your Dockerfile to:

FROM node:18-alpine

ENV NODE_ENV=production

WORKDIR /usr/src/app

COPY package*.json /usr/src/app/

RUN npm install --production --silent 

COPY source /usr/src/app/dist

ENV PORT 3001

EXPOSE ${PORT}

ENV SERVICE_VERSION 1.0.2

# You have typo in NODE_ENV ( used - instead of _ )
#ENV NODE-ENV=production

ENV NODE_ENV=production

CMD ["node", "dist/app.js"]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading