Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions src/BuildProcess/CompressApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ public function __invoke()

if (PHP_OS == 'Darwin') {
$this->compressApplicationOnMac();
$this->ensureCompressedApplicationSizeIsWithinSizeLimits($this->getCompressedApplicationSizeInBytes());

return $this->ensureArchiveIsWithinSizeLimits($appSizeInBytes);
}

$archive = new ZipArchive();

$archive->open($this->buildPath.'/app.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
$archive->open($this->getCompressedApplicationPath(), ZipArchive::CREATE | ZipArchive::OVERWRITE);

foreach (BuiltApplicationFiles::get($this->appPath) as $file) {
$relativePathName = str_replace('\\', '/', $file->getRelativePathname());
Expand All @@ -53,17 +54,39 @@ public function __invoke()

$archive->close();

$this->ensureCompressedApplicationSizeIsWithinSizeLimits($this->getCompressedApplicationSizeInBytes());

$this->ensureArchiveIsWithinSizeLimits($appSizeInBytes);
}

/**
* Get the full path of the compressed application (zip file).
*
* @return string
*/
protected function getCompressedApplicationPath()
{
return $this->buildPath.'/app.zip';
}

/**
* Get the size of the zip file in bytes.
*
* @return int
*/
protected function getCompressedApplicationSizeInBytes()
{
return filesize($this->getCompressedApplicationPath());
}

/**
* Utilize the "zip" utility to compress the application.
*
* @return void
*/
protected function compressApplicationOnMac()
{
(new Process(['zip', '-r', $this->buildPath.'/app.zip', '.'], $this->appPath))->mustRun();
(new Process(['zip', '-r', $this->getCompressedApplicationPath(), '.'], $this->appPath))->mustRun();
}

/**
Expand All @@ -80,7 +103,7 @@ protected function getPermissions($file)
}

/**
* Ensure the application archive is within supported size limits.
* Ensure the uncompressed application archive is within supported size limits.
*
* @param float $bytes
* @return void
Expand All @@ -95,6 +118,22 @@ protected function ensureArchiveIsWithinSizeLimits($bytes)
}
}

/**
* Ensure the compressed application is within supported size limits.
*
* @param float $bytes
* @return void
*/
protected function ensureCompressedApplicationSizeIsWithinSizeLimits($bytes)
{
$size = ceil($bytes / 1048576);

if ($size > 50) {
Helpers::line();
Helpers::abort('Compressed application is greater than 50MB. Your compressed application is '.$size.'MB.');
}
}

/**
* Get the size of the given directory.
*
Expand Down
6 changes: 3 additions & 3 deletions src/BuildProcess/ValidateManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function warnAboutDeprecations()
Helpers::warn(
'- The "separate-vendor" option is deprecated.'
.' Please use Docker based deployments instead:'
.' https://docs.vapor.build/1.0/projects/environments.html#runtime'
.' https://docs.vapor.build/projects/environments#docker-runtimes'
);
}

Expand All @@ -45,14 +45,14 @@ protected function warnAboutDeprecations()
])) {
Helpers::warn(
'The runtimes "php-7.3", "php-7.4", "php-7.4:al2", "php-7.4:imagick", and "php-8.0" are deprecated and will no longer be supported or receiving any updates.'
.' For a full list of supported runtimes, please see: https://docs.vapor.build/1.0/projects/environments.html#runtime'
.' For a full list of supported runtimes, please see: https://docs.vapor.build/projects/environments#runtime'
);
}

if (Manifest::runtime($this->environment) === 'php-8.0:al2') {
Helpers::warn(
'The runtime "php-8.0:al2" is now deprecated and it is no longer possible to deploy new environments using this runtime. Support will be removed for existing runtimes on February 26, 2024.'
.' For a full list of supported runtimes, please see: https://docs.vapor.build/1.0/projects/environments.html#runtime'
.' For a full list of supported runtimes, please see: https://docs.vapor.build/projects/environments#runtime'
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Solutions/EnvironmentVariableLimitReached.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function applicable()
public function all()
{
return [
'Use encrypted environment files in place of or in addition to environment variables: https://docs.vapor.build/1.0/projects/environments.html#encrypted-environment-files',
'Use encrypted environment files in place of or in addition to environment variables: https://docs.vapor.build/projects/environments#encrypted-environment-files',
];
}
}
2 changes: 1 addition & 1 deletion src/Solutions/FunctionExceedsMaximumAllowedSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function all()
.' Docker based deployments allow you to package and deploy applications up to 10GB in size.'
.' When migrating an existing environment to a Docker runtime, please keep in mind that you won\'t be able to revert that environment to the default Vapor Lambda runtime later.'
.' For that reason, you may want to create an environment for testing the Docker runtime first.'
.' https://docs.vapor.build/1.0/projects/environments.html#building-custom-docker-images',
.' https://docs.vapor.build/projects/environments#docker-runtimes',
];
}
}