mix lambda.build (Mayfly v0.1.0)
View SourceA Mix task for building AWS Lambda deployment packages for Elixir applications.
This task creates a deployment package for AWS Lambda, including:
- Building a release using
mix release - Creating a bootstrap script
- Optionally building in a Docker container
- Optionally creating a ZIP archive for deployment
Usage
mix lambda.build [options]Options
--zip, -z - Create a ZIP file for deployment
--outdir, -o - Specify the output directory (default: current directory)
--docker, -d - Build using Docker (useful for cross-platform compatibility)
--help, -h - Print this help messageExamples
# Build a release
mix lambda.build
# Build a release and create a ZIP file
mix lambda.build --zip
# Build using Docker and create a ZIP file
mix lambda.build --docker --zip
# Specify an output directory
mix lambda.build --zip --outdir ./deploy
Summary
Functions
Generates the content for the bootstrap script.
Builds the release using mix release.
Creates the bootstrap file.
Creates a ZIP archive if requested.
Handles Docker build if requested.
Parses and validates command line arguments.
Prints help information.
Prints a summary of the build process.
Restores the original environment.
Runs the Lambda build task.
Runs a system command and handles the result.
Sets up the build environment.
Functions
Generates the content for the bootstrap script.
@spec build_release() :: :ok | {:error, String.t()}
Builds the release using mix release.
Returns :ok if successful.
Creates the bootstrap file.
Returns {:ok, bootstrap_path} if successful.
Creates a ZIP archive if requested.
Returns :ok if successful or if ZIP creation was not requested.
Handles Docker build if requested.
Returns :ok if successful or if Docker build was not requested.
@spec parse_and_validate_args([String.t()]) :: {:ok, keyword()} | {:halt, :help} | {:error, String.t()}
Parses and validates command line arguments.
Returns {:ok, opts} if successful, {:halt, :help} if help was requested,
or {:error, reason} if validation fails.
@spec print_help() :: :ok
Prints help information.
@spec print_summary(keyword()) :: :ok
Prints a summary of the build process.
@spec restore_environment(String.t() | nil) :: :ok
Restores the original environment.
Returns :ok if successful.
Runs the Lambda build task.
This is the main entry point for the mix task, orchestrating the build process.
Runs a system command and handles the result.
Returns {:ok, output} if successful, or {:error, reason} if the command fails.
@spec setup_environment() :: String.t() | nil
Sets up the build environment.
Sets MIX_ENV to "lambda" and returns the original value.