> 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

## 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="/files/1XTekO6gkXm4lkzdxv6O" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/WNpnZ0ziitYUYXfZoM2q" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/yZ0GTkQvyaYoW92W4xKe" 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="/files/WGyinEhav7VKPpnfMVRF" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/xVeiBuWmS8z8UL0iLXvE" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/QD15WEpnlmBDcu1P0gaQ" alt=""><figcaption></figcaption></figure>

7. Now that we have everything ready lets press enter

<figure><img src="/files/3HchSAwXNBnqYV2RNsTg" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/UWNMrYBpwj2IxOAQNXLy" 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="/files/Z7WUNPvbqxKuvB523v3c" 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="/files/z6TmaUdNiSm1nwtLt7vP" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/bQZwWQzh5NHLzNQq3chl" 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)
