1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 15:42:48 -05:00

create kestrel server for serving static files

This commit is contained in:
Kyle Spearrin
2017-08-15 12:03:55 -04:00
parent a9b9094b9c
commit 71c4954ca8
13 changed files with 109 additions and 5 deletions

View File

@ -0,0 +1,3 @@
*
!obj/Docker/publish/*
!obj/Docker/empty/

2
util/Server/Dockerfile Normal file
View File

@ -0,0 +1,2 @@
FROM microsoft/aspnetcore:2.0
COPY obj/Docker/publish /bitwarden_server

27
util/Server/Program.cs Normal file
View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Hosting;
namespace Server
{
public class Program
{
public static void Main(string[] args)
{
var builder = new WebHostBuilder()
.UseKestrel()
.UseStartup<Startup>();
if(args.Length > 0)
{
builder.UseContentRoot(args[0]);
}
if(args.Length > 1)
{
builder.UseWebRoot(args[1]);
}
var host = builder.Build();
host.Run();
}
}
}

View File

@ -0,0 +1,12 @@
{
"profiles": {
"Server": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:53910/"
}
}
}

12
util/Server/Server.csproj Normal file
View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>
</Project>

16
util/Server/Startup.cs Normal file
View File

@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
namespace Server
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{ }
public void Configure(IApplicationBuilder app)
{
app.UseFileServer();
}
}
}

11
util/Server/build.ps1 Normal file
View File

@ -0,0 +1,11 @@
$dir = Split-Path -Parent $MyInvocation.MyCommand.Path
echo "`n# Building Server"
echo "`nBuilding app"
echo ".NET Core version $(dotnet --version)"
dotnet publish $dir\Server.csproj -c "Release" -o $dir\obj\Docker\publish
echo "`nBuilding docker image"
docker --version
docker build -t bitwarden/server $dir\.

14
util/Server/build.sh Normal file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e
DIR="$(dirname $(readlink -f $0))"
echo -e "\n# Building Server"
echo -e "\nBuilding app"
echo -e ".NET Core version $(dotnet --version)"
dotnet publish $DIR/Server.csproj -c "Release" -o $DIR/obj/Docker/publish
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/server $DIR/.