I am trying to build an angular app in a docker container. I successfully built a docker image and created a container from it, however when I run it I get /docker-entrypoint.sh: 32: exec: yarn: not found
. Here is my Dockerfile:
FROM node:13.3.0 AS compile-image
RUN npm install -g yarn
WORKDIR /opt/ng
COPY package.json yarn.lock angular.json ./
RUN yarn
RUN yarn install
COPY . ./
RUN node_modules/.bin/ng build --prod
FROM nginx
COPY --from=compile-image /opt/ng/dist/dashboard /usr/share/nginx/html
CMD ["yarn", "start"]
From what I understand Run yarn
fails but I am confused as to why since RUN npm install -g yarn
should install it. I am new to docker so sorry if I am jumping to wrong conclusions.
Please use nginx:1.18-alpine
and install yarn from package manager npm install -g yarn
FROM node:13.3.0 AS compile-image
RUN npm install -g yarn
WORKDIR /opt/ng
COPY package.json yarn.lock angular.json ./
RUN yarn
RUN yarn install
COPY . ./
RUN node_modules/.bin/ng build --prod
FROM nginx:1.18-alpine
RUN apk add yarn
COPY --from=compile-image /opt/ng/dist/dashboard /usr/share/nginx/html
CMD ["yarn", "start"]
Also, make sure that you change to your requirements.