diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b6ca1ed..ba0892a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -42,7 +42,12 @@ jobs: run: | IMAGE="${{ secrets.WINSOMNIA_REGISTRY }}/winsomnia/${{ steps.envdetect.outputs.repo_slug }}:${GITHUB_REF_NAME}" - docker build -t "$IMAGE" . + docker build \ + --secret id=nuget_username,env=WINSOMNIA_NUGET_USERNAME \ + --secret id=nuget_token,env=WINSOMNIA_NUGET_TOKEN \ + --secret id=nuget_source,env=WINSOMNIA_NUGET_SOURCE \ + -t "$IMAGE" . + docker push "$IMAGE" echo "image=$IMAGE" >> $GITHUB_OUTPUT diff --git a/Dockerfile b/Dockerfile index ca0f610..267e297 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,27 @@ FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base LABEL company="Winsomnia" LABEL maintainer.name="Wesser" maintainer.email="support@winsomnia.net" + WORKDIR /app RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* + HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl --fail http://localhost:8080/health || exit 1 FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build + WORKDIR /src COPY . . -ARG NUGET_USERNAME -ARG NUGET_PASSWORD -ARG NUGET_ADDRESS - -RUN dotnet nuget add source ${NUGET_ADDRESS} \ - --name Winsomnia \ - --username ${NUGET_USERNAME} \ - --password ${NUGET_PASSWORD} \ - --store-password-in-clear-text +RUN --mount=type=secret,id=nuget_username \ + --mount=type=secret,id=nuget_token \ + --mount=type=secret,id=nuget_source \ + dotnet nuget add source $(cat /run/secrets/nuget_source) \ + --name Winsomnia \ + --username $(cat /run/secrets/nuget_username) \ + --password $(cat /run/secrets/nuget_token) \ + --store-password-in-clear-text RUN dotnet restore ./Backend.sln @@ -31,6 +33,9 @@ RUN dotnet publish Endpoint/Endpoint.csproj \ FROM base AS final WORKDIR /app + COPY --from=build /app . + RUN find . -name "*.pdb" -type f -delete + ENTRYPOINT ["dotnet", "Mirea.Api.Endpoint.dll"] \ No newline at end of file