<div class="gfmr-markdown-container"><div class="gfmr-markdown-source" style="display: none;"># Hosting
## Keycloak
The PDC API requires a [Keycloak](https://www.keycloak.org/) instance
to handle authentication.
We suggest creating a second realm named `pdc`
to separate Keycloak administrator accounts from PDC accounts.
## service
The PDC API is a fairly standard Node.js application.
It needs no special operating system permissions,
and should be run as a non-root user.
Add the environment variables in `.env.example`
however your hosting environment needs.
Be sure to set `NODE_ENV=production`,
as recommended by the
[Node.js documentation](https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production)
and the
[Express documentation](https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production).
### DigitalOcean App Platform
The PDC API can be deployed on
[DigitalOcean App Platform](https://www.digitalocean.com/products/app-platform):
[](https://cloud.digitalocean.com/apps/new?repo=https://github.com/PhilanthropyDataCommons/service/tree/main)
Although specified in the template,
the API cannot be used with a DigitalOcean dev database,
because [dev databases do not allow schema
creation](https://www.digitalocean.com/community/questions/how-to-create-tables-with-app-platform-managed-dev-databases?comment=206323)
and the PDC requires PostgreSQL schemas;
the `migrate` job will fail with a permission denied error.
Either delete the dev database and add a prod database with the same name during app creation,
upgrade the generated dev database to a managed database after creating the app,
or delete the dev database and configure the environment variables with credentials for a database hosted elsewhere.
</div><div class="gfmr-markdown-rendered" data-mermaid-bg-color="transparent" data-shiki-theme="github-dark"><h1>Hosting</h1>
<h2>Keycloak</h2>
<p>The PDC API requires a <a href="https://www.keycloak.org/">Keycloak</a> instance<br>
to handle authentication.</p>
<p>We suggest creating a second realm named <code>pdc</code><br>
to separate Keycloak administrator accounts from PDC accounts.</p>
<h2>service</h2>
<p>The PDC API is a fairly standard Node.js application.<br>
It needs no special operating system permissions,<br>
and should be run as a non-root user.</p>
<p>Add the environment variables in <code>.env.example</code><br>
however your hosting environment needs.</p>
<p>Be sure to set <code>NODE_ENV=production</code>,<br>
as recommended by the<br>
<a href="https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production">Node.js documentation</a><br>
and the<br>
<a href="https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production">Express documentation</a>.</p>
<h3>DigitalOcean App Platform</h3>
<p>The PDC API can be deployed on<br>
<a href="https://www.digitalocean.com/products/app-platform">DigitalOcean App Platform</a>:</p>
<p><a href="https://cloud.digitalocean.com/apps/new?repo=https://github.com/PhilanthropyDataCommons/service/tree/main"><img src="https://www.deploytodo.com/do-btn-blue.svg" alt="Deploy to DO"></a></p>
<p>Although specified in the template,<br>
the API cannot be used with a DigitalOcean dev database,<br>
because <a href="https://www.digitalocean.com/community/questions/how-to-create-tables-with-app-platform-managed-dev-databases?comment=206323">dev databases do not allow schema<br>
creation</a><br>
and the PDC requires PostgreSQL schemas;<br>
the <code>migrate</code> job will fail with a permission denied error.<br>
Either delete the dev database and add a prod database with the same name during app creation,<br>
upgrade the generated dev database to a managed database after creating the app,<br>
or delete the dev database and configure the environment variables with credentials for a database hosted elsewhere.</p>
</div></div>
# Hosting
## Keycloak
The PDC API requires a [Keycloak](https://www.keycloak.org/) instance
to handle authentication.
We suggest creating a second realm named `pdc`
to separate Keycloak administrator accounts from PDC accounts.
## service
The PDC API is a fairly standard Node.js application.
It needs no special operating system permissions,
and should be run as a non-root user.
Add the environment variables in `.env.example`
however your hosting environment needs.
Be sure to set `NODE_ENV=production`,
as recommended by the
[Node.js documentation](https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production)
and the
[Express documentation](https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production).
### DigitalOcean App Platform
The PDC API can be deployed on
[DigitalOcean App Platform](https://www.digitalocean.com/products/app-platform):
[](https://cloud.digitalocean.com/apps/new?repo=https://github.com/PhilanthropyDataCommons/service/tree/main)
Although specified in the template,
the API cannot be used with a DigitalOcean dev database,
because [dev databases do not allow schema
creation](https://www.digitalocean.com/community/questions/how-to-create-tables-with-app-platform-managed-dev-databases?comment=206323)
and the PDC requires PostgreSQL schemas;
the `migrate` job will fail with a permission denied error.
Either delete the dev database and add a prod database with the same name during app creation,
upgrade the generated dev database to a managed database after creating the app,
or delete the dev database and configure the environment variables with credentials for a database hosted elsewhere.
Hosting
Keycloak
The PDC API requires a Keycloak instance
to handle authentication.
We suggest creating a second realm named pdc
to separate Keycloak administrator accounts from PDC accounts.
service
The PDC API is a fairly standard Node.js application.
It needs no special operating system permissions,
and should be run as a non-root user.
Add the environment variables in .env.example
however your hosting environment needs.
Be sure to set NODE_ENV=production,
as recommended by the
Node.js documentation
and the
Express documentation.
DigitalOcean App Platform
The PDC API can be deployed on
DigitalOcean App Platform:

Although specified in the template,
the API cannot be used with a DigitalOcean dev database,
because dev databases do not allow schema
creation
and the PDC requires PostgreSQL schemas;
the migrate job will fail with a permission denied error.
Either delete the dev database and add a prod database with the same name during app creation,
upgrade the generated dev database to a managed database after creating the app,
or delete the dev database and configure the environment variables with credentials for a database hosted elsewhere.