63 lines
3.2 KiB
Docker
63 lines
3.2 KiB
Docker
# Cross-compile Linux binaries on amd64; consumers package these outputs directly.
|
|
ARG NATIVEAOT_RESTORE_IMAGE
|
|
FROM ${NATIVEAOT_RESTORE_IMAGE} AS restore
|
|
WORKDIR /src/backend
|
|
COPY source/backend/ ./
|
|
COPY source/packaging/native/msquic/ /src/packaging/native/msquic/
|
|
ARG NODE_RID=linux-musl-arm64
|
|
ARG STATIC_MSQUIC=true
|
|
ENV NUGET_PACKAGES=/root/.nuget/packages
|
|
FROM restore AS managed
|
|
ARG NODE_RID=linux-musl-arm64
|
|
ARG STATIC_MSQUIC=true
|
|
ARG APP_VERSION=0.0.0-dev
|
|
ARG MOSHIRO_TAG=
|
|
ARG MOSHIRO_COMMIT=
|
|
ARG MOSHIRO_BUILT_AT=
|
|
ENV MOSHIRO_TAG=$MOSHIRO_TAG MOSHIRO_COMMIT=$MOSHIRO_COMMIT MOSHIRO_BUILT_AT=$MOSHIRO_BUILT_AT
|
|
# Build the project graph once; both native publishes reuse these managed outputs.
|
|
RUN test -n "$NODE_RID" \
|
|
&& echo "building managed outputs for $NODE_RID" \
|
|
&& dotnet build Agent.Native.proj -m:3 -c Release -r "$NODE_RID" --no-restore \
|
|
-p:PublishAot=true -p:UseAotAnywhere=true -p:SelfContained=true -p:Version="$APP_VERSION" \
|
|
-p:RuntimeIdentifier="$NODE_RID" \
|
|
-p:StaticMsQuic="$STATIC_MSQUIC" -p:StaticExecutable="$STATIC_MSQUIC" \
|
|
-p:RuntimeFrameworkVersion=10.0.12 -p:InvariantGlobalization=true \
|
|
-p:UseAppHost=true -p:StripSymbols=true -p:DebugType=none -p:DebugSymbols=false --artifacts-path /artifacts
|
|
|
|
FROM managed AS build-agent
|
|
ARG NODE_RID=linux-musl-arm64
|
|
ARG STATIC_MSQUIC=true
|
|
ARG APP_VERSION=0.0.0-dev
|
|
RUN dotnet publish agent/src/MoShiro.Agent -m:3 -c Release -r "$NODE_RID" \
|
|
--self-contained true --no-build --no-restore -p:PublishAot=true -p:UseAotAnywhere=true \
|
|
-p:Version="$APP_VERSION" -p:StaticMsQuic="$STATIC_MSQUIC" -p:StaticExecutable="$STATIC_MSQUIC" \
|
|
-p:RuntimeFrameworkVersion=10.0.12 -p:InvariantGlobalization=true -p:UseAppHost=true -p:StripSymbols=true \
|
|
-p:DebugType=none -p:DebugSymbols=false --artifacts-path /artifacts -o /out/agent \
|
|
&& test -x /out/agent/moshiro-agent \
|
|
&& test "$(stat -c%s /out/agent/moshiro-agent)" -gt 2000000 \
|
|
&& if [ "$STATIC_MSQUIC" = true ]; then \
|
|
! readelf -l /out/agent/moshiro-agent | grep -q INTERP \
|
|
&& ! readelf -d /out/agent/moshiro-agent 2>&1 | grep -q NEEDED; \
|
|
fi
|
|
|
|
FROM managed AS build-enroll
|
|
ARG NODE_RID=linux-musl-arm64
|
|
ARG STATIC_MSQUIC=true
|
|
ARG APP_VERSION=0.0.0-dev
|
|
RUN dotnet publish fleet/tools/fleet-enroll -m:3 -c Release -r "$NODE_RID" \
|
|
--self-contained true --no-build --no-restore -p:PublishAot=true -p:UseAotAnywhere=true \
|
|
-p:Version="$APP_VERSION" -p:StaticMsQuic="$STATIC_MSQUIC" -p:StaticExecutable="$STATIC_MSQUIC" \
|
|
-p:RuntimeFrameworkVersion=10.0.12 -p:InvariantGlobalization=true -p:UseAppHost=true -p:StripSymbols=true \
|
|
-p:DebugType=none -p:DebugSymbols=false --artifacts-path /artifacts -o /out/enroll \
|
|
&& test -x /out/enroll/fleet-enroll \
|
|
&& test "$(stat -c%s /out/enroll/fleet-enroll)" -gt 2000000 \
|
|
&& if [ "$STATIC_MSQUIC" = true ]; then \
|
|
! readelf -l /out/enroll/fleet-enroll | grep -q INTERP \
|
|
&& ! readelf -d /out/enroll/fleet-enroll 2>&1 | grep -q NEEDED; \
|
|
fi
|
|
|
|
FROM scratch AS binaries
|
|
COPY --from=build-agent /out/agent/moshiro-agent /out/agent/moshiro-agent
|
|
COPY --from=build-enroll /out/enroll/fleet-enroll /out/enroll/fleet-enroll
|