2
votes

I am attempting to build my angular app in Docker using the following Dockerfile:

FROM node:8.11.2-alpine as node

COPY package.json package-lock.json ./

RUN npm i && mkdir /app && cp -R ./node_modules ./app

WORKDIR /usr/src/app

COPY . .

RUN npm install

FROM nginx:1.13.3-alpine

RUN rm -rf /usr/share/nginx/html/*

COPY ./nginx.conf  /etc/nginx/conf.d/default.conf

COPY --from=node . /dist/usr/share/nginx/html

CMD ["nginx", "-g", "daemon off;"]

And the following nginx.conf file:

 server {
 listen 80;
 location / {
 root /usr/share/nginx/html/;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
 }
  }

The container builds just fine, but when I check my port for this container, I receive the "403 Forbidden" webpage instead of my Angular application.

When inspecting my container, I find the following error message: 2018/09/03 23:23:09 [error] 6#6: *1 directory index of "/usr/share/nginx/html/" is forbidden, client: 172.17.0.1, server: , request: "GET / HTTP/1.1", host: "localhost"

My index.html file exists inside a folder called 'src' , which is on the same directory as my DockerFile and nginx.conf file.

Could not having the Docker-Compose.yml file on the same directory as the DockerFile be causing the issue? Is there something I am missing?

The current container does not have a volume, as of yet.

Please help point me in the right direction.