Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Adding dotnet support

* Test Commit for new build options

* Oryx build optimizations

* Fix bug in source directory

* Fix python builds to use virtualenv flags correctly

* Fix expressbuilder issue

* Update ExpressBuilder.cs

Correcting the SitePackages root path

* Fixed the bug where kudu didn't handle symlinks in zip files for zip deploy

* Added functionality to return the deployment log url at the end of a git deployment

* Added functionality to switch between volatile logs and mounted dir logs

* Update ExpressBuilder.cs

Fix typo node_modules.zip

* Minor fixes to the Kudu Ui.Added tail 10 lines to log stream startup

* Increasing log stream timeout and new line fix

* Enable functions detector deeplink

* Add: support for .sh file in PostDeploymentActions

* Add execution mode before running the script

* Add logging for running powershell script in RemoteSigned

* Add support for function app build by oryx

* Fix issue when redeploying using zipdeploy function app

* Add: Url support for ZipDeploy

* Use ReadAsStreamAsync to reduce thread blocking time

* Change sitepackage.txt to packageversion.txt (fixes Azure-App-Service#36)

* Updates for .NET core Builds

* .NET core use temp directory for build

* Fix issues with functionapp build

* Enhance SimpleWebTokenHelper

* Add: HostAssignmentContext

* Remove unnecessary SettingsKeys.cs

* Update function app express build artifacts

* Fix .net core 1.0 and 2.0 builds with oryx

* Add authorization and authentication

* Rename Instance Controller to LinuxConsumptionInstanceAdmin Controller

* Fix: controller name

* Add some comments to explain the /assign and /info endpoints

* Remove PlaceholderMode setting in InitializeProcess

* Remove initialize process

* Move extensions to KuduWebUtils

* Squash Commit
Add admin/instance/assign and admin/instance/info endpoints
Reset launchSettings.json
Rename WebhostEnvironment to LinuxConsumptionEnvironment
Rename InstanceAdmin namespace to LinuxConsumptionInstanceAdmin
Add Linux Consumption Specialization logic

* Added VFS path to log stream, fixed line break problem with logstream

* Update LogStreamManager.cs
  • Loading branch information
sanchitmehta authored Jun 4, 2019
1 parent 30942e3 commit 19acdba
Show file tree
Hide file tree
Showing 50 changed files with 2,177 additions and 56 deletions.
1 change: 0 additions & 1 deletion Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public static TimeSpan MaxAllowedExecutionTime
public const string DurableTask = "durableTask";
public const string Extensions = "extensions";
public const string SitePackages = "SitePackages";
public const string SiteVersionTxt = "siteversion.txt";
public const string PackageNameTxt = "packagename.txt";
public const string KuduBuild = "1.0.0.6";
}
Expand Down
37 changes: 37 additions & 0 deletions Kudu.Contracts/ILinuxConsumptionEnvironment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Threading.Tasks;

namespace Kudu.Contracts
{
public interface ILinuxConsumptionEnvironment
{
/// <summary>
/// Gets a value indicating whether requests should be delayed.
/// </summary>
bool DelayRequestsEnabled { get; }

Task DelayCompletionTask { get; }

/// <summary>
/// Gets a value indicating whether the current environment is in standby mode.
/// </summary>
bool InStandbyMode { get; }

/// <summary>
/// Flags that requests under this environment should be delayed.
/// </summary>
void DelayRequests();

/// <summary>
/// Flags that requests under this environment should be resumed.
/// </summary>
void ResumeRequests();

/// <summary>
/// Flags the current environment as ready and specialized.
/// This sets <see cref="EnvironmentSettingNames.AzureWebsitePlaceholderMode"/> to "0"
/// and <see cref="EnvironmentSettingNames.AzureWebsiteContainerReady"/> to "1" against
/// the current environment.
/// </summary>
void FlagAsSpecializedAndReady();
}
}
5 changes: 5 additions & 0 deletions Kudu.Contracts/Settings/SettingsKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,10 @@ public static class SettingsKeys
public const string RunFromZipOld = "WEBSITE_RUN_FROM_ZIP"; // Old name, will eventually go away
public const string RunFromZip = "WEBSITE_RUN_FROM_PACKAGE";
public const string MaxZipPackageCount = "SCM_MAX_ZIP_PACKAGE_COUNT";
// Antares container specific settings
public const string PlaceholderMode = "WEBSITE_PLACEHOLDER_MODE";
public const string ContainerReady = "WEBSITE_CONTAINER_READY";
public const string AuthEncryptionKey = "WEBSITE_AUTH_ENCRYPTION_KEY";
public const string ContainerEncryptionKey = "CONTAINER_ENCRYPTION_KEY";
}
}
5 changes: 5 additions & 0 deletions Kudu.Core/Deployment/DeploymentContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public class DeploymentContext
/// </summary>
public ILogger GlobalLogger { get; set; }

/// <summary>
/// Repository Path
/// </summary>
public string RepositoryPath { get; set; }

/// <summary>
/// The output path.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Core/Deployment/DeploymentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ await PostDeploymentHelper.SyncFunctionsTriggers(

if (_settings.RunFromLocalZip() && deploymentInfo is ZipDeploymentInfo)
{
await PostDeploymentHelper.UpdateSiteVersion(deploymentInfo as ZipDeploymentInfo, _environment, logger);
await PostDeploymentHelper.UpdatePackageName(deploymentInfo as ZipDeploymentInfo, _environment, logger);
}

FinishDeployment(id, deployStep);
Expand Down
35 changes: 32 additions & 3 deletions Kudu.Core/Deployment/Generator/ExternalCommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Kudu.Contracts.Settings;
using Kudu.Core.Infrastructure;
using Kudu.Core.Tracing;
using Kudu.Core.Helpers;
using NuGet.Versioning;

namespace Kudu.Core.Deployment.Generator
Expand Down Expand Up @@ -61,11 +62,17 @@ public void PostBuild(DeploymentContext context)
{
var fi = new FileInfo(file);
string scriptFilePath = null;
if (string.Equals(".ps1", fi.Extension, StringComparison.OrdinalIgnoreCase))

if (OSDetector.IsOnWindows())
{
scriptFilePath = GetWindowsPostBuildFilepath(context, fi);
}
else if (!OSDetector.IsOnWindows())
{
scriptFilePath = string.Format(CultureInfo.InvariantCulture, "PowerShell.exe -ExecutionPolicy RemoteSigned -File \"{0}\"", file);
scriptFilePath = GetLinuxPostBuildFilepath(context, fi);
}
else

if (string.IsNullOrEmpty(scriptFilePath))
{
scriptFilePath = string.Format(CultureInfo.InvariantCulture, "\"{0}\"", file);
}
Expand Down Expand Up @@ -195,6 +202,7 @@ public IList<string> GetPostBuildActionScripts()
{
var files = FileSystemHelpers.GetFiles(sf, "*")
.Where(f => f.EndsWith(".cmd", StringComparison.OrdinalIgnoreCase)
|| f.EndsWith(".sh", StringComparison.OrdinalIgnoreCase)
|| f.EndsWith(".bat", StringComparison.OrdinalIgnoreCase)
|| f.EndsWith(".ps1", StringComparison.OrdinalIgnoreCase)).ToList();

Expand All @@ -204,5 +212,26 @@ public IList<string> GetPostBuildActionScripts()

return scriptFilesGroupedAndSorted;
}

private string GetLinuxPostBuildFilepath(DeploymentContext context, FileInfo fi)
{
if (string.Equals(".sh", fi.Extension, StringComparison.OrdinalIgnoreCase))
{
context.Logger.Log("Add execute permission for post build script " + fi.FullName);
PermissionHelper.Chmod("ugo+x", fi.FullName, Environment, DeploymentSettings, context.Logger);
return string.Format(CultureInfo.InvariantCulture, "\"{0}\"", fi.FullName);
}
return null;
}

private string GetWindowsPostBuildFilepath(DeploymentContext context, FileInfo fi)
{
if (string.Equals(".ps1", fi.Extension, StringComparison.OrdinalIgnoreCase))
{
context.Logger.Log("Execute post build script with RemoteSigned policy " + fi.FullName);
return string.Format(CultureInfo.InvariantCulture, "PowerShell.exe -ExecutionPolicy RemoteSigned -File \"{0}\"", fi.FullName);
}
return null;
}
}
}
87 changes: 76 additions & 11 deletions Kudu.Core/Deployment/Generator/OryxBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System.Threading.Tasks;
using Kudu.Core.Helpers;
using Kudu.Contracts.Settings;
using Kudu.Core.Deployment.Oryx;
using Kudu.Core.Infrastructure;
using System.IO;
using System;
using Kudu.Core.Commands;

namespace Kudu.Core.Deployment.Generator
{
Expand All @@ -17,36 +22,96 @@ public override Task Build(DeploymentContext context)
{
FileLogHelper.Log("In oryx build...");

// Step 1: Run kudusync
// initialize the repository Path for the build
context.RepositoryPath = RepositoryPath;

string kuduSyncCommand = string.Format("kudusync -v 50 -f {0} -t {1} -n {2} -p {3} -i \".git;.hg;.deployment;.deploy.sh\"",
RepositoryPath,
context.OutputPath,
context.NextManifestFilePath,
context.PreviousManifestFilePath
);
// Initialize Oryx Args.
IOryxArguments args = OryxArgumentsFactory.CreateOryxArguments();

FileLogHelper.Log("Running KuduSync with " + kuduSyncCommand);
if (!args.SkipKuduSync)
{
// Step 1: Run kudusync
string kuduSyncCommand = string.Format("kudusync -v 50 -f {0} -t {1} -n {2} -p {3} -i \".git;.hg;.deployment;.deploy.sh\"",
RepositoryPath,
context.OutputPath,
context.NextManifestFilePath,
context.PreviousManifestFilePath
);

RunCommand(context, kuduSyncCommand, false, "Oryx-Build: Running kudu sync...");
FileLogHelper.Log("Running KuduSync with " + kuduSyncCommand);

OryxArguments args = new OryxArguments();
RunCommand(context, kuduSyncCommand, false, "Oryx-Build: Running kudu sync...");
}

if (args.RunOryxBuild)
{
PreOryxBuild(context);

string buildCommand = args.GenerateOryxBuildCommand(context);
RunCommand(context, buildCommand, false, "Running oryx build...");

//
// Run express build setups if needed
if (args.Flags == BuildOptimizationsFlags.UseExpressBuild)
{
Oryx.ExpressBuilder.SetupExpressBuilderArtifacts(context.OutputPath);
if (FunctionAppHelper.LooksLikeFunctionApp())
{
SetupFunctionAppExpressArtifacts(context);
}
else
{
Oryx.ExpressBuilder.SetupExpressBuilderArtifacts(context.OutputPath);
}
}
}

return Task.CompletedTask;
}

private static void PreOryxBuild(DeploymentContext context)
{
if (FunctionAppHelper.LooksLikeFunctionApp())
{
// We need to delete this directory in order to avoid issues with
// reinstalling Python dependencies on a target directory
var pythonPackagesDir = Path.Combine(context.OutputPath, ".python_packages");
if (Directory.Exists(pythonPackagesDir))
{
FileSystemHelpers.DeleteDirectorySafe(pythonPackagesDir);
}
}
}

private void SetupFunctionAppExpressArtifacts(DeploymentContext context)
{
string sitePackages = "/home/data/SitePackages";
string packageNameFile = Path.Combine(sitePackages, "packagename.txt");
string packagePathFile = Path.Combine(sitePackages, "packagepath.txt");

FileSystemHelpers.EnsureDirectory(sitePackages);

string zipAppName = $"{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.zip";
string zipFile = Path.Combine(sitePackages, zipAppName);

context.Logger.Log("Writing the artifacts to a zip file");
var exe = ExternalCommandFactory.BuildExternalCommandExecutable(OryxBuildConstants.FunctionAppBuildSettings.ExpressBuildSetup, sitePackages, context.Logger);
try
{
exe.ExecuteWithProgressWriter(context.Logger, context.Tracer, $"zip -r {zipFile} .", String.Empty);
}
catch (Exception)
{
context.GlobalLogger.LogError();
throw;
}

// Just to be sure that we don't keep adding zip files here
DeploymentHelper.PurgeZipsIfNecessary(sitePackages, context.Tracer, totalAllowedZips: 3);

File.WriteAllText(packageNameFile, zipAppName);
File.WriteAllText(packagePathFile, sitePackages);
}

//public override void PostBuild(DeploymentContext context)
//{
// // no-op
Expand Down
Loading

0 comments on commit 19acdba

Please sign in to comment.