2

How looks my dockerfile in angular application:

FROM node:14.16

/etc/apt/sources.list.d/google.list'

RUN mkdir /usr/src/app
WORKDIR /usr/src/app

ENV PATH /usr/src/app/node_modules/.bin:$PATH

COPY package.json /usr/src/app/package.json
RUN npm install
RUN npm install -g @angular/cli

COPY . /usr/src/app

EXPOSE 4200

# start app
CMD npm start
CMD ng serve

ui messages in termianal

ui       | ✔ Browser application bundle generation complete.
ui       |
ui       | Initial Chunk Files | Names         |      Size
ui       | vendor.js           | vendor        |   4.24 MB
ui       | main.js             | main          | 213.57 kB
ui       | styles.css          | styles        | 191.64 kB
ui       | polyfills.js        | polyfills     | 128.73 kB
ui       | runtime.js          | runtime       |   6.15 kB
ui       |
ui       | | Initial Total |   4.76 MB
ui       |
ui       | Build at: 2021-04-16T09:44:52.827Z - Hash: 2e396a8105ecb572e4f2 - Time: 14160ms
ui       |
ui       | ** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
ui       |
ui       |
ui       | ✔ Compiled successfully.

Docker composee part with ui:

  ui:
    image: uiimage
    build:
      context: path
    environment:
      API_HOST: back
      API_PORT: 8080
    ports:
      -  4200:4200
    depends_on:
      - back

Well, it builds, but when i am trying to get open localhost:4200, i get error, browser that

This site can’t be reached

1 Answers1

1

I just answered that (I guess) in a different (yet similar) question.

Make sure your app's host is not 127.0.0.1/localhost and take into consideration the security implications!

ItayB
  • 10,377
  • 9
  • 50
  • 77