github.com/hashicorp/packer@v1.14.3/website/content/docs/post-processors/compress.mdx (about)

     1  ---
     2  description: |
     3    The `compress` post-processor compresses an artifact that contains multiple files, such as VMware of VirtualBox builds, into a single archive.
     4  page_title: compress post-processor reference
     5  ---
     6  
     7  <BadgesHeader>
     8    <PluginBadge type="official" />
     9  </BadgesHeader>
    10  
    11  # `compress` post-processor
    12  
    13  Artifact BuilderId: `packer.post-processor.compress`
    14  
    15  The Packer compress post-processor takes an artifact with files, such as from
    16  VMware or VirtualBox, and compresses the artifact into a single archive.
    17  
    18  ## Configuration
    19  
    20  ### Optional:
    21  
    22  By default, packer will build archives in `.tar.gz` format with the following
    23  filename: `packer_{{.BuildName}}_{{.BuilderType}}`. If you want to change this
    24  you will need to specify the `output` option.
    25  
    26  - `output` (string) - The path to save the compressed archive. The archive
    27    format is inferred from the filename. E.g. `.tar.gz` will be a gzipped
    28    tarball. `.zip` will be a zip file. If the extension can't be detected
    29    packer defaults to `.tar.gz` behavior but will not change the filename.
    30  
    31    This is treated as a
    32    [template engine](/packer/docs/templates/legacy_json_templates/engine). Therefore, you
    33    may use user variables and template functions in this field.
    34    The following special variables are also available to use in the output
    35    template:
    36  
    37    - `{{.BuildName}}`
    38    - `{{.BuilderType}}`
    39  
    40    If you are executing multiple builders in parallel you should make sure
    41    `output` is unique for each one. For example `packer_{{.BuildName}}.zip`.
    42  
    43  - `format` (string) - Disable archive format autodetection and use provided
    44    string.
    45  
    46  - `compression_level` (number) - Specify the compression level, for
    47    algorithms that support it, from 1 through 9 inclusive. Typically higher
    48    compression levels take longer but produce smaller files. Defaults to `6`
    49  
    50  - `keep_input_artifact` (boolean) - if `true`, keep both the source files and
    51    the compressed file; if `false`, discard the source files. Defaults to
    52    `false`
    53  
    54  ### Supported Formats
    55  
    56  Supported file extensions include `.zip`, `.tar`, `.gz`, `.tar.gz`, `.lz4` and
    57  `.tar.lz4`. Note that `.gz` and `.lz4` will fail if you have multiple files to
    58  compress.
    59  
    60  ## Examples
    61  
    62  Some minimal examples are shown below, showing only the post-processor
    63  configuration:
    64  
    65  ```json
    66  {
    67    "type": "compress",
    68    "output": "archive.tar.lz4"
    69  }
    70  ```
    71  
    72  ```json
    73  {
    74    "type": "compress",
    75    "output": "{{.BuildName}}_bundle.zip"
    76  }
    77  ```
    78  
    79  ```json
    80  {
    81    "type": "compress",
    82    "output": "log_{{.BuildName}}.gz",
    83    "compression_level": 9
    84  }
    85  ```