This repository has been archived by the owner on May 18, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 89877f9
Showing
17 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/bin | ||
/obj | ||
project.lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": ".NET Core Launch (web)", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build", | ||
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/HeroicHaiku.dll", | ||
"args": [], | ||
"cwd": "${workspaceRoot}", | ||
"stopAtEntry": false, | ||
"internalConsoleOptions": "openOnSessionStart", | ||
"env": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"version": "0.1.0", | ||
"command": "dotnet", | ||
"isShellCommand": true, | ||
"args": [], | ||
"tasks": [ | ||
{ | ||
"taskName": "build", | ||
"args": [ | ||
"${workspaceRoot}/project.json" | ||
], | ||
"isBuildCommand": true, | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace HeroicHaiku.Controllers | ||
{ | ||
public class HomeController : Controller | ||
{ | ||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
public IActionResult About() | ||
{ | ||
return View(); | ||
} | ||
|
||
public IActionResult Error() | ||
{ | ||
return View(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM microsoft/aspnetcore:1.1.0 | ||
|
||
RUN adduser --disabled-password deployuser | ||
USER deployuser | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
CMD ASPNETCORE_URLS=http://*:$PORT dotnet HeroicHaiku.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.IO; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace HeroicHaiku | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var config = new ConfigurationBuilder() | ||
.AddEnvironmentVariables(prefix: "ASPNETCORE_") | ||
.Build(); | ||
|
||
var host = new WebHostBuilder() | ||
.UseConfiguration(config) | ||
.UseKestrel() | ||
.UseContentRoot(Directory.GetCurrentDirectory()) | ||
.UseStartup<Startup>() | ||
.Build(); | ||
|
||
host.Run(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# ASP.NET Core MVC on Heroku | ||
|
||
A barebones demo showing that an ASP.NET Core MVC app can run easily on Heroku via Docker. | ||
|
||
Developed on a Mac with the .NET Core SDK v1.1. Please note, there is no IIS integration so this might not actually run in Visual Studio on Windows. Funny, isn't it? | ||
|
||
# Requirements | ||
|
||
- [.NET Core SDK v1.1](https://www.microsoft.com/net/download/core#/current) | ||
- [Heroku Toolbelt](https://toolbelt.heroku.com/) (to authenticate with the Docker registry hosted by Heroku) | ||
- [Docker Toolbox](https://docker.com/toolbox) (to build the images and push to a registry) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace HeroicHaiku | ||
{ | ||
public class Startup | ||
{ | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddMvc(); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
{ | ||
app.UseMvc(routes => | ||
{ | ||
routes.MapRoute( | ||
name: "default", | ||
template: "{controller=Home}/{action=Index}/{id?}"); | ||
}); | ||
|
||
app.UseStaticFiles(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env sh | ||
|
||
dotnet publish | ||
docker build bin/Debug/netcoreapp1.1/publish -t heroichaiku | ||
|
||
docker login --username=_ --password=$(heroku auth:token) registry.heroku.com | ||
docker tag heroichaiku registry.heroku.com/heroichaiku/web | ||
docker push registry.heroku.com/heroichaiku/web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@{ | ||
ViewData["Title"] = "About"; | ||
} | ||
|
||
<h2>@ViewData["Title"]</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@{ | ||
ViewData["Title"] = "Home"; | ||
} | ||
|
||
<h2>@ViewData["Title"]</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@{ | ||
ViewData["Title"] = "Error"; | ||
} | ||
|
||
<h2>@ViewData["Title"]</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>@ViewData["Title"]</title> | ||
<link rel="stylesheet" href="~/css/site.css"> | ||
</head> | ||
|
||
<body> | ||
<ul> | ||
<li> | ||
<a asp-area="" asp-controller="Home" asp-action="Index"> | ||
Home | ||
</a> | ||
</li> | ||
<li> | ||
<a asp-area="" asp-controller="Home" asp-action="About"> | ||
About | ||
</a> | ||
</li> | ||
</ul> | ||
|
||
@RenderBody() | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@using HeroicHaiku | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@{ | ||
Layout = "_Layout"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"dependencies": { | ||
"Microsoft.NETCore.App": { | ||
"version": "1.1.0", | ||
"type": "platform" | ||
}, | ||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", | ||
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0", | ||
"Microsoft.AspNetCore.StaticFiles": "1.1.0", | ||
"Microsoft.AspNetCore.MVC": "1.1.0" | ||
}, | ||
|
||
"frameworks": { | ||
"netcoreapp1.1": { } | ||
}, | ||
|
||
"buildOptions": { | ||
"emitEntryPoint": true, | ||
"preserveCompilationContext": true | ||
}, | ||
|
||
"runtimeOptions": { | ||
"configProperties": { | ||
"System.GC.Server": true | ||
} | ||
}, | ||
|
||
"publishOptions": { | ||
"include": [ | ||
"**/*.cshtml", | ||
"wwwroot", | ||
"Dockerfile" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
html { | ||
font-family: sans-serif; | ||
} |