29 lines
941 B
Docker
29 lines
941 B
Docker
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
|
ARG TARGETARCH
|
|
WORKDIR /source
|
|
|
|
# copy csproj and restore as distinct layers
|
|
#COPY *.csproj .
|
|
#RUN dotnet restore -a $TARGETARCH
|
|
#RUN dotnet restore -r linux-$TARGETARCH
|
|
|
|
# copy and publish app and libraries
|
|
COPY . .
|
|
#RUN dotnet publish TodoApi.csproj -c Release -a $TARGETARCH --self-contained false --no-restore -o /app
|
|
RUN dotnet publish TodoApi.csproj -r linux-$TARGETARCH --self-contained false -o /app
|
|
|
|
# Build database migration tool
|
|
RUN dotnet tool install --global dotnet-ef --version 8.0.0
|
|
ENV PATH="${PATH}:/root/.dotnet/tools"
|
|
RUN dotnet ef migrations bundle --self-contained -r linux-$TARGETARCH -o /app/migratedb
|
|
#RUN dotnet ef migrations bundle --no-build -o /app/migratedb --verbose
|
|
|
|
# final stage/image
|
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
|
WORKDIR /app
|
|
COPY --from=build /app .
|
|
|
|
EXPOSE 8080
|
|
|
|
ENV DOTNET_EnableDiagnostics=0
|
|
ENTRYPOINT ["./TodoApi"] |