-
Notifications
You must be signed in to change notification settings - Fork 321
/
Dockerfile
59 lines (41 loc) · 1.84 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Usage: docker buildx build --platform linux/amd64 .
# Usage: docker buildx build --platform linux/arm64 .
# See https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md#full-tag-listing
ARG BUILD_IMAGE_TAG="8.0-jammy"
ARG RUN_IMAGE_TAG="8.0-alpine"
#########################################################################
# .NET build
#########################################################################
FROM mcr.microsoft.com/dotnet/sdk:$BUILD_IMAGE_TAG AS build
ARG BUILD_CONFIGURATION=Release
COPY . /src/
WORKDIR "/src/service/Service"
RUN dotnet build Service.csproj -c $BUILD_CONFIGURATION -o /app/build /p:RepoRoot=/src/
RUN dotnet publish "./Service.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false /p:RepoRoot=/src/
#########################################################################
# prepare final content
#########################################################################
FROM mcr.microsoft.com/dotnet/aspnet:$RUN_IMAGE_TAG AS base
# Non-root user that will run the service
ARG USER=km
WORKDIR /app
RUN \
# Create user
#Debian: useradd --create-home --user-group $USER --shell /bin/bash && \
adduser -D -h /app -s /bin/sh $USER && \
# Allow user to access the build
chown -R $USER.$USER /app
COPY --from=build --chown=km:km --chmod=0550 /app/publish .
#########################################################################
# runtime
#########################################################################
LABEL org.opencontainers.image.authors="Devis Lucato, https://github.com/dluc"
# Define current user
USER $USER
# Used by .NET and KM to load appsettings.Production.json
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://+:9001
ENV ASPNETCORE_HTTP_PORTS=9001
EXPOSE 9001
# Define executable
ENTRYPOINT ["dotnet", "Microsoft.KernelMemory.ServiceAssembly.dll"]