# Output Blocks

The `output_blocks` setting can be used to inject commands directly into the {file}`Dockerfile` generated by
the OU Container Builder.

:::{warning}
This is the equivalent of a nuclear-powered chainsaw. Beware. Any mistakes in the custom output blocks
are likely to prevent the VCE from building or running.
:::

:::{code-block} yaml
output_blocks:
  build:
    - block:    # The block text to write into the Dockerfile
      weight:   # Weight used for ordering the output blocks
  deploy:
    - block:
      weight:
:::

All blocks are sorted using the `weight` and then the `block` text is written as-is to the {file}`Dockerfile`.
The {doc}`../../developer/output_block_weights` lists weight values and what activities are allocated to which weight ranges.
Blocks defined in the {file}`Configuration.yaml` should use weights from ranges that are marked as "Free", to
ensure stable and repeatable behaviour.

## Common Recipies

Here are a set of common recipies for which the `output_blocks` need to be used.

### Copying data into the build stage

To copy data into the build stage, for use in build scripts, adapt the following snippet:

:::{code-block} yaml
output_blocks:
  build:
    - block: COPY source.tar.gz /target/location.tar.gz
      weight: 201
:::

This ensures that the file is copied before any {doc}`scripts <scripts>` are run and is available to those scripts.

### Copying data from build to deploy stage

If building software in the build stage, to copy data into the final deploy VCE image, adapt the following snippet:

:::{code-block} yaml
output_blocks:
  deploy:
    - block: COPY --from=base /path/to/build/output /target/location
      weight: 2001
:::
