# AWS EC2

> Deploy Edesy Email on an Amazon EC2 instance with Docker and Docker Compose.

Source: https://edesy.in/docs/email-platform/deploy/aws-ec2

This page guides you through deploying Edesy Email Open-Source on an Amazon EC2 instance by setting up the deployment environment, installing and starting Edesy Email, and connecting it to the Amazon EC2 instance.

## Requirements
- A t3.medium instance or larger. While you can run it on smaller instances, performance may not be optimal.
- [Create and download an SSH key to connect to the instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html)

## Setup
1. SSH into your instance or use Amazon EC2 Instance Connect
2. Install Docker
```sh
sudo yum update -y
sudo yum install -y docker containerd git screen
sudo service docker start
sudo usermod -a -G docker $USER
```

3. Install `docker-compose`
```sh
wget https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)
sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/libexec/docker/cli-plugins/docker-compose
chmod +x /usr/libexec/docker/cli-plugins/docker-compose
sudo systemctl enable docker.service --now
docker compose version
```

4. Download Edesy Email configuration:
```
mkdir edesy-email && cd edesy-email
wget https://raw.githubusercontent.com/edesy-email/platform/master/{.env.example,docker-compose.yml}
```

5. Setup environment variables
```
mv .env.example .env
```

For default installations, security is set to `basic` which only allows for a single user. Before proceeding please update the email, password and app secret to not be their default values.

```
APP_SECRET=//Please pick a random value at least 16 characters in length
AUTH_BASIC_EMAIL=test@edesy-email.com
AUTH_BASIC_PASSWORD=password
```

This file also lets you use a separate database, change what queue is being used or setup SSO.

By default the port is configured to use `3000` for the UI and API. You can modify this by setting `UI_PORT`.

6. Bring containers online
```
docker compose up -d # run the Docker container
```

7. Setup security groups
Based on what port you are using for the UI portion, you will want to make sure you have configured that port to be open as well in your security groups.
