skip to Main Content

I follow to this reference to reduce my docker image. This is my Dockerfile:

FROM node:10 as builder
RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . .
RUN npm run build
RUN npm prune --production
RUN /usr/local/bin/node-prune
FROM node:10-alpine
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist /app/
EXPOSE 3000
CMD npm run start:dev

However when run docker build I got the error. Thank for your attention.

enter image description here

2

Answers


  1. Use below lines:

    RUN curl -sf https://gobinaries.com/tj/node-prune | sh
    
    RUN node-prune /usr/src/app/node_modules
    
    Login or Signup to reply.
  2. The curl command uses -s (--silent) which is suppressing a failure to get the install script since that URL is dead and node-prune no longer uses goreleaser.

    Adding the curl -S (--show-error) option will ensure errors are raised:

    $ curl -sSfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin
    curl: (6) Could not resolve host: install.goreleaser.com
    

    Install

    Official node-prune install instructions use gobinaries.com:

    RUN curl -sSf https://gobinaries.com/tj/node-prune | sh
    

    Alternatively since curl is not in base Docker Alpine images you can use wget:

    wget -O - https://gobinaries.com/tj/node-prune | sh
    

    The default install location is /usr/local/bin but can use PREFIX var to change that:

    curl -sSf https://gobinaries.com/tj/node-prune | PREFIX=/tmp/ sh
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search