-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
55 lines (46 loc) · 1.69 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
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 443
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
ARG TARGETARCH
ARG BUILDPLATFORM
# Install NativeAOT build prerequisites
#RUN apt-get update \
# && apt-get install -y --no-install-recommends \
# clang zlib1g-dev
WORKDIR /src
COPY ["src/Elastic.Markdown/Elastic.Markdown.csproj", "src/Elastic.Markdown/Elastic.Markdown.csproj"]
COPY ["src/docs-builder/docs-builder.csproj", "src/docs-builder/docs-builder.csproj"]
COPY ["docs/docs.csproj", "docs/docs.csproj"]
COPY "build/build.csproj" "build/build.csproj"
COPY ".github/.github.csproj" ".github/.github.csproj"
COPY "tests/Elastic.Markdown.Tests/Elastic.Markdown.Tests.csproj" "tests/Elastic.Markdown.Tests/Elastic.Markdown.Tests.csproj"
COPY ["docs-builder.sln", "docs-builder.sln"]
RUN dotnet restore "docs-builder.sln"
COPY . .
WORKDIR "/src"
RUN dotnet build "src/docs-builder/docs-builder.csproj" -c Release -o /app/build -a $TARGETARCH
FROM build AS publish
RUN dotnet publish "src/docs-builder/docs-builder.csproj" -c Release -o /app/publish \
#--runtime alpine-x64 \
--self-contained true \
/p:PublishTrimmed=true \
/p:PublishSingleFile=true \
/p:PublishAot=false \
-a $TARGETARCH
FROM --platform=$BUILDPLATFORM base AS final
ARG TARGETARCH
ARG BUILDPLATFORM
# create a new user and change directory ownership
RUN adduser --disabled-password \
--home /app \
--gecos '' dotnetuser && chown -R dotnetuser /app
# impersonate into the new user
USER dotnetuser
WORKDIR /app
COPY NOTICE.txt .
COPY LICENSE.txt .
COPY --from=publish /app/publish .
CMD chmod +x docs-builder
ENTRYPOINT ["./docs-builder"]