Развернуть приложение angular в Openshift 4 - PullRequest
0 голосов
/ 26 февраля 2020

Я пытаюсь развернуть приложение angular в openshift. Все, что у меня есть в проекте - это angular проект с докер-файлом, который запускает ng build --prod и npm запускает запуск приложения. Проблема в том, что я вижу, что он работает внутри локального хоста, отличного от хоста openshift. Из-за этого я получаю «Приложение не доступно» в браузере при нажатии на URL openshift. Пожалуйста, пожелайте исправить это.

Ниже находится журнал от Pod

exmaple-ui@0.0.0 start /ng-app
> ng serve --host 0.0.0.0 --port 4200

WARNING: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.

Binding this server to an open connection can result in compromising your application or
computer. Using a different host than the one passed to the "--host" flag might result in
websocket connection issues. You might need to use "--disableHostCheck" if that's the
case.
** Angular Live Development Server is listening on 0.0.0.0:4200, open your browser on http://localhost:4200/ **

Date: 2020-02-26T06:08:37.782Z
Hash: dc7eff7d77f7a5fbef4e
Time: 81197ms
chunk {es2015-polyfills} es2015-polyfills.js, es2015-polyfills.js.map (es2015-polyfills) 285 kB [initial] [rendered]
chunk {main} main.js, main.js.map (main) 97.8 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 236 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 3.61 MB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 7.4 MB [initial] [rendered]
[34mℹ[39m [90m「wdm」[39m: Compiled successfully.

1 Ответ

0 голосов
/ 02 марта 2020

Я бы предложил ..

  1. Сборка angular приложения локально или на любом CI (Jenkins et c), ng build --prod
  2. Использование nginx образ для развертывания и размещения содержимого c, nginx config.

2.1 Docker image

FROM nginx:1.13.3-alpine
## Copy our nginx config
COPY nginx/ /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/* && chmod -R 777 /var/log/nginx /var/cache/nginx/ && chmod -R 777 /etc/nginx/* && chmod -R 777 /var/run/ && chmod -R 777 /usr/share/nginx/
## copy over the artifacts in dist folder to default nginx public folder
COPY dist/MyApp /usr/share/nginx/html
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
...