-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
37 lines (24 loc) · 1.06 KB
/
Dockerfile
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
ARG PROJECT_NAME=OpenFTTH.SpecificationImporter
ARG DOTNET_VERSION=8.0
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build-env
# Renew the ARG argument for it to be available in this build context.
ARG PROJECT_NAME
WORKDIR /app
COPY ./*sln ./
COPY ./src/**/*.csproj ./src/${PROJECT_NAME}/
RUN dotnet restore --packages ./packages
COPY . ./
WORKDIR /app/src/${PROJECT_NAME}
RUN dotnet publish -c Release -o out --packages ./packages
# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:${DOTNET_VERSION}-jammy-amd64
# Renew the ARG argument for it to be available in this build context.
ARG PROJECT_NAME
# Cannot reference ARG in CMD, so we set it in ENV instead.
ENV EXECUTEABLE=${PROJECT_NAME}.dll
WORKDIR /app
COPY --from=build-env /app/src/${PROJECT_NAME}/out .
# Cannot use PROJECT_NAME here in environment, have to sadly write out the whole name.
# There is a hack where you can execute this as an environment variable, but then the process won't have id 1
# and signal are no longer received.
ENTRYPOINT ["dotnet", "OpenFTTH.SpecificationImporter.dll"]