Dockerfiles
Dotnet Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY ../engine/examples ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY /app/out .
ENTRYPOINT ["dotnet", "aspnetapp.dll"]
Angular Dockerfile
FROM node:16.14 as build
WORKDIR /dist/src/app
RUN npm install -g npm@8.18.0
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:1.21.3-alpine as final
COPY /dist/src/app/dist/playlists /usr/share/nginx/html
COPY /nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
Versions
The versions of the images for Node and the version of NPM installed match the version we've been doing development with.
The Nginx Configuration
server {
listen 80;
sendfile on;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 256;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /usr/share/nginx/html;
location ~ /index.html|.*\.json$ {
expires -1;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
}
location ~ .*\.css$|.*\.js$ {
add_header Cache-Control 'max-age=31449600'; # one year
}
location / {
try_files $uri $uri/ /index.html =404;
}
}
The .dockerignore
.git
.editorconfig
/.vscode/*
/node_modules
.gitignore