-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
39 lines (29 loc) · 907 Bytes
/
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
FROM mcr.microsoft.com/dotnet/sdk:6.0 as build
WORKDIR /src/Dotnet.Api
COPY Dotnet.Api/Dotnet.Api .
RUN dotnet restore -r linux-musl-x64 "Dotnet.Api.csproj"
RUN dotnet publish ./Dotnet.Api.csproj \
-c Release \
-o /app/publish \
-r linux-musl-x64 \
--no-restore \
--self-contained true \
/p:PublishTrimmed=true \
/p:TrimMode=Link \
/p:PublishSingleFile=true
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine AS publish
# Run as non-root
RUN adduser --disabled-password \
--home /app \
--gecos '' dotnetuser && chown -R dotnetuser /app
# Upgrade musl in case of any vulnerabilities
RUN apk upgrade musl
# Required for Time Zone database lookups
RUN apk add --no-cache tzdata
USER dotnetuser
WORKDIR /app
# Copy files and folders
EXPOSE 5000
ENV ASPNETCORE_URLS=http://+:5000
COPY --chown=dotnetuser --from=build /app/publish .
ENTRYPOINT "./Dotnet.Api"