-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (46 loc) · 1.45 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
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
ARG VERSION
ARG REVISION
# Set default shell
SHELL ["/bin/bash", "-c"]
# Install Node.js
RUN apt-get update && \
apt-get install -y gnupg && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
NODE_MAJOR=20 && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
# Install latest DocFX release
RUN dotnet tool update -g docfx
# Restore dependencies and tools
COPY src/EWS.csproj .
RUN dotnet restore "EWS.csproj"
# Set environment variables
ENV PUBLISH_DIR=/app/publish
ENV GENERATE_SOURCEMAP=false
# Create optimized production build
COPY src/ .
RUN dotnet publish "EWS.csproj" \
-c Release \
-p:VersionPrefix=${VERSION} \
-p:SourceRevisionId=${REVISION} \
-o ${PUBLISH_DIR}
# Build documentation
COPY docs/ ./docs/
RUN ~/.dotnet/tools/docfx build -o ${PUBLISH_DIR}/wwwroot/help docs/docfx.json
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
ENV HOME=/app
ENV TZ=Europe/Zurich
ENV ASPNETCORE_ENVIRONMENT=Production
WORKDIR ${HOME}
EXPOSE 8080
# Set default locale
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
COPY --from=build /app/publish $HOME
USER $APP_UID
ENTRYPOINT ["dotnet", "EWS.dll"]