How to build a Docker image that serves Angular application (without Universal).
Build your application to the dist/app
directory, then copy it into an image.
FROM nginx:latest
COPY ./etc/nginx.conf /etc/nginx/nginx.conf
ADD ./dist/app /var/app/
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
# Basic Settings
sendfile off;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging Settings
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server {
listen 80 default_server;
charset utf-8;
set $root_path '/var/app';
root $root_path;
location ~* ^.*$ {
root $root_path;
try_files $uri $1/index.html =404;
}
}
}
Build image:
$ docker build -t IMAGE_NAME .
After that you can use the image and load your application from the 80 port.