Deploy your app in a container
For our deployments we use Kubernetes or OpenShift. Everything has to be in a container and be part of a develop / build / deploy pipeline.
In a previous post I already explained how to deploy an Angular app in a Java artifact using a maven structure.
When we want to completely separate the frontend from the backend we have to create multiple containers.
In this example we create a Docker container that contains an Angular application (http://javademo.io).
The docker container
FROM nginx COPY nginx.conf /etc/nginx/nginx.conf COPY ./src/dist /usr/share/nginx/html
Some advantages of a web server:
- own rules and filters
- resolution of the html urls (404 error after refresh)
Our docker consists in only 3 lines.
FROM nginx we use the nginx Docker image
COPY nginx.conf /etc/nginx/nginx.conf we copy our own nginx configuration.
COPY ./src/dist /usr/share/nginx/html we copy the prod build of our Angular app.
We have a custom configuration for nginx
This configuration creates a web server that listen port 80, makes a compressions of the response and redirect to the main page if an URL is not found.