> For the complete documentation index, see [llms.txt](https://stakpak.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stakpak.gitbook.io/docs/tutorial/deploy-coolify-on-aws-and-deploy-your-app.md).

# Deploy Coolify on AWS & Deploy Your App

Run your own application platform on AWS using Coolify, similar to Heroku or Vercel

## Overview

[Coolify](https://coolify.io/) lets you run your own platform similar to Heroku or Vercel, on  your own infrastructure.

In this tutorial, you will:

* Deploy Coolify on AWS EC2
* Deploy a real application using Coolify
* Test that everything is working
* Then use Stakpak [Autopilot](/docs/how-it-works/autopilot.md) to monitor and maintain it automatically

all with just one prompt

{% hint style="success" %}
Estimated time: 20 Minutes
{% endhint %}

## Problem

Setting up Coolify on AWS is mostly manual steps and trial and error.

* Create the server
* Install dependencies
* Run the install script
* Make sure everything is configured correctly

A small mistake can leave you with a broken setup that’s hard to debug.

## How Stakpak Helps?

We created a Stakpak [Skill](https://github.com/stakpak/community-paks/blob/main/coolify-deployment/SKILL.md) that handles the Coolify setup end to end, with just one prompt

## Application

### What the app does

We’ll use a simple todo app built with Next.js and Turso.

It:

* lets you create and delete tasks
* stores data in a Turso database (SQLite over HTTP)
* uses a modern stack (Next.js, Drizzle ORM, Tailwind)

This is a small app, but it’s enough to test:

* deployment
* database connectivity
* container behavior

You can check the code source [here](https://github.com/mstfash/nextjs-turso-todos-template)

Now that we understand the app, we can start deploying it

## Step-by-Step Guide

### Prerequisites

1. [Install Stakpak](/docs/get-started/install-stakpak.md)
2. [Configure Stakpak](/docs/get-started/configure-stakpak.md)
3. Install [Browser Extension](/docs/how-it-works/browser-extension.md)(Optional)
4. Cloud provider credentials configured

### Deployment

1. Open stakpak ask it to `deploy my app on aws with coolify`

Now let it do its stakpak magic

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2F7erQUVrc4Gh4mge2208U%2Fimage.png?alt=media&amp;token=220a1d12-8f92-4446-ae3a-3c185a2733e7" alt=""><figcaption></figcaption></figure>

2. As you can see, it automatically find the coolify skill, let's press enter

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2FulGMgfF6QRl0yDDzBClO%2Fimage.png?alt=media&amp;token=90e68d72-bb47-423c-bb29-c0971440cebe" alt=""><figcaption></figcaption></figure>

3. Now its asking us about which EC2 we want to use, lets choose t3.medium

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2FvDTWkoiP0lPgF0I6WRJL%2Fimage.png?alt=media&amp;token=7b97f698-d75f-45a3-af92-1e41fde1898c" alt=""><figcaption></figcaption></figure>

4. Now it's asking us where we want to deploy our app, choose the closest region to your users

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2FX5VD616u23sJHdT2Yst4%2Fimage.png?alt=media&amp;token=017e8d68-f11f-486c-a9a3-53e5332ff41e" alt=""><figcaption></figcaption></figure>

5. Now it's asking for the DB URL and Auth Token for our app

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2FEWC6BgUR1gnBVLQLN2Of%2Fimage.png?alt=media&amp;token=c392ce8f-6008-42ac-8338-b0e5031aeb6c" alt=""><figcaption></figcaption></figure>

6. Now, let's restrict SSH to our IP only for security

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2FCgfHHKaykvTB4MCl7eKH%2Fimage.png?alt=media&amp;token=604913c0-1bd8-4afb-8b49-fd2193ab2fee" alt=""><figcaption></figcaption></figure>

7. Now that we have everything ready lets press enter

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2FODLgVgCGHx3FYfaknalu%2Fimage.png?alt=media&amp;token=a709161b-f17d-4dfb-a77a-a92d28796b2a" alt=""><figcaption></figcaption></figure>

8. Now that Coolify is deployed, let's make an admin account

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2Fjl7RL0nvK1uybZopbSKO%2Fimage.png?alt=media&amp;token=bd82188e-ef9d-4366-8a5a-89e5308367a0" alt=""><figcaption></figcaption></figure>

9. Then it configured Coolify by starting the reverse proxy and enabling API access
10. It created a project and connected the GitHub repo as a new application
11. It added the Turso database credentials as environment variables
12. Finally, it triggered the deployment, and Coolify built and launched the app automatically

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2FppPld9VJMWoKzUy1xzey%2Fimage.png?alt=media&amp;token=fa608191-d710-4878-8eb3-a8ceb0acf5c1" alt=""><figcaption></figcaption></figure>

Now everything is working🥳

Now, let's ask it to set up Stakpak [Autopilot](/docs/how-it-works/autopilot.md)

{% hint style="info" %}
Stakpak Autopilot monitors your apps 24/7, detects unexpected changes, fixes what’s safe, and only alerts you when it actually matters.
{% endhint %}

### Monitoring

1. Prompt: `Set up stakpak autopilot to monitor the app`

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2FRzFt92szKJqtAQFd7aW1%2Fimage.png?alt=media&amp;token=57fd4496-aa31-42d1-8665-ea0140b32ab3" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2684022488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOFDKnFMEMmJjoclGx9Hr%2Fuploads%2FNJW1r73YBcfs4VHfyUAt%2Fimage.png?alt=media&amp;token=34b461c8-0d1d-41e9-bd5e-ca5e12218d9b" alt=""><figcaption></figcaption></figure>

That's it!!

## Extra Resources:

### Related Use Cases

* [Load Test to Optimize Cloud Costs](/docs/tutorial/load-test-to-optimize-cloud-costs.md)
* [Migrate a Next.js App from Vercel to AWS](/docs/tutorial/migrate-a-next.js-app-from-vercel-to-aws.md)
* [Detect and Fix Missing Backups for a PostgreSQL DB in Production](/docs/tutorial/detect-and-fix-missing-backups-for-a-postgresql-db-in-production.md)
* [Containerize a Python App](/docs/tutorial/containerize-a-python-app.md)

and more...

### References

* [Install Stakpak](/docs/get-started/install-stakpak.md)
* [Configure Stakpak](/docs/get-started/configure-stakpak.md)
* [Configuration and credential file settings in the AWS CLI](https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-files.html)
* [Coolify](https://github.com/coollabsio/coolify)
* [Installing Coolify](https://coolify.io/docs/get-started/installation)
* [Autopilot](/docs/how-it-works/autopilot.md)
* [Handling Secrets](/docs/how-it-works/handling-secrets.md)
