-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (48 loc) · 2.29 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (48 loc) · 2.29 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
# syntax=docker/dockerfile:1-labs
################################################################################
# restore
################################################################################
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS restore
COPY *.sln* .
COPY --parents */*.csproj .
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet restore
################################################################################
# build + tests
################################################################################
FROM restore AS build
ARG BUILD_CONFIGURATION
COPY . .
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet build -c ${BUILD_CONFIGURATION} --no-restore --sc false
RUN dotnet test -c ${BUILD_CONFIGURATION} --no-restore --no-build\
--logger "trx;LogFileName=test-results.trx"
################################################################################
# migrator-publish
################################################################################
################################################################################
# migrator-final
################################################################################
################################################################################
# api-publish
################################################################################
FROM build AS api-publish
ARG BUILD_CONFIGURATION
ARG SRC_DIR
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet publish API -o ${SRC_DIR}/API -c ${BUILD_CONFIGURATION} \
--no-restore --no-build -p:UseAppHost=false
################################################################################
# api-final
################################################################################
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS api-final
USER $APP_UID
ARG SRC_DIR
WORKDIR ${SRC_DIR}
COPY --from=api-publish --chown=${APP_UID}:${APP_UID} ${SRC_DIR}/API ./
ENTRYPOINT ["dotnet", "API.dll"]
################################################################################
# api-dev
################################################################################
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS api-dev
ENTRYPOINT ["dotnet", "watch", "--project", "API", "--no-launch-profile"]