Skip to main content

AWS

Overview

AWS Copilot is a command-line interface (CLI) tool that simplifies the process of deploying and managing containerized applications on AWS. This guide will walk you through the steps to deploy AnswerAI using AWS Copilot.

Key Benefits

  • Simplified deployment process
  • Automatic infrastructure provisioning
  • Easy management of multiple environments

Prerequisites

Before you begin, ensure you have the following:

  • An AWS account
  • AWS CLI installed and configured
  • Docker installed
  • AWS Copilot CLI installed
  • AnswerAI application code
  • Environment variables for your application

How to Use

1. Install AWS Copilot

If you haven't already installed AWS Copilot, you can do so by running:

brew install aws/tap/copilot-cli   # For macOS

For other operating systems, refer to the AWS Copilot installation guide.

2. Configure AWS CLI

Ensure your AWS CLI is configured with the correct credentials:

aws configure

3. Clone the AnswerAI Repository

Clone the AnswerAI repository to your local machine:

git clone https://github.com/answers-AI/AnswerAI
cd AnswerAI

4. Initialize the Copilot Application

In the root directory of your AnswerAI project, run:

copilot app init --domain <your-domain>

Replace <your-domain> with your desired domain name, e.g., myapp.flowise.theanswer.ai.

5. Create a New Environment

Create a new environment for your application:

copilot env init --name <env-name> --profile default

Replace <env-name> with your desired environment name (e.g., "production" or "staging").

6. Set Up Environment Variables

Create an environment file named <env-name>.env in your project directory. Add all required environment variables to this file. For example:

PORT=3000
APIKEY_PATH=/path/to/api/key
SECRETKEY_PATH=/path/to/secret/key
LOG_PATH=/path/to/logs
DISABLE_FLOWISE_TELEMETRY=true
IFRAME_ORIGINS=https://example.com
MY_APP_VITE_AUTH_DOMAIN=your-auth-domain
MY_APP_VITE_AUTH_CLIENT_ID=your-auth-client-id
...

For a list of all environment variables, please refer to the Environment Variables page.

7. Deploy the Service

Deploy your AnswerAI service to the created environment:

copilot svc deploy --env <env-name>

This command will build your Docker image, push it to Amazon ECR, and deploy it to Amazon ECS.

8. Access Your Deployed Service

To get the URL of your deployed service, run:

copilot svc show

This will display information about your service, including its public URL.

Tips and Best Practices

  • Use separate environments (e.g., "staging" and "production") to test changes before deploying to production.
  • Regularly update your AWS Copilot CLI to access the latest features and improvements.
  • Use AWS Copilot's built-in commands to manage your application, such as copilot svc logs to view service logs.
  • Implement a CI/CD pipeline to automate deployments using AWS Copilot commands.

Troubleshooting

Issue: Deployment Fails

If your deployment fails, check the following:

  1. Ensure all required environment variables are correctly set in your <env-name>.env file.
  2. Verify that your AWS CLI is configured with the correct credentials and permissions.
  3. Check the Copilot logs for detailed error messages:
copilot svc logs --env <env-name>

Issue: Unable to Access the Deployed Service

If you can't access your deployed service:

  1. Verify that the service is running:
copilot svc status --env <env-name>
  1. Check if the correct ports are exposed in your Dockerfile and Copilot configuration.
  2. Ensure your domain's DNS settings are correctly configured to point to the AWS-provided URL.

Remember to regularly update your AnswerAI application and redeploy using Copilot to ensure you have the latest features and security updates.