Skip to content

Instantly share code, notes, and snippets.

@shanji97
Created July 20, 2023 10:20
Show Gist options
  • Save shanji97/36b1de53e5be1a55cb9915d4114e590c to your computer and use it in GitHub Desktop.
Save shanji97/36b1de53e5be1a55cb9915d4114e590c to your computer and use it in GitHub Desktop.
Docker command failed with exit code 1
FROM mcr.microsoft.com/dotnet/aspnet:6.0 as base
ENV ASPNETCORE_ENVIRONMENT=Development
WORKDIR /app
#Expose ports
EXPOSE 80
EXPOSE 443
#Set up build image
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG Configuration=Release
WORKDIR /src
#Copy *.sln file, and the corresponding csproj.
COPY *.sln ./
COPY ["Project.Core/Project.Core.csproj", "Project.Core/"]
COPY ["project-web/Project.Web.csproj", "project-web"]
#Restore packages
RUN dotnet restore
#Copy everything else and build
WORKDIR "/src/project-web"
RUN dotnet build "Project.Web.csproj" -c $Configuration -o /app/build
#Publish
FROM build AS publish
ARG Configuration=Release
RUN dotnet publish -c $Configuration -o /app/publish /p:UseAppHost=false
#Final image
FROM base as final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT [ "dotnet", "Project.Web.dll" ]
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Project.Web</RootNamespace>
<UserSecretsId>ee44544c-1228-42bf-94fc-b74c80695196</UserSecretsId>
<DockerfileFile>..\DockerFile</DockerfileFile>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Project.Core\Project.Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="..\.dockerignore" />
</ItemGroup>
</Project>
@shanji97
Copy link
Author

Added the Dockerfile using the automated VS2022 command and moved it into the root where the solution file is located.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment