# Installing dependencies

If your policy requires dependencies, you have two options depending on your execution environment:

1. **Custom Docker image** - Install dependencies at build time in your Dockerfile
2. **Native execution** - Dependencies are installed automatically at runtime

Your `requirements.txt` should contain the `lunar_policy` package at a minimum:

```txt
lunar_policy==0.1.6
```

## Custom Docker Image

When running in containers, create a custom Docker image with all dependencies pre-installed. This provides faster startup times, reproducible builds, and eliminates network dependencies at runtime.

Create a Dockerfile that inherits from the official `earthly/lunar-scripts` image and installs your dependencies at build time:

{% code title="Dockerfile" %}

```dockerfile
FROM earthly/lunar-scripts:1.0.0

# Copy and install Python dependencies
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt && rm /tmp/requirements.txt
```

{% endcode %}

Then configure your plugin or `lunar-config.yml` to use this image:

```yaml
image: my-org/my-custom-image:v1.0
```

For more details on image configuration, see [Images](/configuration/lunar-config/images.md).

## Native Execution

When running with `image: native` (no container), place your `requirements.txt` in the same directory as your `lunar-config.yml` or `lunar-policy.yml` file. Dependencies are installed automatically before the policy is run, and only once in each environment.

## Development convenience with `earthly/lunar-scripts`

The official `earthly/lunar-scripts` image automatically installs dependencies from any `requirements.txt` file found in the plugin directory as part of its entrypoint. This is a convenience feature for quick development iteration, but baking dependencies into your image provides faster startup times in production.

To override this behavior, you can change the `ENTRYPOINT` in your Dockerfile. For example:

```dockerfile
ENTRYPOINT ["/usr/bin/python3"]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-lunar.earthly.dev/plugin-sdks/python-sdk/dependencies.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
