You are tasked with deploying a backend application using Docker while integrating it with services installed directly on an EC2 instance. This setup demonstrates understanding of containerized applications communicating with traditional instance-based services.
- EC2 Instance: t2.micro (or similar)
- Operating System: Ubuntu 22.04 LTS
- Required packages:
- PostgreSQL 14 or later
- Nginx (latest stable version)
- Docker
-
PostgreSQL Setup
- Install PostgreSQL directly on the EC2 instance
- Configure PostgreSQL to accept connections from Docker containers
- Create necessary database and user
- Secure the database with proper credentials
- Ensure PostgreSQL is running on port 5432
-
Application Containerization
- Create Dockerfile for the backend application
- Configure environment variables for database connection
- Build and run the container
- Ensure proper network configuration to connect to host PostgreSQL
- Application should run on port 8000
-
Nginx Configuration
- Install Nginx on the EC2 instance
- Configure as reverse proxy to the Docker container
- Handle static file serving
- Basic security headers implementation
- Listen on port 80
- GitHub Actions Workflow
- Automated testing
- Docker image building
- Deployment to EC2 instance
- Environment variable management