New attempt
This commit is contained in:
38
Dockerfile
38
Dockerfile
@@ -1,21 +1,35 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
||||
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 5000
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0-bullseye-slim-amd64 AS build
|
||||
WORKDIR /src
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
||||
ARG TARGETARCH
|
||||
ARG TARGETOS
|
||||
RUN arch=$TARGETARCH \
|
||||
&& if [ "$arch" = "amd64" ]; then arch="x64"; fi \
|
||||
&& echo $TARGETOS-$arch > /tmp/rid
|
||||
ARG BUILDPLATFORM
|
||||
|
||||
WORKDIR /src
|
||||
COPY *.csproj .
|
||||
RUN dotnet restore -r $(cat /tmp/rid)
|
||||
RUN dotnet restore -r
|
||||
COPY . .
|
||||
WORKDIR "/src"
|
||||
RUN dotnet publish -c Release -o /app -r $(cat /tmp/rid) --self-contained false --no-restore
|
||||
RUN dotnet build -c Release -o /app/build -a $TARGETARCH
|
||||
|
||||
FROM base AS final
|
||||
FROM build AS publish
|
||||
RUN dotnet public -c Release -o /app/publish \
|
||||
--self-contained true \
|
||||
/p:PublishTrimmed=true \
|
||||
/p:PublishSingleFile=true \
|
||||
-a $TARGETARCH
|
||||
|
||||
FROM --platform=$BUILDPLATFORM base AS final
|
||||
ARG TARGETARCH
|
||||
ARG BUILDPLATFORM
|
||||
|
||||
RUN adduser --disabled-password \
|
||||
--home /app \
|
||||
--gecos '' dotnetuser && chown -R dotnetuser /app
|
||||
|
||||
USER dotnetuser
|
||||
WORKDIR /app
|
||||
COPY --from=build /app .
|
||||
ENTRYPOINT ["dotnet", "MauMau-Server.dll"]
|
||||
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["./MauMau-Server"]
|
||||
Reference in New Issue
Block a user