Run an app or a database
Deploy your code from git on App Deployment, run a PostgreSQL database beside it, and connect the two, from start to finish.
In the dashboard
This tutorial gets your own code running on Coritan with a database beside it, both on App Deployment. Sections 1 to 3 deploy the app from its git repository and serve it over HTTPS on your domain, sections 4 and 5 run a PostgreSQL database from the catalogue, and section 6 connects them. To run only a database, start at section 4.
The app is billed by what it uses, after the free amounts every account gets each month, so a small app can cost nothing and the order has no price to pay. One instance with light traffic comes to about $1.14 a month (How App Deployment is billed). The database server is billed by what it uses too (How game servers and databases are billed). If you are not sure which way to run your code suits it, read Which compute product to choose first.
Before you begin
Section titled Before you begin- A Coritan account. Create an account if you have none, then sign in.
- Your app in a git repository on a public host, such as GitHub, that answers over HTTPS.
- An app that listens on the port in its
PORTvariable and answers HTTP requests for/(How each kind runs). - An access token for the API, because section 1 orders the app with one request (Authentication). To order it from the dashboard instead, follow Order the app in the dashboard, then continue at section 2.
- Credit on your account. The app and the database are billed by what they use, and a prepaid account needs a minimum total of deposits, $10.00 by default, before either runs (What you need before you order). The credit pays for their use each hour (Add credit to your balance).
- Server access, for the database. Pro, Business and Enterprise include it, and a Free account adds it in the same order as its first database. The app needs no plan.
psql, PostgreSQL's command-line client, on your computer.
1. Order the app
Section titled 1. Order the appOrder the app with your repository and its branch. An app needs no plan and no size, so the order names neither (Order any kind). The example runs one instance in Frankfurt (
fra):Shellcurl -X POST https://api.coritan.com/api/v1/services/order \ -H "Authorization: Bearer $CORITAN_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "config": { "kind": "git", "name": "web-shop", "placement": {"mode": "single", "locations": ["fra"]}, "source": {"git": {"repo_url": "https://github.com/example/web-shop", "branch": "main"}}, "runtime": {"port": 3000, "health_check_path": "/"} } }'The app has nothing to pay up front. A prepaid account that has not made the first deposit gets
403withDeposit at least $10.00 before you start anything that bills by use. The deposit stays in your account as credit.Add credit, then send the order again.
In the dashboard, open App Deployment. web-shop is listed as a Web service, marked Not deployed until its first release is ready (Order any kind).
Order the app in the dashboard
Section titled Order the app in the dashboard- In the dashboard, go to App Deployment and select New deployment.
- Under What to deploy, select Git repository. Under Repository, select Paste an address and type
https://github.com/example/web-shop, or select From GitHub and choose the repository. - Under Build and run, leave the fields blank so the build works them out. The app listens on port 3000, which is what a blank Port means.
- Under Locations, keep Single and choose Frankfurt under Data centres. There is no size to choose: the memory limit starts at 512 MB, or 1 GB for Next.js, and grows by itself.
- Under Networking, keep the suggested Deployment name. Leave Advanced as it is: Largest memory limit is 4 GB and Monthly budget is empty.
- In the summary, read the Billed by use panel. For one instance, it shows $0.25 a month for an idle app, $1.14 for light traffic and $12.81 for busy traffic, after the free amounts each month.
- If your account has not made its first deposit, the summary shows a Deposit line: the credit stays yours and pays for what the app uses. Choose how to pay under Pay with.
- Select the button. It reads Deploy when nothing is due, or names the amount, such as Pay $10.00 and deploy, and pays the deposit and deploys in one click.
The order's page shows Setting up while we set the app up (Order your code).
2. Watch it go live
Section titled 2. Watch it go live- Open
web-shop, then its Releases tab. Its first release builds the newest commit onmain, and the release's page shows the build log as it goes. - The release moves from Queued to Building to Deploying. Once its instance passes the health check, the release reads Live, and so does the deployment in the App Deployment list.
- The deployment's header shows its platform address, such as
web-shop.apps.example.net, with Copy address. Open it in a browser withhttps://in front.
Your app answers over HTTPS (Deploy, promote and roll back releases).
3. Serve it on your domain
Section titled 3. Serve it on your domain- On the deployment's page, select the Domains tab, then Add domain…. The Add a domain page opens.
- In Domain, type the name, such as
www.example.com, and select Add domain. - At your DNS host, create the
TXTrecord that proves the domain is yours and theCNAMErecord that sends its visitors to the app, both as the tab gives them. When Coritan hosts the domain's DNS, add both on the domain's DNS tab (Add, edit and delete DNS records). - Wait a few minutes, then select Verify on the domain's row.
The domain shows Verified, and Certificate issued once the certificate authority has checked it. Your app answers at https://www.example.com (Add a domain and protection).
4. Order the database server
Section titled 4. Order the database server- In the dashboard, go to Order a service and select PostgreSQL database under Quick start. The order page opens with PostgreSQL chosen in the Catalogue.
- Under Size, choose a plan. It sets what the database has and does not set a price: the database is billed by what it uses.
- Under Version, keep the version the page chose, marked
Default, or choose the major version your app needs. - Under Data centres, choose the one your app runs in, Frankfurt in this example, so the two are close.
- Under Settings, keep the suggested Server name or type your own. You can rename the server later on its Settings tab (Rename the server).
- Check the summary under Your order, then select the button under it. It reads Deploy when nothing is due, and otherwise names the amount, such as Pay $14.50 and deploy for a Free account with no credit: one click adds Server access and the deposit, places the order and pays for it on this page.
- If the order's page reads Order placed, payment due, pay under Pay invoice.
The order's page shows Setting up, then Your order is ready. The database appears under App Deployment, marked Starting while Coritan installs PostgreSQL (Order a deployment).
5. Start the database and connect to it
Section titled 5. Start the database and connect to itOpen the database from the App Deployment page. The install does not start it, so select Start. The Console tab shows PostgreSQL's own messages until it prints
database system is ready to accept connections(Use the console and power controls).Select the Settings tab. Under Network, Address with port shows where the database listens, such as
203.0.113.10:10565, and Copy address copies it.Under Startup variables, read the user name in
POSTGRES_USER, the password inPOSTGRES_PASSWORDand the database's name inPOSTGRES_DB(Server settings). The same card changes and adds startup variables, such as an app server's own settings and keys (Add a startup variable).On your computer, connect with
psqland the values from the tab, then type the password when it asks:Shellpsql -h 203.0.113.10 -p 10565 -U pguser pgdbAt the
pgdb=#prompt, give the user a password of your own:Text\password pguser
Warning
Every new PostgreSQL server starts with the password that Startup variables shows, and the server's address is public. Set your own before you store anything. The table goes on showing the first password, so keep the new one somewhere safe.
psql connects and shows its prompt, and after \password it connects only with your new password.
6. Connect the app to the database
Section titled 6. Connect the app to the database- Open
web-shopfrom App Deployment and select the Variables tab, then Add variable…. The Add a variable page opens. - In Name, type the variable your app reads, such as
DATABASE_URL. In Value, type the connection address, such aspostgresql://pguser:YOUR_PASSWORD@203.0.113.10:10565/pgdb, with your new password in it. - Leave Secret ticked and Environment at All environments, choose Runtime only under Available at, and select Add variable. The page closes and the list shows the new variable.
- A notice at the top of the page says Redeploy to apply your changes. Select Redeploy… in it, then Redeploy in the dialog. The app reads this variable only while it runs, so a redeploy applies it and nothing is built. Instances keep the variables they started with until the next release.
A new release starts. Once it is Live, your app reads DATABASE_URL and stores its data in PostgreSQL (Environments and variables). With the API, a binding can set DATABASE_URL and the rest for you instead, and keeps them up to date when the password changes (Variables from Coritan services).
Troubleshooting
Section titled TroubleshootingThe app did not pass its health check within 10 minutes. Health check on /: the connection failed- Nothing answered on the port in the app's
PORTvariable. Make the app listen on that port (Troubleshooting). - Not verified yet above the domain's row
- Coritan did not find the
TXTrecord. Check its name and value at your DNS host, wait a few minutes, then select Verify again. psqlcannot connect- Check that the database's status says it is running, and that
psqluses the port from Address with port rather than PostgreSQL's usual5432(Troubleshoot servers).
Next steps
Section titled Next steps- Connect GitHub, so each push to the branch builds a release, and previews of other branches
- Take a server snapshot of the database server before a risky change
- Store files and backups, for the files your app keeps outside the database