DEV Community

Discussion on: Docker pipeline with Typescript + Express for production

Collapse
 
dmshvetsov profile image
Dmitry Shvetsov • Edited

Why do you need to use the copy command twice in the first stage?

COPY package*.json ./
COPY . .
Enter fullscreen mode Exit fullscreen mode
Collapse
 
dmshvetsov profile image
Dmitry Shvetsov • Edited

looks like you were trying to achieve cache usage. But then you need to swap npm Install and copy all other files to image. Like this:

## this is the stage one , also know as the build step

FROM node:12.17.0-alpine
WORKDIR /usr/src/app
COPY package*.json ./

# these two swapped
RUN npm install
COPY . .

RUN npm run build
Enter fullscreen mode Exit fullscreen mode