Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
DropkicK Deployment Example
using System.IO;
using System.Security.Cryptography.X509Certificates;
using dropkick.Configuration.Dsl;
using dropkick.Configuration.Dsl.Files;
using dropkick.Configuration.Dsl.Iis;
using dropkick.Configuration.Dsl.RoundhousE;
using dropkick.Configuration.Dsl.Security;
using dropkick.Configuration.Dsl.WinService;
using dropkick.Wmi;
namespace App.Deployment
{
public class TheDeployment : Deployment<TheDeployment, DeploymentSettings>
{
public TheDeployment()
{
Define(settings =>
{
DeploymentStepsFor(Db,
s =>
{
s.RoundhousE()
.ForEnvironment(settings.Environment)
.OnDatabase(settings.DbName)
.WithScriptsFolder(settings.DbSqlFilesPath)
.WithDatabaseRecoveryMode(settings.DbRecoveryMode)
.WithRestorePath(settings.DbRestorePath)
.WithRepositoryPath("https://github.com/chucknorris/roundhouse.git")
.WithVersionFile("_BuildInfo.xml")
.WithRoundhousEMode(settings.RoundhousEMode);
});
DeploymentStepsFor(Web,
s =>
{
s.CopyDirectory(@"..\_PublishedWebSites\WebName").To(@"{{WebsitePath}}").DeleteDestinationBeforeDeploying();
s.CopyFile(@"..\environment.files\{{Environment}}\{{Environment}}.web.config").ToDirectory(@"{{WebsitePath}}").RenameTo(@"web.config");
s.Security(securityOptions =>
{
securityOptions.ForPath(settings.WebsitePath, fileSecurityConfig => fileSecurityConfig.GrantRead(settings.WebUserName));
securityOptions.ForPath(Path.Combine(settings.HostServicePath, "logs"), fs => fs.GrantReadWrite(settings.WebUserName));
securityOptions.ForPath(@"~\C$\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files", fs => fs.GrantReadWrite(settings.WebUserName));
if (Directory.Exists(@"~\C$\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files"))
{
securityOptions.ForPath(@"~\C$\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files", fs => fs.GrantReadWrite(settings.WebUserName));
}
securityOptions.ForCertificate(settings.CertificateThumbprint, c =>
{
c.GrantReadPrivateKey()
.To(settings.WebUserName)
.InStoreLocation(StoreLocation.LocalMachine)
.InStoreName(StoreName.My);
});
});
});
DeploymentStepsFor(Host,
s =>
{
var serviceName = "ServiceName.{{Environment}}";
s.WinService(serviceName).Stop();
s.CopyDirectory(@"..\_PublishedApplications\ServiceName").To(@"{{HostServicePath}}").DeleteDestinationBeforeDeploying();
s.CopyFile(@"..\environment.files\{{Environment}}\{{Environment}}.servicename.exe.config").ToDirectory(@"{{HostServicePath}}").RenameTo(@"servicename.exe.config");
s.Security(o =>
{
o.ForCertificate(settings.CertificateThumbprint, c =>
{
c.GrantReadPrivateKey()
.To(settings.ServiceUserName)
.InStoreLocation(StoreLocation.LocalMachine)
.InStoreName(StoreName.My);
});
o.LocalPolicy(lp =>
{
lp.LogOnAsService(settings.ServiceUserName);
lp.LogOnAsBatch(settings.ServiceUserName);
});
o.ForPath(settings.HostServicePath, fs => fs.GrantRead(settings.ServiceUserName));
o.ForPath(Path.Combine(settings.HostServicePath,"logs"), fs => fs.GrantReadWrite(settings.ServiceUserName));
o.ForPath(settings.ServiceWorkDirectory, fs => fs.GrantReadWrite(settings.ServiceUserName));
o.ForPath(settings.ServiceTriggerWatchDirectory, fs => fs.GrantReadWrite(settings.ServiceUserName));
o.ForPath(settings.SecureWorkDirectory, fs =>
{
fs.GrantReadWrite(settings.ServiceUserName);
fs.RemoveInheritance();
fs.Clear().Preserve(settings.ServiceUserName)
.RemoveAdministratorsGroup()
.RemoveUsersGroup();
});
});
s.WinService(serviceName).Delete();
s.WinService(serviceName).Create().WithCredentials(settings.ServiceUserName, settings.ServiceUserPassword).WithDisplayName("servicename({{Environment}})").WithServicePath(@"{{HostServicePath}}\servicename.exe").
WithStartMode(settings.ServiceStartMode)
.AddDependency("MSMQ");
if (settings.ServiceStartMode != ServiceStartMode.Disabled && settings.ServiceStartMode != ServiceStartMode.Manual)
{
s.WinService(serviceName).Start();
}
});
});
}
//order is important
public static Role Db { get; set; }
public static Role Web { get; set; }
public static Role Host { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.