techgarage-ir.MTWireGuard/Dockerfile

52 lines
1.4 KiB
Text
Raw Normal View History

2024-09-10 13:53:15 +03:30
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish
WORKDIR /src
2024-09-10 00:58:14 +03:30
# Define platform
ARG TARGETPLATFORM
2024-09-10 10:18:30 +03:30
ARG RID
# Set the RID based on the TARGETPLATFORM
2024-09-10 00:58:14 +03:30
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
2024-09-10 10:18:30 +03:30
echo "Setting RID for linux/amd64" ; RID=linux-x64 ; \
2024-09-10 00:58:14 +03:30
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
2024-09-10 10:18:30 +03:30
echo "Setting RID for linux/arm64" ; RID=linux-arm64 ; \
else \
echo "Unsupported platform $TARGETPLATFORM" ; exit 1 ; \
fi && \
echo "Using RID: $RID"
2024-09-10 00:58:14 +03:30
# Copy project files
COPY *.sln .
COPY UI/*.csproj ./UI/
COPY Application/*.csproj ./Application/
COPY MikrotikAPI/*.csproj ./MikrotikAPI/
2024-07-21 00:47:33 +03:30
COPY Serilog.Ui.SqliteProvider/*.csproj ./Serilog.Ui.SqliteProvider/
# Restore packages
2024-09-10 10:29:19 +03:30
RUN dotnet restore --runtime "$RID"
# Copy other files
COPY UI/. ./UI/
COPY Application/. ./Application/
COPY MikrotikAPI/. ./MikrotikAPI/
2024-07-21 00:47:33 +03:30
COPY Serilog.Ui.SqliteProvider/. ./Serilog.Ui.SqliteProvider/
# Publish project
RUN dotnet publish "./UI/MTWireGuard.csproj" -c Release \
-o /app/publish \
--no-restore \
2024-09-10 11:36:41 +03:30
--runtime "$RID" \
2024-09-10 14:51:57 +03:30
--self-contained true \
/p:WarningLevel=0 \
/p:PublishTrimmed=true
# Create final image and run project
2024-09-10 13:53:15 +03:30
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled-extra AS final
2024-07-21 00:47:33 +03:30
ENV TZ=Asia/Tehran
2023-03-03 23:24:18 +03:30
WORKDIR /app
EXPOSE 8080
COPY --from=publish /app/publish .
ENTRYPOINT ["./MTWireGuard"]