a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse
social-media
social
iceshrimp
fedi
1# syntax=docker/dockerfile-upstream:master
2# To build with ILLink & AOT enabled, run docker build --build-arg="AOT=true"
3# To build without VIPS support, run docker build --build-arg="VIPS=false"
4
5ARG AOT=false
6
7ARG IMAGE=${AOT/true/alpine-wasm}
8ARG IMAGE=${IMAGE/false/alpine}
9
10FROM --platform=$BUILDPLATFORM iceshrimp.dev/iceshrimp/dotnet-sdk:10.0-$IMAGE AS builder
11WORKDIR /src
12ARG BUILDPLATFORM
13ARG AOT=false
14
15# copy csproj files & nuget config, then restore as distinct layers
16COPY NuGet.Config /src
17COPY Iceshrimp.Backend/*.csproj /src/Iceshrimp.Backend/
18COPY Iceshrimp.Parsing/*.csproj /src/Iceshrimp.Parsing/
19COPY Iceshrimp.Frontend/*.csproj /src/Iceshrimp.Frontend/
20COPY Iceshrimp.Shared/*.csproj /src/Iceshrimp.Shared/
21COPY Iceshrimp.Build/*.csproj /src/Iceshrimp.Build/
22COPY Iceshrimp.Build/*.props /src/Iceshrimp.Build/
23COPY Directory.Build.props /src/Directory.Build.props
24
25WORKDIR /src/Iceshrimp.Backend
26ARG VIPS=true
27RUN --mount=type=cache,target=/root/.nuget \
28 dotnet restore -p:Configuration=Release -p:BundleNativeDeps=$VIPS -p:EnableLibVips=$VIPS
29
30# copy build files
31COPY Iceshrimp.Backend/ /src/Iceshrimp.Backend/
32COPY Iceshrimp.Parsing/ /src/Iceshrimp.Parsing/
33COPY Iceshrimp.Frontend/ /src/Iceshrimp.Frontend/
34COPY Iceshrimp.Shared/ /src/Iceshrimp.Shared/
35COPY Iceshrimp.Build/ /src/Iceshrimp.Build/
36
37# copy files required for sourcelink
38COPY .git/HEAD /src/.git/HEAD
39COPY .git/config /src/.git/config
40COPY .git/refs/heads/ /src/.git/refs/heads/
41RUN mkdir -p /src/.git/objects
42
43# build without architecture set, allowing for reuse of the majority of the compiled IL between architectures
44RUN --mount=type=cache,target=/root/.nuget \
45 dotnet publish --no-restore -c Release -o /build -p:EnableAOT=$AOT -p:BundleNativeDeps=$VIPS -p:EnableLibVips=$VIPS -p:DeterministicSourcePaths=true -p:ContinuousIntegrationBuild=true
46
47# if architecture doesn't match, build with architecture set, otherwise use existing compile output
48ARG TARGETPLATFORM
49ARG TARGETARCH
50
51RUN --mount=type=cache,target=/root/.nuget \
52 if [[ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]]; then \
53 dotnet restore -a $TARGETARCH -p:Configuration=Release -p:BundleNativeDeps=$VIPS -p:EnableLibVips=$VIPS; \
54 dotnet publish --no-restore -c Release -a $TARGETARCH -o /app-$TARGETARCH -p:EnableAOT=$AOT -p:BundleNativeDeps=$VIPS -p:EnableLibVips=$VIPS -p:DeterministicSourcePaths=true -p:ContinuousIntegrationBuild=true; \
55 mv /app-$TARGETARCH /app; else mv /build /app; \
56 fi
57
58# Enable globalization and time zones:
59# https://github.com/dotnet/dotnet-docker/blob/main/samples/enable-globalization.md
60# final stage/image
61FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine-composite AS image
62WORKDIR /app
63COPY --from=builder /app .
64USER app
65ENTRYPOINT ["./Iceshrimp.Backend", "--environment", "Production", "--migrate-and-start"]