diff --git a/.docker/build.sh b/.docker/build.sh new file mode 100755 index 00000000..9d051f25 --- /dev/null +++ b/.docker/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash +docker build . -f dotnet-sdk-8.0-wasm.Dockerfile -t iceshrimp.dev/iceshrimp/dotnet-sdk:8.0-wasm --push +docker build . -f dotnet-sdk-8.0-alpine.Dockerfile -t iceshrimp.dev/iceshrimp/dotnet-sdk:8.0-alpine --push +docker build . -f dotnet-sdk-9.0-alpine-wasm.Dockerfile -t iceshrimp.dev/iceshrimp/dotnet-sdk:9.0-alpine-wasm --push +docker build . -f ci-env.Dockerfile -t iceshrimp.dev/iceshrimp/ci-env:dotnet --push +docker build . -f ci-env-wasm.Dockerfile -t iceshrimp.dev/iceshrimp/ci-env:dotnet-wasm --push diff --git a/.forgejo/ci-env-wasm/Dockerfile b/.docker/ci-env-wasm.Dockerfile similarity index 73% rename from .forgejo/ci-env-wasm/Dockerfile rename to .docker/ci-env-wasm.Dockerfile index 45151e06..37c32abc 100644 --- a/.forgejo/ci-env-wasm/Dockerfile +++ b/.docker/ci-env-wasm.Dockerfile @@ -1,11 +1,8 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 +FROM iceshrimp.dev/iceshrimp/dotnet-sdk:8.0-wasm RUN apt-get update && apt-get install git bash python3 curl golang nodejs zstd ca-certificates -y RUN install -m 0755 -d /etc/apt/keyrings RUN curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc RUN chmod a+r /etc/apt/keyrings/docker.asc RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null RUN apt-get update && apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin -y -RUN curl -o /bin/git-restore-mtime https://raw.githubusercontent.com/MestreLion/git-tools/main/git-restore-mtime -RUN chmod +x /bin/git-restore-mtime -RUN dotnet workload install wasm-tools CMD ["/bin/sh"] diff --git a/.forgejo/ci-env/Dockerfile b/.docker/ci-env.Dockerfile similarity index 50% rename from .forgejo/ci-env/Dockerfile rename to .docker/ci-env.Dockerfile index f93f453c..54644c64 100644 --- a/.forgejo/ci-env/Dockerfile +++ b/.docker/ci-env.Dockerfile @@ -1,5 +1,3 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine RUN apk add --no-cache --no-progress git docker bash python3 curl go nodejs-current zstd -RUN curl -o /bin/git-restore-mtime https://raw.githubusercontent.com/MestreLion/git-tools/main/git-restore-mtime -RUN chmod +x /bin/git-restore-mtime CMD ["/bin/sh"] diff --git a/.forgejo/ci-release/Dockerfile b/.docker/dotnet-runner-8.0.Dockerfile similarity index 68% rename from .forgejo/ci-release/Dockerfile rename to .docker/dotnet-runner-8.0.Dockerfile index ee7d639a..dc06c562 100644 --- a/.forgejo/ci-release/Dockerfile +++ b/.docker/dotnet-runner-8.0.Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled AS image-aot +FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled ARG TARGETARCH WORKDIR /app COPY linux-$TARGETARCH/ . diff --git a/.docker/dotnet-sdk-8.0-alpine.Dockerfile b/.docker/dotnet-sdk-8.0-alpine.Dockerfile new file mode 100644 index 00000000..f36faa7f --- /dev/null +++ b/.docker/dotnet-sdk-8.0-alpine.Dockerfile @@ -0,0 +1,2 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine +CMD ["/bin/sh"] diff --git a/.docker/dotnet-sdk-8.0-wasm.Dockerfile b/.docker/dotnet-sdk-8.0-wasm.Dockerfile new file mode 100644 index 00000000..44b32789 --- /dev/null +++ b/.docker/dotnet-sdk-8.0-wasm.Dockerfile @@ -0,0 +1,4 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 +RUN --mount=type=cache,target=/root/.nuget dotnet workload install wasm-tools +RUN apt-get update && apt-get install python3 -y +CMD ["/bin/sh"] diff --git a/.docker/dotnet-sdk-9.0-alpine-wasm.Dockerfile b/.docker/dotnet-sdk-9.0-alpine-wasm.Dockerfile new file mode 100644 index 00000000..cddb58cc --- /dev/null +++ b/.docker/dotnet-sdk-9.0-alpine-wasm.Dockerfile @@ -0,0 +1,2 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0-preview-alpine +RUN dotnet workload install wasm-tools diff --git a/.forgejo/workflows/commit.yaml b/.forgejo/workflows/commit.yaml index 65b062e4..1a2af5c4 100644 --- a/.forgejo/workflows/commit.yaml +++ b/.forgejo/workflows/commit.yaml @@ -6,7 +6,7 @@ jobs: test-build-and-push: runs-on: docker container: - image: iceshrimp.dev/iceshrimp/iceshrimp.net:ci-env + image: iceshrimp.dev/iceshrimp/ci-env:dotnet options: | --volume /opt/iceshrimp-cache/nuget:/root/.nuget --volume /root/.docker:/root/.docker @@ -28,10 +28,7 @@ jobs: - name: Initialize builder run: docker buildx use iceshrimp-ci || docker buildx create --name iceshrimp-ci --use - name: Patch Dockerfile - run: | - sed -i 's^mcr.microsoft.com/dotnet/sdk:8.0-alpine^iceshrimp.dev/iceshrimp/iceshrimp.net:ci-env^g' /iceshrimp/Dockerfile - sed -i 's^mcr.microsoft.com/dotnet/sdk:8.0^iceshrimp.dev/iceshrimp/iceshrimp.net:ci-env-wasm^g' /iceshrimp/Dockerfile - sed -i 's^dotnet workload install wasm-tools^echo^g' /iceshrimp/Dockerfile + run: sed -i 's^mcr.microsoft.com/dotnet/sdk:8.0-alpine^iceshrimp.dev/iceshrimp/dotnet-sdk:8.0-alpine^g' /iceshrimp/Dockerfile - name: Build the image shell: bash run: docker buildx build --target image-jit -t iceshrimp.dev/${GITHUB_REPOSITORY@L}:$GITHUB_REF_NAME --provenance=false --platform=linux/amd64,linux/arm64 --push /iceshrimp diff --git a/.forgejo/workflows/release-artifacts.yaml b/.forgejo/workflows/release-artifacts.yaml index d5ff679e..1f6c2ca9 100644 --- a/.forgejo/workflows/release-artifacts.yaml +++ b/.forgejo/workflows/release-artifacts.yaml @@ -6,7 +6,7 @@ jobs: build-artifacts: runs-on: docker container: - image: iceshrimp.dev/iceshrimp/iceshrimp.net:ci-env-wasm + image: iceshrimp.dev/iceshrimp/ci-env:dotnet-wasm options: --volume /opt/iceshrimp-cache/nuget:/root/.nuget steps: - name: Clone repository @@ -62,7 +62,7 @@ jobs: - name: Build the image shell: bash run: | - cp /src/.forgejo/ci-release/Dockerfile /out + cp /src/.docker/dotnet-runner-8.0.Dockerfile /out/Dockerfile docker buildx build ${{ env.TAGS }} --provenance=false --platform=linux/amd64,linux/arm64 --push /out - name: Purge cache run: docker buildx prune --keep-storage 20G diff --git a/.forgejo/workflows/test-build.yaml b/.forgejo/workflows/test-build.yaml index fbb32400..6590bc91 100644 --- a/.forgejo/workflows/test-build.yaml +++ b/.forgejo/workflows/test-build.yaml @@ -7,7 +7,7 @@ jobs: test-build: runs-on: docker container: - image: iceshrimp.dev/iceshrimp/iceshrimp.net:ci-env + image: iceshrimp.dev/iceshrimp/dotnet-sdk:8.0-alpine options: --volume /opt/iceshrimp-cache/nuget:/root/.nuget steps: - name: Clone repository diff --git a/Dockerfile b/Dockerfile index bdd646c6..075fa25a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # We have to build & run AOT images on linux-glibc, at least until .NET 9.0 (See https://github.com/dotnet/sdk/issues/32327 for details) -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS builder-jit +FROM --platform=$BUILDPLATFORM iceshrimp.dev/iceshrimp/dotnet-sdk:8.0-alpine AS builder-jit ARG BUILDPLATFORM WORKDIR /src @@ -40,14 +40,10 @@ RUN --mount=type=cache,target=/root/.nuget \ mv /app-$TARGETARCH /app; else mv /build /app; \ fi -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS builder-aot +FROM --platform=$BUILDPLATFORM iceshrimp.dev/iceshrimp/dotnet-sdk:8.0-wasm AS builder-aot ARG BUILDPLATFORM WORKDIR /src -RUN --mount=type=cache,target=/root/.nuget \ - dotnet workload install wasm-tools -RUN apt-get update && apt-get install python3 -y - # copy csproj/fsproj & nuget config, then restore as distinct layers COPY NuGet.Config /src COPY Iceshrimp.Backend/*.csproj /src/Iceshrimp.Backend/