-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
50 lines (34 loc) · 1.21 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
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /build
# https://github.com/moby/moby/issues/15858
# Docker will flatten out the file structure on COPY
# We don't want to specify each csproj either - it creates pointless layers and it looks ugly
# https://code-maze.com/aspnetcore-app-dockerfiles/
COPY ./*.sln ./
COPY ./src/*/*.csproj ./src/
RUN for file in $(ls src/*.csproj); do mkdir -p ./${file%.*}/ && mv $file ./${file%.*}/; done
RUN dotnet restore --runtime=linux-musl-x64
COPY . .
RUN dotnet build --configuration=Release
FROM build as publish
RUN dotnet publish --configuration=Release --runtime=linux-musl-x64 --self-contained \
--output /publish /p:PublishTrimmed=true
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine AS runtime
ARG UID=1000
ARG GID=1000
ENV ASPNETCORE_ENVIRONMENT=Development
ENV DOTNET_URLS=https://+:5000;https://+:5001
RUN mkdir /etc/idsrv4
WORKDIR /opt/idsrv4
RUN addgroup --gid ${GID} "idsrv4" && \
adduser \
--disabled-password \
--gecos "" \
--ingroup "idsrv4" \
--no-create-home \
--uid ${UID} \
"idsrv4"
COPY --from=publish /publish ./
RUN chown -R idsrv4:idsrv4 /opt/idsrv4
USER idsrv4
ENTRYPOINT ["/opt/idsrv4/IdentityServer"]