Move packaging process into own plugin
Problem
The packaging process should be moved into an own plugin. Status: Done --> See https://github.com/serverless/serverless/pull/1494 This includes: - [x] Zipping up a whole service - [x] One service equals one zip file which includes all the necessary code (all functions) - [x] Magic handler support will be dropped (as it's not necessary anymore) - [x] There will be no checksum to check if something has changed - The zipped up service will be redeployed every time (this ensure that the build "will always work" as no brittle steps as e.g. checksum support will be implemented) - [x] Possibility to set a path to an own artefact (.zip file) via a definition in the `serverless.yaml` file (e.g. `artefact_path`). This way the deployment plugin will use the user specified artefact and won't zip up everything on it's own Questions: - Do we need an own lifecycle in the `deploy` plugin? Or should we use `before:deploy:deploy`? Current implementation: The current implementation can be found in the `awsDeploy` plugin. Open issues: - DRYrun support should be implemented (The user should be able to specify if he wants to save the Resource template (such as `CloudFormation`) and the .zip file to the file system without deploying it) (moved into own issue: https://github.com/serverless/serverless/issues/1496) - Automatic excludes based on the used programming language (moved into own issue: https://github.com/serverless/serverless/issues/1495) - e.g. exclude `src`, `pom` and `traget`
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Refactor Packaging Process into Dedicated Plugin
The current packaging process is tightly coupled with the deployment logic in the `awsDeploy` plugin, leading to a lack of modularity and flexibility. By moving the packaging process into its own plugin, we can streamline the deployment process and allow for better customization and maintenance.
Awaiting Verification
Be the first to verify this fix
- 1
Create New Packaging Plugin
Develop a new plugin that handles the zipping of the service. This plugin should be responsible for creating a single zip file containing all necessary code for deployment.
javascriptmodule.exports = { package: { individually: true } }; - 2
Implement Artifact Path Configuration
Add functionality to allow users to specify a custom artifact path in the `serverless.yaml` file. This will enable users to define where the zip file should be stored.
yamlartifact_path: './custom/path/to/artifact.zip' - 3
Remove Magic Handler Support
Ensure that the magic handler support is removed from the packaging process, as it is no longer necessary. This will simplify the code and reduce potential confusion.
javascript// Remove magic handler logic from packaging code - 4
Implement Always Redeploy Logic
Modify the deployment logic to ensure that the zipped service is redeployed every time, eliminating the need for checksum checks. This guarantees that the build will always work without brittle steps.
javascriptthis.serverless.service.package.artifact = this.serverless.service.package.artifact || 'default.zip'; - 5
Add DRYrun Support
Implement a DRYrun feature that allows users to save the Resource template and the zip file to the file system without deploying it. This should be a separate command in the new plugin.
javascript// Example command for DRYrun serverless dryrun
Validation
To confirm the fix worked, deploy a service using the new packaging plugin and verify that the zip file is created correctly at the specified artifact path. Additionally, check that the deployment occurs without checksum checks and that the magic handler support is absent.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep