# Packaging

Extraction plugins are packaged as OCI images (also known as Docker images).
The OCI images are _labeled_ with the PluginInfo.
To automate packaging of a Python plugin and labeling the OCI image,
the Extraction Plugin SDK comes with a utility application `build_plugin`.

Make sure that the Extraction Plugins SDK is [installed](getting_started.md#Installation) as well as Docker.

Then, build your plugin container image using the following command:

```bash
build_plugin PLUGIN_FILE DOCKER_FILE_DIRECTORY [DOCKER_IMAGE_NAME] [DOCKER_ARGS]
```

For example:
```bash
build_plugin chatplugin.py . chatplugin --build-arg http_proxy="$http_proxy" --build-arg https_proxy="$https_proxy"
```

This will generate a plugin image:
* The extraction plugin is added to your local image registry (`docker images`),
* Note that the variables `$http_proxy` and `$https_proxy` are put in quotes, this is needed in case they contain
  spaces,
* The image is tagged with two tags: `latest`, and your plugin version.

Arguments:
* PLUGIN_FILE: Path to the python file of the plugin.
* DOCKER_FILE_DIRECTORY: Path to the directory containing the Dockerfile of the plugin.
* (Optional) [DOCKER\_IMAGE\_NAME]: Name of the docker image without tag. Note that docker image names cannot start with
  a period or dash. If it starts with a dash, it will be interpreted as an additional docker argument (see
  DOCKER\_ARGS). If no name is given the name defaults to `extraction-plugin/PLUGINID`, e.g.
  `extraction-plugin/nfi.nl/extract/chat/whatsapp`.
* (Optional) [DOCKER\_ARGS]: Additional arguments for the docker command, which can be as many arguments as you like.

To verify that the image has been built, type the following command to view all local images:
```bash
docker images
```

Once your plugin is packaged, it can be published or 'uploaded' to Hansken.
See ":ref:`upload_plugin`" for instructions.

