Run an app or a database
Deploy your code from git with Apps, run a PostgreSQL database on Container Apps, 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. Two products do the work. Apps builds your app from a git repository and serves it over HTTPS, at its own address and on your domain. Container Apps runs one program from a catalogue on a server of its own, here a PostgreSQL database. Sections 1 to 3 deploy the app, sections 4 and 5 run the database, and section 6 connects them. To run only a database, start at section 4.
An app has no plan and no invoice (How Apps is billed). The database server costs the plan you choose on its order page. If you are not sure which product suits your code, read Container Apps, Cloud Compute and Apps compared 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. For a private repository, an access token from your git host that can read it.
- An app that listens on the port in its
PORTvariable and answers HTTP requests for/(What your app must do). - For the database, credit for the server's first invoice, or a card or PayPal to pay it when you order (Add credit to your balance).
psql, PostgreSQL's command-line client, on your computer.
1. Create the app
Section titled 1. Create the app- In the dashboard, go to Apps and select New app….
- Under App, type a Name, such as
Web shop. The hint under it shows the address the app will answer at. - Under Source, choose Git repository. Fill in Repository with the repository's HTTPS address, such as
https://github.com/example/web-shop, and change Branch when the app is not onmain. Fill in Access token when the repository is private. - Under Regions, leave Every region chosen, and Replicas per region at
1. - Under Run, set Health check path to a path your app answers,
/at first, and choose a Size. - Leave Start the first deployment now ticked, and select Create app.
- In the Push webhook secret dialog, select Copy all and keep what it copies, then select I have saved it. You need it only to deploy on every push (Deploy on every push).
The first deployment's page opens, and its Build log follows the build (Create an app).
Note
The sidebar has no Apps while Apps is off for the platform. You can then run the app on a Container Apps server. Select Node.js app under Quick start on the Order a service page, or choose Python under Runtimes in the order page's Software section. Under Source, fill in Git repository, and Entry file when the app does not start from index.js or main.py. The server clones the repository when it installs the software, and the app listens on the port in its SERVER_PORT variable (Order a server).
2. Watch it go live
Section titled 2. Watch it go liveCoritan builds an image from your branch, then starts the replicas and requests your health check path on each one. The deployment's progress bar says what it is doing, such as Building or Starting replicas.
Once the deployment is Ready, the app is Live. Open its platform address, such as https://web-shop.apps.example.net, which the app's header shows with a copy button. Your app answers over HTTPS (Read a deployment and its build log).
3. Serve it on your domain
Section titled 3. Serve it on your domain- On the app's page, select the Domains tab, then Add domain….
- In Domain, type the name, such as
www.example.com, and select Add domain. - At your DNS host, create the
TXTrecord that Prove the domain is yours gives, and theCNAMErecord that Send its visitors to the app gives. 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 custom domain).
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 Container Apps order page opens with PostgreSQL chosen under Software.
- Under Plan, choose how often to pay, then a plan under Size.
- Under Version, keep the version the page chose, marked
Default, or choose the major version your app needs. - Under Location, choose the data centre closest to the people who use your app.
- 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 server when your credit pays the first invoice, and Place order and pay when you pay on the next 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 server appears on the Container Apps page with the status Installing while Coritan installs PostgreSQL (Order a server).
5. Start the database and connect to it
Section titled 5. Start the database and connect to itOpen the server from the Container Apps page. The install does not start it, so select Start. The console 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).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 same password, the one 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 the app from Apps and select the Environment tab, then Add variable….
- 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, choose Runtime only in Available at, and select Add variable.
- Select Redeploy… in the app's header, then Redeploy. Replicas keep the variables they started with until the next deployment.
The new deployment's page opens. Once it is Ready, your app reads DATABASE_URL and stores its data in PostgreSQL (Set environment variables).
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 (Replicas do not pass their health check). Not verified yetunder 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 server's status badge 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- Deploy on every push, so each push to the branch goes live
- 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