diff --git a/.woodpecker.yml b/.woodpecker.yml index acebcf6..a581ce8 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,9 +1,25 @@ steps: - name: Tests when: - - branch: main + - branch: [main,dev] event: push - - event: tag + - event: [pull_request, pull_request_closed, tag] image: mcr.microsoft.com/dotnet/sdk:8.0 commands: - dotnet test + +- name: Build and Publish Dev Docker Image + when: + - branch: dev + image: woodpeckerci/plugin-docker-buildx:4.2 + settings: + platforms: linux/amd64,linux/arm64 + repo: ${CI_REG_HOST}:${CI_REG_PORT}/${CI_REPO_OWNER}/${CI_REPO_NAME} + tags: dev + registry: http://${CI_REG_HOST}:${CI_REG_PORT} + insecure: true + buildkit_config: "[registry.\"${CI_REG_HOST}:${CI_REG_PORT}\"]\n http = true\n insecure = true" + username: + from_secret: CI_REG_USER + password: + from_secret: CI_REG_TOKEN diff --git a/AstralApi.sln b/AstralApi.sln index 426f74e..6ea55cb 100644 --- a/AstralApi.sln +++ b/AstralApi.sln @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{EB Alveus.ruleset = Alveus.ruleset LICENSE = LICENSE README.md = README.md + .woodpecker.yml = .woodpecker.yml + Dockerfile = Dockerfile EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Astral.Tests", "Astral.Tests\Astral.Tests.csproj", "{F0CBECAA-F279-4D94-9F83-E9EBC7A5C08C}" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b716af4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER $APP_UID +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG TARGETARCH +ARG BUILDPLATFORM +ARG BUILD_CONFIGURATION=Release + +WORKDIR /src + +COPY ["Astral.ApiServer/Astral.ApiServer.csproj", "Astral.ApiServer/"] +COPY ["Astral.Core/Astral.Core.csproj", "Astral.Core/"] +COPY ["Astral.Services/Astral.Services.csproj", "Astral.Services/"] +COPY ["Astral.DAL/Astral.DAL.csproj", "Astral.DAL/"] + +RUN dotnet restore "Astral.ApiServer/Astral.ApiServer.csproj" +COPY . . +WORKDIR "/src/Astral.ApiServer" +RUN dotnet build "Astral.ApiServer.csproj" -c $BUILD_CONFIGURATION -a $TARGETARCH -o /app/build + +FROM build AS publish +ARG TARGETARCH +ARG BUILD_CONFIGURATION=Release + +RUN dotnet publish "Astral.ApiServer.csproj" --no-restore -c $BUILD_CONFIGURATION -a $TARGETARCH -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Astral.ApiServer.dll"]