I'm trying to containerize my Angular app using Docker.
I'm pretty new to Docker, hence I followed a tutorial, adding a Dockerfile
with the following content:
FROM node:13.3.0 AS compile-image
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm install
ENV PATH="./node_modules/.bin:$PATH"
COPY . ./
RUN ng build --prod
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=compile-image /opt/ng/dist/myproject /usr/share/nginx/html
But somehow it fails at Step 9/10 returning following error:
COPY failed: stat /var/lib/docker/tmp/docker-builder934487773/nginx.conf: no such file or directory
Modified the Dockerfile, you can start from this and update as required.
FROM node:13.3.0 AS compile-image
COPY package.json package-lock.json ./
RUN npm install && mkdir /angular-app
ENV PATH="./node_modules/.bin:$PATH"
WORKDIR /angular-app
COPY . .
RUN ng build --prod
FROM nginx
RUN rm -rf /usr/share/nginx/html/*
COPY --from=compile-image /angular-app/dist /usr/share/nginx/html
You can refer to nginx.conf documentation from http://nginx.org/en/docs/beginners_guide.html & if it is needed create the conf file and add a COPY statement in dockerfile
Having the docker-compose and the dockerfile in the same folder might work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.