Friday, November 15, 2019

Build producetion app angular in docker

Welcome to our blog, today I will introduce you Build producetion app angular in docker the simplest way, to accomplish this problem you should do each of the steps below.
Build producetion app angular in docker

Step 1. Create new app in angular
ng new DemoPush
Step 2. Creata a file dockerfile in angular
FROM node:stretch-slim
## Install http-server
RUN npm install -g superstatic
WORKDIR /app
COPY /dist/demopush .
# EXPOSE $PORT
ENTRYPOINT superstatic --host 0.0.0.0 --port 80 --gzip $USE_GZIP --debug $LOG_REQUESTS
# CMD ["superstatic" ,"--port 80"]
Step 3. Create a file docker-compore.yml
version: '2.3'
services:
  angular:
    hostname: 10.199.15.93
    container_name: angular-container
    build: .
    ports:
      - 80:80
Step 4. Create a file nginx.conf
server {
  listen 80;
  location / {
    root /usr/share/nginx/html;
    index index.html index.htm;
    try_files $uri $uri/ /index.html =404;
  }
Now we build the docker in angular as follows:
ng build --prod --base-href /sample/
after we build app in angular
docker build -t sample .
Run below:
docker run  -p 80:80 --name myapp sample 

No comments:

Post a Comment