fix: pr validation #6
@ -24,7 +24,7 @@ RUN apt-get update && \
|
||||
RUN mkdir -p /app/uploads /app/logs \
|
||||
&& chmod 755 /app/uploads /app/logs
|
||||
|
||||
# Build stage - use build platform for compilation
|
||||
# Build stage - restore and publish
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG TARGETPLATFORM
|
||||
ARG VERSION
|
||||
@ -39,6 +39,7 @@ COPY ["src/BCards.Web/BCards.Web.csproj", "src/BCards.Web/"]
|
||||
RUN case "$TARGETPLATFORM" in \
|
||||
"linux/amd64") RID="linux-x64" ;; \
|
||||
"linux/arm64") RID="linux-arm64" ;; \
|
||||
*) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
|
||||
esac && \
|
||||
echo "🔧 Restoring for RID: $RID" && \
|
||||
dotnet restore "src/BCards.Web/BCards.Web.csproj" --runtime $RID
|
||||
@ -47,37 +48,17 @@ RUN case "$TARGETPLATFORM" in \
|
||||
COPY . .
|
||||
WORKDIR "/src/src/BCards.Web"
|
||||
|
||||
# Build application with Release configuration
|
||||
RUN case "$TARGETPLATFORM" in \
|
||||
"linux/amd64") RID="linux-x64" ;; \
|
||||
"linux/arm64") RID="linux-arm64" ;; \
|
||||
esac && \
|
||||
echo "🔨 Building for RID: $RID" && \
|
||||
dotnet build "BCards.Web.csproj" \
|
||||
-c Release \
|
||||
-o /app/build \
|
||||
--no-restore \
|
||||
--runtime $RID \
|
||||
-p:Version=$VERSION \
|
||||
-p:InformationalVersion=$COMMIT
|
||||
|
||||
# Publish stage - optimize for target platform
|
||||
FROM build AS publish
|
||||
ARG TARGETPLATFORM
|
||||
ARG VERSION
|
||||
ARG COMMIT
|
||||
|
||||
# Publish with cross-compilation friendly settings
|
||||
# Publish diretamente (build + publish em um comando)
|
||||
RUN case "$TARGETPLATFORM" in \
|
||||
"linux/amd64") RID="linux-x64" ;; \
|
||||
"linux/arm64") RID="linux-arm64" ;; \
|
||||
*) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
|
||||
esac && \
|
||||
echo "📦 Publishing for RID: $RID" && \
|
||||
dotnet publish "BCards.Web.csproj" \
|
||||
-c Release \
|
||||
-o /app/publish \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--runtime $RID \
|
||||
--self-contained false \
|
||||
-p:PublishReadyToRun=false \
|
||||
@ -102,7 +83,7 @@ LABEL environment="release"
|
||||
WORKDIR /app
|
||||
|
||||
# Copy published application
|
||||
COPY --from=publish /app/publish .
|
||||
COPY --from=build /app/publish .
|
||||
|
||||
# Create non-root user for security
|
||||
RUN groupadd -r bcards && useradd -r -g bcards bcards \
|
||||
@ -136,4 +117,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||
USER bcards
|
||||
|
||||
# Entry point with optimized runtime settings
|
||||
ENTRYPOINT ["dotnet", "BCards.Web.dll"]
|
||||
ENTRYPOINT ["dotnet", "BCards.Web.dll"]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user