I want to deploy my angular app inside a docker container but I'm unable to route my app inside the container. I tried to follow the official angular doc guidlines. You can have a look of what I did here:
Dockerfile:
FROM node:latest as build
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build --prod
# Stage 1: serve app with nginx server
FROM nginx:latest
COPY --from=build /app/dist/pointeuse /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
Nginx configuration file
server {
listen [::]:80;
sendfile on;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 256;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html =404;
}
}
Pointeuse folder (my app)
3rdpartylicenses.txt polyfills-es2015.690002c25ea8557bb4b0.js
assets polyfills-es5.9e286f6d9247438cbb02.js
favicon.ico runtime-es2015.1eba213af0b233498d9d.js
index.html runtime-es5.1eba213af0b233498d9d.js
main-es2015.df94aaa439cec2ec9350.js styles.4333e01ba2bdd733ca4e.css
main-es5.df94aaa439cec2ec9350.js
I needed to add
listen 80
in the nginx configuration file. Because IPv6 is not enabled by default in docker.