I’ve been trying to host an angular app on nginx with docker during this past week but i couldnt get through it.
This is mi dockerfile:
your text
FROM node:latest as build your text
WORKDIR /usr/local/app your text
COPY ./ /usr/local/app/ your text
RUN npm install your text
RUN npm install -g @angular/cli your text
CMD [“npm”, “start”] your text
FROM nginx:latest your text
RUN rm /usr/share/nginx/html/* your text
COPY –from=build /usr/local/app/dist/prueba /usr/share/nginx/html your text
RUN rm etc/nginx/conf.d/default.conf your text
COPY default.conf /etc/nginx/conf.d/ your text
EXPOSE 80
this is my default.conf file:
your text
server {
your text
listen 80;
your text
server_name app;
your text
location / {
your text
proxy_pass http://localhost:4200;
your text
proxy_http_version 1.1;
your text
proxy_set_header Upgrade $http_upgrade;
your text
proxy_set_header Connection ‘upgrade’;
your text
proxy_set_header Host $host;
your text
proxy_cache_bypass $http_upgrade;
your text
}
}
user24718521 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.