Skip to content

Commit 95d07bd

Browse files
Ryan MoranForestEckhardt
Ryan Moran
authored andcommitted
Adds samples for language families
Signed-off-by: Forest Eckhardt <[email protected]>
1 parent b136e3e commit 95d07bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1574
-0
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Paketo Buildpacks Sample Applications
2+
3+
A collection of sample applications that can be built using Paketo Buildpacks.
4+
5+
## Prerequisites
6+
7+
1. Clone this repository: `git clone https://github.com/paketo-buildpacks/samples`
8+
1. [Docker](https://docs.docker.com/get-docker/)
9+
1. [Pack](https://buildpacks.io/docs/install-pack/)
10+
11+
## Samples
12+
13+
### Node.js
14+
* [NPM](/nodejs/npm/README.md)
15+
* [Yarn](/nodejs/yarn/README.md)
16+
17+
### Dotnet Core
18+
* [Runtime-only](/dotnet-core/runtime/README.md)
19+
* [ASPNet](/dotnet-core/aspnet/README.md)
20+
21+
### Go
22+
* [Mod](/go/mod/README.md)
23+
* [Dep](/go/dep/README.md)
24+
25+
### PHP
26+
* [Built-in Webserver](/php/webserver/README.md)
27+
* [NGINX](/php/nginx/README.md)
28+
* [Apache HTTPD](/php/httpd/README.md)

dotnet-core/aspnet/Program.cs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace aspnet
11+
{
12+
public class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
CreateHostBuilder(args).Build().Run();
17+
}
18+
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.ConfigureWebHostDefaults(webBuilder =>
22+
{
23+
webBuilder.UseStartup<Startup>();
24+
});
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:36111",
7+
"sslPort": 44311
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"aspnet": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"applicationUrl": "https://localhost:5001;http://localhost:5000",
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
}
25+
}
26+
}
27+
}

dotnet-core/aspnet/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Dotnet Core Sample App using ASPNet
2+
3+
## Building
4+
5+
`pack build dotnet-aspnet-sample --buildpack gcr.io/paketo-buildpacks/dotnet-core`
6+
7+
## Running
8+
9+
`docker run --interactive --tty --env PORT=8080 --publish 8080:8080 dotnet-aspnet-sample`
10+
11+
## Viewing
12+
13+
`curl http://localhost:8080`

dotnet-core/aspnet/Startup.cs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Builder;
6+
using Microsoft.AspNetCore.Hosting;
7+
using Microsoft.AspNetCore.Http;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.Hosting;
10+
11+
namespace aspnet
12+
{
13+
public class Startup
14+
{
15+
// This method gets called by the runtime. Use this method to add services to the container.
16+
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
17+
public void ConfigureServices(IServiceCollection services)
18+
{
19+
}
20+
21+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
22+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
23+
{
24+
if (env.IsDevelopment())
25+
{
26+
app.UseDeveloperExceptionPage();
27+
}
28+
29+
app.UseRouting();
30+
31+
app.UseEndpoints(endpoints =>
32+
{
33+
endpoints.MapGet("/", async context =>
34+
{
35+
await context.Response.WriteAsync(@"<!DOCTYPE html>
36+
<html>
37+
<head>
38+
<title>Powered By Paketo Buildpacks</title>
39+
</head>
40+
<body>
41+
<img style=""display: block; margin-left: auto; margin-right: auto; width: 50%;"" src=""https://paketo.io/images/paketo-logo-full-color.png""></img>
42+
</body>
43+
</html>");
44+
});
45+
});
46+
}
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
}
9+
}

dotnet-core/aspnet/appsettings.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
},
9+
"AllowedHosts": "*"
10+
}

dotnet-core/aspnet/aspnet.csproj

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"format": 1,
3+
"restore": {
4+
"/app/dotnet-core/aspnet/aspnet.csproj": {}
5+
},
6+
"projects": {
7+
"/app/dotnet-core/aspnet/aspnet.csproj": {
8+
"version": "1.0.0",
9+
"restore": {
10+
"projectUniqueName": "/app/dotnet-core/aspnet/aspnet.csproj",
11+
"projectName": "aspnet",
12+
"projectPath": "/app/dotnet-core/aspnet/aspnet.csproj",
13+
"packagesPath": "/root/.nuget/packages/",
14+
"outputPath": "/app/dotnet-core/aspnet/obj/",
15+
"projectStyle": "PackageReference",
16+
"configFilePaths": [
17+
"/root/.nuget/NuGet/NuGet.Config"
18+
],
19+
"originalTargetFrameworks": [
20+
"netcoreapp3.1"
21+
],
22+
"sources": {
23+
"https://api.nuget.org/v3/index.json": {}
24+
},
25+
"frameworks": {
26+
"netcoreapp3.1": {
27+
"projectReferences": {}
28+
}
29+
},
30+
"warningProperties": {
31+
"warnAsError": [
32+
"NU1605"
33+
]
34+
}
35+
},
36+
"frameworks": {
37+
"netcoreapp3.1": {
38+
"imports": [
39+
"net461",
40+
"net462",
41+
"net47",
42+
"net471",
43+
"net472",
44+
"net48"
45+
],
46+
"assetTargetFallback": true,
47+
"warn": true,
48+
"frameworkReferences": {
49+
"Microsoft.AspNetCore.App": {
50+
"privateAssets": "none"
51+
},
52+
"Microsoft.NETCore.App": {
53+
"privateAssets": "all"
54+
}
55+
},
56+
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/3.1.301/RuntimeIdentifierGraph.json"
57+
}
58+
}
59+
}
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
4+
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
5+
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
6+
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
7+
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/root/.nuget/packages/</NuGetPackageRoot>
8+
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/root/.nuget/packages/</NuGetPackageFolders>
9+
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
10+
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
11+
</PropertyGroup>
12+
<PropertyGroup>
13+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
14+
</PropertyGroup>
15+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
</PropertyGroup>
6+
</Project>
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"version": 3,
3+
"targets": {
4+
".NETCoreApp,Version=v3.1": {}
5+
},
6+
"libraries": {},
7+
"projectFileDependencyGroups": {
8+
".NETCoreApp,Version=v3.1": []
9+
},
10+
"packageFolders": {
11+
"/root/.nuget/packages/": {}
12+
},
13+
"project": {
14+
"version": "1.0.0",
15+
"restore": {
16+
"projectUniqueName": "/app/dotnet-core/aspnet/aspnet.csproj",
17+
"projectName": "aspnet",
18+
"projectPath": "/app/dotnet-core/aspnet/aspnet.csproj",
19+
"packagesPath": "/root/.nuget/packages/",
20+
"outputPath": "/app/dotnet-core/aspnet/obj/",
21+
"projectStyle": "PackageReference",
22+
"configFilePaths": [
23+
"/root/.nuget/NuGet/NuGet.Config"
24+
],
25+
"originalTargetFrameworks": [
26+
"netcoreapp3.1"
27+
],
28+
"sources": {
29+
"https://api.nuget.org/v3/index.json": {}
30+
},
31+
"frameworks": {
32+
"netcoreapp3.1": {
33+
"projectReferences": {}
34+
}
35+
},
36+
"warningProperties": {
37+
"warnAsError": [
38+
"NU1605"
39+
]
40+
}
41+
},
42+
"frameworks": {
43+
"netcoreapp3.1": {
44+
"imports": [
45+
"net461",
46+
"net462",
47+
"net47",
48+
"net471",
49+
"net472",
50+
"net48"
51+
],
52+
"assetTargetFallback": true,
53+
"warn": true,
54+
"frameworkReferences": {
55+
"Microsoft.AspNetCore.App": {
56+
"privateAssets": "none"
57+
},
58+
"Microsoft.NETCore.App": {
59+
"privateAssets": "all"
60+
}
61+
},
62+
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/3.1.301/RuntimeIdentifierGraph.json"
63+
}
64+
}
65+
}
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"version": 2,
3+
"dgSpecHash": "mRerHd+tzjNCPLtqErH507lRy9vhp10iuxVay9pUQD4LLo7hK9vQr2J2q+qRIWS4sV+7KawbphU4xX3Z3CzFog==",
4+
"success": true,
5+
"projectFilePath": "/app/dotnet-core/aspnet/aspnet.csproj",
6+
"expectedPackageFiles": [],
7+
"logs": []
8+
}

dotnet-core/runtime/Program.cs

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
using System.Net;
7+
using System.Net.Sockets;
8+
9+
namespace runtime
10+
{
11+
class Program
12+
{
13+
static void Main(string[] args)
14+
{
15+
string port = Environment.GetEnvironmentVariable("PORT");
16+
TcpListener server = new TcpListener(IPAddress.Any, Int32.Parse(port));
17+
18+
server.Start();
19+
20+
while (true)
21+
{
22+
TcpClient client = server.AcceptTcpClient();
23+
NetworkStream ns = client.GetStream();
24+
25+
string document = @"<!DOCTYPE html>
26+
<html>
27+
<head>
28+
<title>Powered By Paketo Buildpacks</title>
29+
</head>
30+
<body>
31+
<img style=""display: block; margin-left: auto; margin-right: auto; width: 50%;"" src=""https://paketo.io/images/paketo-logo-full-color.png""></img>
32+
</body>
33+
</html>";
34+
string payload = @"HTTP/1.1 200 OK
35+
Accept-Ranges: bytes
36+
Content-Length: " + System.Text.ASCIIEncoding.Unicode.GetByteCount(document) + @"
37+
Connection: close
38+
Content-Type: text/html; charset=utf-8
39+
40+
" + document;
41+
42+
byte[] msg = new byte[System.Text.ASCIIEncoding.Unicode.GetByteCount(payload)];
43+
msg = Encoding.Default.GetBytes(payload);
44+
ns.Write(msg, 0, msg.Length);
45+
46+
client.Close();
47+
}
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)