Files
MoShiro/packaging/container/Probe.NativeBuild.Containerfile
T
justme 24ba05fbb6
ci/woodpecker/push/web-build Pipeline was successful
ci/woodpecker/push/verify Pipeline was successful
ci/woodpecker/push/dev-image Pipeline was successful
perf(ci): pin staged restore mtimes so the restore layer caches, drop build intermediates from the layer [CI]
2026-10-19 14:05:22 +08:00

61 lines
3.3 KiB
Docker

# AotAnywhere cross-links both Alpine architectures on the native amd64 runner.
ARG NATIVEAOT_BUILDER_IMAGE=localhost/moshiro-dotnet10-nativeaot-aotanywhere:ci
FROM --platform=linux/amd64 ${NATIVEAOT_BUILDER_IMAGE} AS build
WORKDIR /src/backend
COPY restore/backend/ ./
ARG NODE_RID=linux-musl-x64
ENV NUGET_PACKAGES=/root/.nuget/packages
RUN dotnet restore probe/src/MoShiro.Probe -r "$NODE_RID" -p:PublishAot=true -p:UseAotAnywhere=true \
-p:StaticMsQuic=true -p:StaticExecutable=true -p:RuntimeFrameworkVersion=10.0.12 \
-p:InvariantGlobalization=true --artifacts-path /artifacts \
&& dotnet restore fleet/tools/fleet-enroll -r "$NODE_RID" -p:PublishAot=true -p:UseAotAnywhere=true \
-p:StaticMsQuic=true -p:StaticExecutable=true -p:RuntimeFrameworkVersion=10.0.12 -p:InvariantGlobalization=true \
--artifacts-path /artifacts
COPY source/backend/ ./
COPY source/packaging/native/msquic/ /src/packaging/native/msquic/
# 构建信息:CI 通过 --build-arg 传入;不传就是空(放在 restore 之后,每次构建都变的时间不会让依赖还原的缓存失效)
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
RUN dotnet publish probe/src/MoShiro.Probe -m:3 -c Release -r "$NODE_RID" \
--self-contained true --no-restore -p:PublishAot=true -p:UseAotAnywhere=true \
-p:StaticMsQuic=true -p:StaticExecutable=true -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/probe \
&& dotnet publish fleet/tools/fleet-enroll -m:3 -c Release -r "$NODE_RID" \
--self-contained true --no-restore -p:PublishAot=true -p:UseAotAnywhere=true \
-p:StaticMsQuic=true -p:StaticExecutable=true -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 \
&& rm -rf /artifacts
RUN test -x /out/probe/moshiro-probe && test -x /out/enroll/fleet-enroll \
&& test "$(stat -c%s /out/probe/moshiro-probe)" -gt 2000000 \
&& test "$(stat -c%s /out/enroll/fleet-enroll)" -gt 2000000 \
&& ! readelf -l /out/probe/moshiro-probe | grep -q INTERP \
&& ! readelf -d /out/probe/moshiro-probe 2>&1 | grep -q NEEDED \
&& ! readelf -l /out/enroll/fleet-enroll | grep -q INTERP \
&& ! readelf -d /out/enroll/fleet-enroll 2>&1 | grep -q NEEDED
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine
ARG APP_VERSION=main
LABEL org.opencontainers.image.title="MoShiro Probe" \
org.opencontainers.image.description="MoShiro network measurement probe for Linux" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.version="$APP_VERSION"
COPY --chown=1654:1654 --from=build /out/probe/moshiro-probe /usr/local/bin/moshiro-probe
COPY --chown=1654:1654 --from=build /out/enroll/fleet-enroll /usr/local/bin/fleet-enroll
COPY --chown=1654:1654 config/ /etc/moshiro/
COPY --chown=1654:1654 --chmod=0755 entrypoint.sh /usr/local/bin/moshiro-entrypoint
ENV MOSHIRO_ROLE=probe
USER 1654:1654
WORKDIR /etc/moshiro
VOLUME ["/etc/moshiro"]
ENTRYPOINT ["/usr/local/bin/moshiro-entrypoint"]
CMD ["--config", "/etc/moshiro/probe.json"]