-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (55 loc) · 3.3 KB
/
Copy pathDockerfile
File metadata and controls
74 lines (55 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#######################################################################################################
# BASE RUNTIME
#######################################################################################################
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
WORKDIR /app
EXPOSE 8080
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
#######################################################################################################
# ANGULAR BUILD (CACHE OPTIMIZED)
#######################################################################################################
FROM node:18.15.0-alpine AS angular
WORKDIR /app/client
# 1. dependency layer (VERY STABLE)
COPY authorization/EventTriangle.Client/package.json ./
COPY authorization/EventTriangle.Client/package-lock.json ./
COPY authorization/EventTriangle.Client/angular.json ./
COPY authorization/EventTriangle.Client/tsconfig*.json ./
RUN npm ci
# 2. source layer (changes often)
COPY authorization/EventTriangle.Client/src ./src
COPY authorization/EventTriangle.Client/src/assets ./assets
COPY authorization/EventTriangle.Client/src/favicon.png ./src/favicon.png
RUN npm run build -- --configuration production --output-path dist/client
#######################################################################################################
# DOTNET RESTORE LAYER (MOST IMPORTANT CACHE LAYER)
#######################################################################################################
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS restore
WORKDIR /src
# ONLY csproj files first (MAXIMUM CACHE HIT RATE)
WORKDIR /src
COPY authorization/EventTriangleAPI.Authorization.BusinessLogic/*.csproj authorization/EventTriangleAPI.Authorization.BusinessLogic/
COPY authorization/EventTriangleAPI.Authorization.Domain/*.csproj authorization/EventTriangleAPI.Authorization.Domain/
COPY authorization/EventTriangleAPI.Authorization.Persistence/*.csproj authorization/EventTriangleAPI.Authorization.Persistence/
COPY authorization/EventTriangleAPI.Authorization.Presentation/*.csproj authorization/EventTriangleAPI.Authorization.Presentation/
COPY shared/EventTriangleAPI.Shared.Application/*.csproj shared/EventTriangleAPI.Shared.Application/
COPY shared/EventTriangleAPI.Shared.DTO/*.csproj shared/EventTriangleAPI.Shared.DTO/
RUN dotnet restore authorization/EventTriangleAPI.Authorization.Presentation/EventTriangleAPI.Authorization.Presentation.csproj
#######################################################################################################
# DOTNET BUILD + PUBLISH
#######################################################################################################
FROM restore AS build
# NOW source code (this invalidates only build, not restore)
COPY authorization/ authorization/
COPY shared/ shared/
WORKDIR /src/authorization/EventTriangleAPI.Authorization.Presentation
ARG VERSION
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false
#######################################################################################################
# FINAL IMAGE
#######################################################################################################
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
COPY --from=angular /app/client/dist/client wwwroot
ENTRYPOINT ["dotnet", "EventTriangleAPI.Authorization.Presentation.dll"]