> ## Documentation Index
> Fetch the complete documentation index at: https://docs.airelabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# No Internet: Bundling Data

> Why container functions run without network access, and how to build the data your code needs into the image — including data from remote sources.

Your container cannot reach the internet when it runs. Every file your code needs, such as price curves, weather data, lookup tables, or model weights, must be inside the image when it is built. Building the image has full network access, so this is where you download data and install packages.

## Why there is no network

### Your results stay reproducible

A published version of your function is an immutable image. Once `v1.2.1` is pushed, its code and its data never change. Every model that runs `v1.2.1` runs exactly that code against exactly that data, today and in five years.

If the container downloaded its data on every run, that promise would break in two ways:

* **Unstable runs.** When the upstream site is slow, down, rate-limiting, or has moved the file, your model fails, even though nothing in your model changed.
* **Numbers that change on their own.** When the upstream source publishes a revised file, the same model with the same inputs silently produces different results. Nobody can reproduce last month's numbers or explain why they moved.

The platform can also reuse a recent result when a function runs again with the same image and the same inputs. That is only correct because the image and the inputs fully determine the result.

### Your code and your data stay isolated

Container functions run your code on shared infrastructure, next to other organizations' work. Each run is sandboxed:

* **No network.** No internet, no internal Aire Labs services, no other customers' containers. This is fixed and cannot be turned on.
* **Read-only filesystem**, except for `/tmp`.
* **Memory, CPU, and time limits** for each run.

The only way in or out is the input and output JSON files. Even code you did not write, such as a dependency several levels down, cannot send your model's inputs anywhere.

## Bundle files in your repository

The simplest approach: commit the files and copy them into the image. Both example repositories do this with a `data/` folder:

```text theme={null}
my-container-function/
├── Dockerfile
├── main.py
├── data/
│   └── capex_by_year.csv    # copied into the image by COPY
└── scripts/
    └── fetch_data.py        # run on your machine, never in the container
```

`COPY . /app` in the Dockerfile copies `data/` into the image. Read files relative to your code, not to the working directory:

```python Python theme={null}
from pathlib import Path

DATA_DIR = Path(__file__).resolve().parent / "data"
capex = (DATA_DIR / "capex_by_year.csv").read_text()
```

```r R theme={null}
capex <- read.csv(file.path("data", "capex_by_year.csv"))
# The R example's Dockerfile sets WORKDIR /app, and CMD runs main.R from there.
```

If the data comes from a public source, keep a small script that downloads it, run it on your own machine, and commit what it writes. The download happens when you choose, and you review the diff before it ships:

```python scripts/fetch_data.py theme={null}
import urllib.request
from pathlib import Path

URL = "https://example.org/capex_by_year.csv"
OUT = Path(__file__).resolve().parent.parent / "data" / "capex_by_year.csv"

urllib.request.urlretrieve(URL, OUT)
print(f"wrote {OUT}")
```

```bash R theme={null}
Rscript -e "download.file('https://example.org/capex_by_year.csv', 'data/capex_by_year.csv')"
git add data/capex_by_year.csv
```

This works well for files up to tens of megabytes. For larger files, download them during the build instead.

## Download remote data during `docker build`

`docker build` has network access, so the Dockerfile can fetch a file from a remote source and store it in the image. Pin the file's SHA-256 checksum. If the upstream file changes, the build fails instead of silently changing your numbers.

### A single file: `ADD --checksum`

```dockerfile Dockerfile theme={null}
ADD --checksum=sha256:d7ffee5005cc065cd2f433f338d6b3ee44ac43e1835edaa367c6608bc3f81b03 \
    https://raw.githubusercontent.com/airelabsresearch/integration-language-python/main/data/solar.csv \
    /app/data/solar.csv
```

Get the checksum by downloading the file once:

```bash theme={null}
curl -sL https://example.org/capex_by_year.csv | shasum -a 256
```

If the file no longer matches, the build stops with `digest mismatch`. Download it again, check what changed, update the checksum, and publish a new version.

### Archives and multiple files: `RUN`

For a zip or tarball, or several files, download and verify them in a `RUN` step:

```dockerfile Dockerfile theme={null}
RUN curl -fsSL -o /tmp/nsrdb.zip https://example.org/nsrdb-2024.zip \
 && echo "<sha256>  /tmp/nsrdb.zip" | sha256sum -c - \
 && mkdir -p /app/data/nsrdb \
 && unzip -q /tmp/nsrdb.zip -d /app/data/nsrdb \
 && rm /tmp/nsrdb.zip
```

`curl` and `unzip` must be in your base image. Add them with `apt-get install` if they are not.

### Data that needs credentials

If the source needs an API key or token, pass it as a build secret, not a build argument or an environment variable. A build secret is available only to the one `RUN` step that mounts it and is not stored in the image:

```dockerfile Dockerfile theme={null}
RUN --mount=type=secret,id=data_token \
    curl -fsSL -H "Authorization: Bearer $(cat /run/secrets/data_token)" \
      -o /app/data/prices.csv https://api.example.com/prices.csv
```

```bash theme={null}
docker build --secret id=data_token,env=DATA_TOKEN -t my-function .
```

In the [publishing workflow](https://docs.airelabs.com/developer/publishing-container-functions.md), store the token as a repository secret. Expose it to the build step with `env: DATA_TOKEN: ${{ secrets.DATA_TOKEN }}`, and add the same `--secret id=data_token,env=DATA_TOKEN` flag to its `docker buildx build` command. See the [Docker build secrets guide](https://docs.docker.com/build/building/secrets/).

> [!WARNING]
>
> Anything your Dockerfile writes into the image ships with it. That includes everything a `COPY` picks up, such as a `.env` file. Build secrets are the exception: they are never written to the image. Add files you don't want shipped to `.dockerignore`.

### Packages

Install language packages in the Dockerfile, never at runtime. In Python, list them in `pyproject.toml` and lock them with `uv lock`. In R, use `install.packages()` in a `RUN` step, or [renv](https://rstudio.github.io/renv/articles/docker.html) to lock versions. Code that tries to install a package at runtime fails, because there is no network.

## Updating the data: publish a new version

To use newer data, update the files or the checksum and publish a new version, for example `v1.2.2`. Models pinned to `v1.2.1` keep producing the same results. Switch a block to `v1.2.2` when you want that model to use the new data.

Treat a new dataset exactly like new code. Registry tags are immutable, so you cannot change what an existing version contains.

## Test without network locally

Run your container with `--network none` to reproduce the platform's sandbox on your machine. Code that still tries to reach the network fails here instead of in your model:

```bash theme={null}
docker run --rm --network none --read-only --tmpfs /tmp \
  -v /tmp/airelabs:/airelabs \
  -e AIRELABS_HOOK_INPUT_PATH=/airelabs/hook-input.json \
  -e AIRELABS_HOOK_OUTPUT_PATH=/airelabs/hook-output.json \
  my-function
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.