2

I am run a single Node.js script like so: docker run -it --rm -u node --name build_container -v $(pwd):/home/node/app -w "/home/node/app" node:lts bash -c "yarn install --no-cache --frozen-lockfile".

However, the script log shows the displays info No lockfile found, and, what is even weirder, a message that says a package-lock.json was found. However, the work directory has no package-lock.

enter image description here

Are there any ideas what could be the issue?

CoryCoolguy
  • 1,065
  • 8
  • 18
Fernando Souza
  • 795
  • 8
  • 11

1 Answers1

-1

I would suggest using your own Dockerfile to build your image - and then run it inside the build - like so:

Dockerfile

FROM node:12-alpine

# Create work directory
RUN mkdir -p /express
WORKDIR /express

# Bundle app sources
COPY . .

# Build app
RUN yarn install --prod --frozen-lockfile && yarn run build

EXPOSE 3000

# Set default NODE_ENV to production
ENV NODE_ENV production
ENTRYPOINT [ "yarn", "start" ]

.dockerignore

node_modules
build
dist
config
docs
*.log
.git
.vscode

And then build the image: docker build -t <your image name> -f <Dockerfile (if omitted uses local folder .Dockerfile> <path to code your code>

Once built, run it as you would a normal image - as everything is already in.

Shahar Hadas
  • 2,641
  • 1
  • 27
  • 29