forked from Azure-Samples/helium-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (34 loc) · 1.04 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (34 loc) · 1.04 KB
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
### Build and Unit Test the App
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
### Optional: Set Proxy Variables
# ENV http_proxy {value}
# ENV https_proxy {value}
# ENV HTTP_PROXY {value}
# ENV HTTPS_PROXY {value}
# ENV no_proxy {value}
# ENV NO_PROXY {value}
### copy the source and unit tests code
COPY src /src
### Run the unit tests
WORKDIR /src/unit-tests
RUN dotnet test --logger:trx
### Build the release app
WORKDIR /src/app
RUN dotnet publish -c Release -o /app
###########################################################
### Build the runtime container
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
### if port is changed, also update value in Constants.cs
EXPOSE 4120
WORKDIR /app
### create a user
RUN groupadd -g 4120 helium && \
useradd -r -u 4120 -g helium helium && \
### dotnet needs a home directory for the secret store
mkdir -p /home/helium && \
chown -R helium:helium /home/helium
### run as helium user
USER helium
### copy the app
COPY --from=build /app .
ENTRYPOINT [ "dotnet", "helium.dll" ]