How to livereload nginx to serve Angular ssr on Docker

Viewed 303

How to add liveReload on angular13 and serve on nginx my default.conf and docker as below it work but miss the livereload, I used angular universal, on Angular 13 , the livereload setting is missing.

in Angular 8 server folder app.moudle.ts we can set liveReload:true, but in Angular 13 server folder it only generated main.ts

@Module({
  imports: [
    AngularUniversalModule.forRoot({
      viewsPath: join(process.cwd(), 'dist/browser'),

      bundle: require('../server/main'),
      liveReload: true
    })
  ]
})

nginx default.conf

server {
    listen       80;
    listen  [::]:80;
    server_name  domainname.com www.domainname.com;
    root   /usr/share/nginx/html;
    location / {
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
        gzip on;
        gzip_types application/javascript image/* text/css;
        gunzip on;
    }
   
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

Dockerfile


# STEP 1 build static website
FROM node:alpine as builder
RUN apk update && apk add --no-cache make git
# Create app directory
WORKDIR /app
# Create app/nginx directory and copy default.conf to it
WORKDIR /app/nginx
COPY nginx/conf.d/default.conf /app/nginx/
# Install app dependencies
COPY package.json /app/
RUN cd /app && npm set progress=false && npm install -f
# Copy project files into the docker image
COPY .  /app
RUN cd /app && npm run build:ssr

# STEP 2 build a small nginx image with static website
FROM nginx:alpine
# Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
# From 'builder' copy website to default nginx public folder
COPY --from=builder /app/dist/ctd-13scss/browser /usr/share/nginx/html
# From 'builder' copy default nginx configuration to the configuration conf.d folder of nginx
RUN rm -rf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
#expose
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

My question is how to add the livereload on Angular SSR. Any other way??

0 Answers
Related