Skip to content

Instantly share code, notes, and snippets.

@Guifgr
Created November 6, 2021 21:30
Show Gist options
  • Save Guifgr/e3c0b8a03d2ec188707d769d48e93f44 to your computer and use it in GitHub Desktop.
Save Guifgr/e3c0b8a03d2ec188707d769d48e93f44 to your computer and use it in GitHub Desktop.
heroku .net
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["todo.csproj", ""]
RUN dotnet restore "todo.csproj"
COPY . .
WORKDIR "/src/"
RUN dotnet build "todo.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "todo.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "todo.dll"]
heroku login
heroku container:login
heroku container:push web -a umc-todolist-app
heroku container:release web --app umc-todolist-app
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace todo
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls("http://*:" + Environment.GetEnvironmentVariable("PORT"));
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment