Deploying with Docker
This guide assumes you already have a PostgreSQL (or Postgres-compatible) database running and helps you set up prestd with Docker.
In case youβd like to run prestd with a fresh PostgreSQL database, follow this guide to deploy prestd along with a Postgres instance using Docker Compose.
Prerequisites
Docker (version 20.10.7 or later)
Docker Compose (version 1.29.2 or later)
Create an installation folder called prestd where you would like your prestd installation and data storage.
cd (open/join) into the installation folder.
Quick Start
We will use docker to run pREST and connect to an existing database. To simplify the example we leave the authentication module off and enable debug mode (which disables JWT enforcement).
docker run -d -p 3000:3000 \
-e PREST_VERSION=2 \
-e PREST_PG_URL=postgres://username:password@hostname:port/dbname \
-e PREST_DEBUG=true \
prest/prest:v2.5.2v2 JWT requirement: when
PREST_DEBUGis not set andjwt.defaultis enabled, configurePREST_JWT_KEY(orPREST_JWT_JWKS/PREST_JWT_WELLKNOWNURL) explicitly. In v2+, missing verification material auto-disables JWT with a warning β the server still starts. The v2.0.0-rc6 tagged binary refuses to start in that case. See Configuring pREST.
Docker images: v2 images are built via GoReleaser. Pin to a specific tag like
v2.5.2rather than usinglatestin production. Images are linux/amd64 and linux/arm64 from v2.5.1. MCP over HTTP (/_mcp) is available on v2.1.0+; Studio (/_studio/) on v2.2.0+; MySQL (engine = "mysql") on v2.5.0+.
Edit the PREST_PG_URL env var value, so that you can connect to your Postgres instance.
Examples of PREST_PG_URL:
postgres://admin:password@localhost:5432/my-db
postgres://admin:@localhost:5432/my-db (if there is no password)
If your password contains special characters (e.g. #, %, $, @, etc.), you need to URL encode them in the
PREST_PG_URLenv var (e.g. %40 for @). You can check the logs to see if the database credentials are proper and if pREST is able to connect to the database. pREST needs access permissions to your Postgres database as described in permissions page.
Network config
If your Postgres instance is running on localhost, the following changes will be needed to the docker run command to allow the Docker container to access the hostβs network.
Add the --net=host flag to access the hostβs Postgres service.
This is what your command should look like:
if you are using another operating system we recommend reading the docker network documentation, on macOS and Windows it is different.
With Docker Compose
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your applicationβs services. Then, with a single command, you create and start all the services from your configuration. To learn more about all the features of Compose, see the list of features.
Compose file in the prest repo: docker-compose-prod.yml
Download docker compose file
Up (run) PostgreSQL and prestd
Run data migration to create user structure for access (JWT)
Create user and password for API access (via JWT)
user: prest
pass: prest
v2 defaults auth.encrypt to bcrypt. Hash the password with htpasswd (apache2-utils / httpd) on the host, then insert:
Check if the user was created successfully (by doing a select on the table)
First call on API
With auth enabled, get a token first. From v2.5.2 the catalog routes (/databases, /schemas, /tables) also require it β see Auth.
Kubernetes readiness probe
For multi-database or production deployments, use GET /_ready as the readiness probe. It pings the default database and every registered alias (#973), so it returns 503 while any alias is down β including one registered lazily because it was unreachable at startup (v2.5.2).
See the Kubernetes deployment manifest in the prest repo for a multi-secret example. From v2.5.2 it uses prest/prest:v2 and shows PREST_DB_URL / PREST_PG_ALLOWED_DATABASES; pin a specific tag such as v2.5.2 in production.
Related
Last updated