1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05:00

setup, build, and run scripts

This commit is contained in:
Kyle Spearrin
2017-08-07 11:24:16 -04:00
parent 4a25abade8
commit ee8b0a25a8
26 changed files with 257 additions and 33 deletions

View File

@ -19,8 +19,7 @@ done
# Custom
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
COPY obj/Docker/publish .
ENTRYPOINT ["dotnet", "Api.dll"]

11
src/Api/build.ps1 Normal file
View File

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

14
src/Api/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 API"
echo -e "\nBuilding app"
echo -e ".NET Core version $(dotnet --version)"
dotnet publish $DIR/Api.csproj -f netcoreapp2.0 -c "Release" -o $DIR/obj/Docker/publish
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/api $DIR/.

View File

@ -61,6 +61,7 @@
public class IdentityServerSettings
{
public string CertificateThumbprint { get; set; }
public string CertificatePassword { get; set; }
}
public class DataProtectionSettings

View File

@ -98,7 +98,7 @@ namespace Bit.Core.Utilities
{
// Clean possible garbage characters from thumbprint copy/paste
// ref http://stackoverflow.com/questions/8448147/problems-with-x509store-certificates-find-findbythumbprint
thumbprint = Regex.Replace(thumbprint, @"[^\da-zA-z]", string.Empty).ToUpper();
thumbprint = Regex.Replace(thumbprint, @"[^\da-fA-F]", string.Empty).ToUpper();
X509Certificate2 cert = null;
var certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
@ -113,6 +113,11 @@ namespace Bit.Core.Utilities
return cert;
}
public static X509Certificate2 GetCertificate(string file, string password)
{
return new X509Certificate2(file, password);
}
public static long ToEpocMilliseconds(DateTime date)
{
return (long)Math.Round((date - _epoc).TotalMilliseconds, 0);

View File

@ -144,6 +144,13 @@ namespace Bit.Core.Utilities
{
identityServerBuilder.AddTemporarySigningCredential();
}
else if(!string.IsNullOrWhiteSpace(globalSettings.IdentityServer.CertificatePassword) &&
System.IO.File.Exists("identity.pfx"))
{
var identityServerCert = CoreHelpers.GetCertificate("identity.pfx",
globalSettings.IdentityServer.CertificatePassword);
identityServerBuilder.AddSigningCredential(identityServerCert);
}
else
{
var identityServerCert = CoreHelpers.GetCertificate(globalSettings.IdentityServer.CertificateThumbprint);
@ -161,7 +168,7 @@ namespace Bit.Core.Utilities
this IServiceCollection services, IHostingEnvironment env, GlobalSettings globalSettings)
{
#if NET461
if(!env.IsDevelopment())
if(!env.IsDevelopment() && !globalSettings.SelfHosted)
{
var dataProtectionCert = CoreHelpers.GetCertificate(globalSettings.DataProtection.CertificateThumbprint);
var storageAccount = CloudStorageAccount.Parse(globalSettings.Storage.ConnectionString);

View File

@ -1,3 +1,4 @@
*
!obj/Docker/publish/*
!obj/Docker/empty/
!entrypoint.sh

View File

@ -19,8 +19,10 @@ done
# Custom
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Identity.dll"]
COPY obj/Docker/publish .
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

11
src/Identity/build.ps1 Normal file
View File

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

14
src/Identity/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 Identity"
echo -e "\nBuilding app"
echo -e ".NET Core version $(dotnet --version)"
dotnet publish $DIR/Identity.csproj -f netcoreapp2.0 -c "Release" -o $DIR/obj/Docker/publish
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/identity $DIR/.

View File

@ -0,0 +1,5 @@
#!/bin/sh
cp /etc/core/identity.pfx /app/identity.pfx
dotnet /app/Identity.dll