-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdockerfile
More file actions
executable file
·35 lines (28 loc) · 935 Bytes
/
Copy pathdockerfile
File metadata and controls
executable file
·35 lines (28 loc) · 935 Bytes
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
# https://hub.docker.com/_/microsoft-dotnet-core
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /source
# copy csproj and restore as distinct layers
COPY src .
RUN dotnet restore
# copy everything else and build app
COPY src .
WORKDIR /source
RUN dotnet publish -c release -o /app --no-restore
# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS runtime
# Add bash
RUN apk update && apk add bash
# Add curl
RUN apk --no-cache add curl
# Copy the image built in previously
WORKDIR /app
COPY --from=build /app ./
# Add default user
RUN adduser 1001 --disabled-password
# Switches to a non-root user and changes the ownership of the /app folder"
RUN chown -R 1001 /app && chgrp -R 1001 /app
# Provide write access to the group
RUN chmod -R 777 /app
ENTRYPOINT ["dotnet", "dotnet-helloworld.dll"]
# Run container by default as user with id 1001 (default)
USER 1001