forked from Azure-App-Service/KuduLite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OneDeploy API - /publish and /api/publish (Azure-App-Service#134)
* OneDeploy API - /publish and /api/publish - Adds a new /publish and /api/publish APIs for Java deployment scenarios - This new API primarily supports Java scenarios currently, but can be easily extended for additional scenarios - Overview of new changes - OneDeploy reuses bulk of the code from PushDeploymentController and DeploymentManager - OneDeployBuilder is a new OneDeploy specific site builder, OneDeployFetch is a OneDeploy specific Fetch handler - WatchedFileEnabled/RestartAllowed/ArtifactType/TargetRootPath are additional knobs introduced in DeploymentInfoBase.cs for OneDeploy specific functionality - The implementation inspects the WEBSITE_STACK environment variable for certain scenarios. This variable is injected by the App Service runtime - OneDeploy uses the new restart API (in other words, it does not rely on touching any file for triggering a recycle) - Summary of changes to existing code: - A bunch of variables were renamed for readability purposes - ZipDeploymentInfo is now ArtifactDeploymentInfo (generalized) and is now used by OneDeploy for non-zip artifacts as well - Note: This is primarily a port of projectkudu/kudu#3203 with some additional enhancements to OneDeploy. These enhancements will be back ported to https://github.com/projectkudu/kudu * Minor refactoring
- Loading branch information
1 parent
c1cbd84
commit 972f930
Showing
14 changed files
with
688 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Kudu.Contracts.Deployment | ||
{ | ||
public enum ArtifactType | ||
{ | ||
Unknown, | ||
War, | ||
Jar, | ||
Ear, | ||
Lib, | ||
Static, | ||
Startup, | ||
Script, | ||
Zip, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Kudu.Contracts.Settings; | ||
using Kudu.Core.Infrastructure; | ||
|
||
namespace Kudu.Core.Deployment.Generator | ||
{ | ||
// This is the site builder used for OneDeploy scenarios | ||
public class OneDeployBuilder : BasicBuilder | ||
{ | ||
private DeploymentInfoBase _deploymentInfo; | ||
private string _repositoryPath; | ||
|
||
public OneDeployBuilder(IEnvironment environment, IDeploymentSettingsManager settings, IBuildPropertyProvider propertyProvider, string repositoryPath, string projectPath, DeploymentInfoBase deploymentInfo) | ||
: base(environment, settings, propertyProvider, repositoryPath, projectPath) | ||
{ | ||
_deploymentInfo = deploymentInfo; | ||
_repositoryPath = repositoryPath; | ||
} | ||
|
||
public override string ProjectType | ||
{ | ||
get { return Constants.OneDeploy; } | ||
} | ||
|
||
public override Task Build(DeploymentContext context) | ||
{ | ||
context.Logger.Log($"Running build. Project type: {ProjectType}"); | ||
|
||
// Start by copying the manifest as-is so that | ||
// manifest based deployments (Example: ZipDeploy) are unaffected | ||
context.Logger.Log($"Copying the manifest"); | ||
FileSystemHelpers.CopyFile(context.PreviousManifestFilePath, context.NextManifestFilePath); | ||
|
||
// If we want to clean up the target directory before copying | ||
// the new files, use kudusync so that only unnecessary files are | ||
// deleted. This has two benefits: | ||
// 1. This is faster than deleting the target directory before copying the source dir. | ||
// 2. Minimizes chances of failure in deleting a directory due to open handles. | ||
// This is especially useful when a target directory is present in the source and | ||
// need not be deleted. | ||
if (_deploymentInfo.CleanupTargetDirectory) | ||
{ | ||
context.Logger.Log($"Clean deploying to {context.OutputPath}"); | ||
|
||
// We do not want to use the manifest for OneDeploy. Use an empty manifest file. | ||
// This way we don't interfere with manifest based deployments. | ||
string tempManifestPath = null; | ||
try | ||
{ | ||
tempManifestPath = Path.GetTempFileName(); | ||
context.PreviousManifestFilePath = context.NextManifestFilePath = tempManifestPath; | ||
base.Build(context); | ||
} | ||
finally | ||
{ | ||
if (!string.IsNullOrWhiteSpace(tempManifestPath)) | ||
{ | ||
FileSystemHelpers.DeleteFileSafe(tempManifestPath); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
context.Logger.Log($"Incrementally deploying to {context.OutputPath}"); | ||
FileSystemHelpers.CopyDirectoryRecursive(_repositoryPath, context.OutputPath); | ||
} | ||
|
||
context.Logger.Log($"Build completed succesfully."); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.