By using AWS re:Post, you agree to the Terms of Use

Questions tagged with .NET on AWS

Sort by most recent
  • 1
  • 12 / page

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Unable to load the service index for source error for a CodeArtifact NuGet feed using Dockerfile

Hi! We’re using AWS CodeArtifact for storing our packages and when we try to build a Docker image from our Dockerfile it fails because it's unable to load the source during the restore process. We have a web API in .Net that we want to deploy using AWS Fargate. This project runs smoothly from Visual Studio 2022 using Docker but we can’t build the image from PowerShell after adding our packages from CodeArtifact. Our approach to include the credentials in the build is to pass the NuGet.Config stored on the host using Buildkit. This’s our Dockerfile: ```powershell #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 80 ENV ASPNETCORE_URLS=http://+:49151 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY . . WORKDIR /src COPY ["Src/Presentation/Project.API/Project.API.csproj", "Src/Presentation/Project.API/"] RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ --mount=type=secret,id=nugetconfig \ dotnet restore "Src/Presentation/Project.API/Project.API.csproj" \ --configfile /run/secrets/nugetconfig COPY . . WORKDIR "/src/Src/Presentation/Project.API" RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ dotnet build "Project.API.csproj" -c Release -o /app/build \ --no-restore FROM build AS publish RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ dotnet publish "Project.API.csproj" -c Release -o /app/publish \ --no-restore FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "Project.API.dll"] ``` Our script in PowerShell: ```powershell docker buildx build --secret id=nugetconfig,src=$HOME\AppData\Roaming\NuGet\NuGet.Config -f "Src\Presentation\Project.API\Dockerfile" -t my-dotnet-image . ``` Output: ```powershell #14 [build 6/9] RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages --mount=type=secret,id=nugetconfig dotnet restore "Src/Presentation/Project.API/Project.API.csproj" --configfile /run/secrets/nugetconfig #14 1.175 Determining projects to restore... #14 2.504 /src/Src/Presentation/Project.API/Project.API.csproj : error NU1301: Unable to load the service index for source https://domain-123456789012.d.codeartifact.us-east-2.amazonaws.com/nuget/repository/v3/index.json. ``` What are we missing here? Once we have the Dockerfile working we want to use CDK for deploying the Docker image alongside our infrastructure. We’re using **aws codeartifact login** command to authenticate with the service. Thanks!
0
answers
0
votes
35
views
profile picture
asked 22 days ago
  • 1
  • 12 / page