diff --git a/attachments/Dockerfile b/attachments/Dockerfile index e73699702..e8879368c 100644 --- a/attachments/Dockerfile +++ b/attachments/Dockerfile @@ -1,6 +1,5 @@ -FROM node +FROM bitwarden/server -RUN npm install http-server -g EXPOSE 80 COPY entrypoint.sh / diff --git a/attachments/entrypoint.sh b/attachments/entrypoint.sh index 748d7c371..6195ff8c3 100644 --- a/attachments/entrypoint.sh +++ b/attachments/entrypoint.sh @@ -1,4 +1,3 @@ #!/bin/sh -http-server /etc/bitwarden/core/attachments/. -p 80 -d false --utc - +dotnet /bitwarden_server/Server.dll /etc/bitwarden/core/attachments . diff --git a/bitwarden-core.sln b/bitwarden-core.sln index e2608287c..e1ed2f09c 100644 --- a/bitwarden-core.sln +++ b/bitwarden-core.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26724.1 +VisualStudioVersion = 15.0.26730.3 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D}" EndProject @@ -30,6 +30,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Identity", "src\Identity\Id EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Setup", "util\Setup\Setup.csproj", "{EF2164EF-1FC0-4518-A2ED-CE02D3630B00}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "util\Server\Server.csproj", "{66B0A682-658A-4A82-B606-A077A4871448}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -66,6 +68,10 @@ Global {EF2164EF-1FC0-4518-A2ED-CE02D3630B00}.Debug|Any CPU.Build.0 = Debug|Any CPU {EF2164EF-1FC0-4518-A2ED-CE02D3630B00}.Release|Any CPU.ActiveCfg = Release|Any CPU {EF2164EF-1FC0-4518-A2ED-CE02D3630B00}.Release|Any CPU.Build.0 = Release|Any CPU + {66B0A682-658A-4A82-B606-A077A4871448}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {66B0A682-658A-4A82-B606-A077A4871448}.Debug|Any CPU.Build.0 = Debug|Any CPU + {66B0A682-658A-4A82-B606-A077A4871448}.Release|Any CPU.ActiveCfg = Release|Any CPU + {66B0A682-658A-4A82-B606-A077A4871448}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -78,6 +84,7 @@ Global {02BC2982-ED8D-4A6D-A41E-092B3DAEB98A} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D} {04148736-3C0B-445E-8B74-2020E7A53502} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D} {EF2164EF-1FC0-4518-A2ED-CE02D3630B00} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} + {66B0A682-658A-4A82-B606-A077A4871448} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E01CBF68-2E20-425F-9EDB-E0A6510CA92F} diff --git a/build.ps1 b/build.ps1 index 3fdefcabc..1eadba11d 100644 --- a/build.ps1 +++ b/build.ps1 @@ -4,6 +4,7 @@ echo $dir echo "`nBuilding bitwarden" echo "==================" +& $dir\util\Server\build.ps1 & $dir\src\Api\build.ps1 & $dir\src\Identity\build.ps1 & $dir\nginx\build.ps1 diff --git a/build.sh b/build.sh index 1a4c5bc44..139bab8e4 100644 --- a/build.sh +++ b/build.sh @@ -6,6 +6,7 @@ DIR="$(dirname $(readlink -f $0))" echo -e "\nBuilding bitwarden" echo -e "==================" +$DIR/util/Server/build.sh $DIR/src/Api/build.sh $DIR/src/Identity/build.sh $DIR/nginx/build.sh diff --git a/util/Server/.dockerignore b/util/Server/.dockerignore new file mode 100644 index 000000000..d8f8175f6 --- /dev/null +++ b/util/Server/.dockerignore @@ -0,0 +1,3 @@ +* +!obj/Docker/publish/* +!obj/Docker/empty/ diff --git a/util/Server/Dockerfile b/util/Server/Dockerfile new file mode 100644 index 000000000..87c36dccc --- /dev/null +++ b/util/Server/Dockerfile @@ -0,0 +1,2 @@ +FROM microsoft/aspnetcore:2.0 +COPY obj/Docker/publish /bitwarden_server diff --git a/util/Server/Program.cs b/util/Server/Program.cs new file mode 100644 index 000000000..52e9e1ceb --- /dev/null +++ b/util/Server/Program.cs @@ -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(); + + if(args.Length > 0) + { + builder.UseContentRoot(args[0]); + } + + if(args.Length > 1) + { + builder.UseWebRoot(args[1]); + } + + var host = builder.Build(); + host.Run(); + } + } +} diff --git a/util/Server/Properties/launchSettings.json b/util/Server/Properties/launchSettings.json new file mode 100644 index 000000000..df4508265 --- /dev/null +++ b/util/Server/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "Server": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:53910/" + } + } +} \ No newline at end of file diff --git a/util/Server/Server.csproj b/util/Server/Server.csproj new file mode 100644 index 000000000..658b8f9ba --- /dev/null +++ b/util/Server/Server.csproj @@ -0,0 +1,12 @@ + + + + netcoreapp2.0 + false + + + + + + + diff --git a/util/Server/Startup.cs b/util/Server/Startup.cs new file mode 100644 index 000000000..4992d5b2f --- /dev/null +++ b/util/Server/Startup.cs @@ -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(); + } + } +} diff --git a/util/Server/build.ps1 b/util/Server/build.ps1 new file mode 100644 index 000000000..633ac334c --- /dev/null +++ b/util/Server/build.ps1 @@ -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\. diff --git a/util/Server/build.sh b/util/Server/build.sh new file mode 100644 index 000000000..7c6396f7b --- /dev/null +++ b/util/Server/build.sh @@ -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/.