# Private repositories

> Deploy a Docker site from a private Git repository with a team private key.

Source: https://vantuly.com/docs/apps/sites/docker/private-repositories

## Deploy from a private repository

The **Private Repository (with Deploy Key)** option clones over SSH with a **team private key**. The steps are Type, Details, Server, Deploy key, Repository, Domain and Review.

1. **Server.** Pick the server. The repository is checked there, and the site goes there.
2. **Deploy key.** Choose one of the team's keys, or click **Generate new key**. The public key and its fingerprint are shown for each key.
3. Add the **public key** to the repository as a read-only deploy key (on GitHub: the repository's **Settings → Deploy keys**; GitLab and Bitbucket have the same setting).
4. **Repository.** Paste the SSH address (`git@github.com:acme/app.git` or `ssh://git@host:2222/acme/app.git`) and click **Check repository**. Smart Scan reads the repository on your server, as for a public one. A GitHub, GitLab or Bitbucket `https://` address works too and is cloned over SSH with the key.

Deploys, **Test access** and **Redeploy** use the same key. A site's own deploy key (see [Deploy from Git](/docs/guides/git-deploy)) is separate; generating one for a site drops its team key.

## Private keys

**Settings → Team → Private keys** lists the team's keys. Owners and admins can generate an ED25519 or RSA key, add an existing one, rename a key or delete it. A team can have 50 keys and generate 10 an hour. The list shows which sites use each key, and only to the people who manage the team.

- The private half is encrypted when you save it and is never shown again, not even to owners. Only the public half is shown.
- On the server the key sits in a folder only root can read. A deploy hands it to `git` through a short-lived agent, so the site's user and the code it runs cannot read the key.
- A key that sites use cannot be deleted. Give those sites another key first.
- The Ask AI assistant cannot create, rename or delete keys.

The repository's host must resolve to a **public address** when a team key is used, and the connection goes to the address that was checked. A Git server on a private network works with a site's own deploy key instead.

## Requirements

- A server you brought yourself (an install-command server, or a machine created with your own cloud account).
- At least 2 GB of memory and 10 GB of free disk. Vantuly installs Docker the first time a Docker site needs it.
- A site counts its containers' memory limits against the server. Zero-downtime Dockerfile sites count double, because two copies run for a moment during a deploy.

## Smart Scan

**Check repository** reads the repository on your server without checking out the code, and reports:

- **Docker Compose selected** when there is a compose file in the base directory (it wins over a Dockerfile), or **Dockerfile** when there is only that. Files only in subdirectories are listed so you can pick one.
- The **port** from the Dockerfile's `EXPOSE`.
- Environment templates (`.env.example`, `.env.sample` and similar). Click **Review** to import the variables into the site's environment.
- **Submodules**, and whether each one can be reached. A private submodule is skipped with a line in the deployment log and the deploy goes on.
- Values that **look unset** (see below).

Change the **Base directory**, **Dockerfile** or **Docker Compose file** and click **Scan again**. If the repository is private or missing, Vantuly says it needs credentials and you can use the Private Repository option or a GitHub App instead.

## Values that look unset

Many compose files ship with values you are meant to change, like `APP_SECRET: REPLACE_WITH_LONG_SECRET`, `STRONG_DB_PASSWORD` or `APP_URL: http://localhost:3000`. Left alone, the app crash-loops. Smart Scan lists them, and Vantuly suggests a random secret for each and `${SERVICE_URL_<SERVICE>}` for a localhost address. A value used in several places (the password in both the app's database URL and the database service) is one row. Review or edit the list before the first deploy; the values are kept encrypted and applied on every deploy. Change them later in **Settings → Docker**.

## Compose files

Services reach each other by name on the project's own network. Everything is internal until a domain goes to it.

- **Domains.** On the **Domains** tab, choose **Goes to** a service and port, and optionally a path (`example.com/api` can go to a different service from `example.com`). A domain with no choice goes to the main service.
- **Ports.** `ports:` in a repository's compose file is accepted but not published; a domain goes to the container port instead.
- **Variables.** `SERVICE_URL_<SERVICE>` and `SERVICE_FQDN_<SERVICE>` (add `_<PORT>` for a specific port) are filled from the domains. A service that uses one and has no domain gets one generated. Any other `${VAR}` comes from the **Environment** tab, and `${VAR:?}` stops the deploy until it has a value.
- **One-shot services.** Add `exclude_from_hc: true` to a service that is meant to exit, such as a migration job.
- **Memory.** A service without `mem_limit` gets 512 MB.

For safety, Vantuly refuses compose files that ask for more than an app needs: `privileged`, host networking, added capabilities, devices, the Docker socket, bind mounts outside the site's data folder, `container_name`, and `include`/`extends`. The error names the line. Volumes and bind mounts are kept in the site's own data folder.

## Deploying

| | Dockerfile site | Compose site |
|---|---|---|
| Update | **Zero downtime** | Brief restart |
| How | A second copy starts, must pass its health check, then takes over; the old one is stopped after a grace period | The project restarts |

A single-service compose file also gets zero-downtime unless a domain goes to a second port of that service.

For zero-downtime, the new copy must answer on the **health path** (default `/`) with anything below 500, and pass the image's `HEALTHCHECK` if it has one, within 5 minutes. If it does not, it is removed, the old copy keeps serving, and the deployment fails with the last log lines. If the server has no room for a second copy, Vantuly restarts briefly instead and says why in the log.

Turn **Zero-downtime** off in **Settings → Docker** for apps that cannot run two copies at once (a SQLite file, a scheduler that must run once, migrations the old version cannot survive).

On the **Deployments** tab each row shows the commit, the image and whether it ran with zero downtime or a brief restart. Use **Redeploy**, **Redeploy (no cache)** to rebuild without the build cache, or **Rollback** to run an earlier deployment as it was, without building again.

Builds use a builder that belongs to the site, so one site cannot see another's images or cache. Old images are cleaned up after each successful deploy.


## Automatic deployments

A repository connected through a GitHub App deploys on every push. For a public repository or a deploy key, open **Source → Automatic deployments**. It lists the webhook for GitHub, GitLab, Bitbucket and Gitea with that host's field names, the URL and the secret (click **Generate new secret** to replace it). The secret is checked on every delivery. To deploy from CI, the same section shows a `curl` command that uses an API token with the deploy scope.

A public repository has no deploy key, and Vantuly cannot add the webhook for you because that needs admin rights on someone else's repository.

## Private registries

To pull private images, add the registry under **Settings → Team → Registries** (owners and admins). Choose Docker Hub, GHCR, GitLab, Google Artifact Registry, AWS ECR, Azure ACR or a custom host. **Test** checks the login from the panel.

Vantuly matches each image's host to your registries and logs in for that deploy only. The login is written to a root-only folder on the server and removed when the deploy ends. A private base image in a Dockerfile needs its registry picked in **Settings → Docker**. A registry that a site uses cannot be removed.

## Backups

Backups work like any site, with one difference for databases. Postgres (including PostGIS, pgvector and Timescale), MySQL, MariaDB and MongoDB services are detected from their image, dumped before each backup, and their data folders are left out. A restore loads the dump. Other services are backed up as files; the Backups card lists them as "files only". To force the choice, set the label `x-vantuly-dump: postgres`, `mysql` or `none` on a service.

## Settings

**Settings → Docker** holds the source, Dockerfile path, build context, build target and build arguments, port, health path, zero-downtime and its stop grace period (default 30 seconds), replaced values and the registry for each image host. Saving redeploys.

## Security

- Containers run with `no-new-privileges`, a process limit, and the network capability `NET_RAW` dropped.
- Containers and builds cannot reach the cloud provider's metadata address (`169.254.169.254` and similar).
- Git addresses that resolve to private or internal addresses are refused on the server.
- Public repositories are cloned over HTTPS without credentials and without following redirects.
- A team private key never reaches a place a site can read, and an SSH address that resolves to a private or internal address is refused for it.

Because a Docker site builds and runs code from a repository, only connect repositories you trust.
