Giter Club home page Giter Club logo

hng_devops_stage_2's Introduction

DevOps Stage 2 Project

Table of Contents

  1. Project Overview
  2. Prerequisites
  3. Manual Deployment Steps
  4. Creating Dockerfiles and Docker Compose
  5. Deploying to EC2
  6. Configuring Nginx Proxy Manager
  7. Domain Setup and SSL Configuration
  8. Testing the Setup
  9. Troubleshooting
  10. Benefits and Learnings

Project Overview

This project is part of the HNG DevOps Stage 2 task, where I deployed a Dockerized full stack web application with a React frontend and FastAPI + PostgreSQL backend. Nginx Proxy Manager was used for SSL and domain configurations.

Prerequisites

  • AWS Account
  • EC2 Instance running Amazon Linux 2
  • Docker and Docker Compose installed
  • Route 53 for domain management
  • Let's Encrypt for SSL certificates

Manual Deployment Steps

  1. Install WSL and Set Up Environment:

  2. Install Poetry and PostgreSQL:

    • Install Poetry: curl -sSL https://install.python-poetry.org | python3 -
    • Add Poetry to PATH: nano ~/.bashrc and add export PATH="$HOME/.local/bin:$PATH"
    • Install PostgreSQL: sudo apt install postgresql
    • Create PostgreSQL user and database.
  3. Set Up Backend:

    • Navigate to backend directory: cd backend
    • Install dependencies: poetry install
    • Set up database tables: poetry run bash ../prestart.sh
    • Run the backend server: poetry run uvicorn app.main:app --reload
  4. Set Up Frontend:

    • Install Node.js and npm.
    • Navigate to frontend directory: cd ../frontend
    • Install dependencies: npm install
    • Run the frontend development server: npm run dev

Creating Dockerfiles and Docker Compose

Created Dockerfiles and docker-compose.yml file to containerize the application. These files are included in the repository.

Deploying to EC2

  1. Connect to EC2 Instance:

    • Use EC2 Instance Connect to SSH into the instance.
  2. Install Docker and Docker Compose:

  3. Clone Repository and Update .env Files:

    • Clone the repository on EC2.
    • Update VITE_API_URL in the frontend .env file.
  4. Build and Run Containers:

    • Run: docker-compose up --build -d

Configuring Nginx Proxy Manager

  1. Access and Login:

    • Open http://:81 and use default credentials to log in.
  2. Add Proxy Hosts:

    • Add configurations for stagetwoapp.strangled.net, db.stagetwoapp.strangled.net, and proxy.stagetwoapp.strangled.net

Domain Setup and SSL Configuration

  1. Configure Route 53:

  2. Enable SSL in Nginx Proxy Manager:

    • Request a new SSL Certificate using Let's Encrypt and enable Force SSL.

Testing the Setup

  1. Access Application:

  2. Verify SSL and Redirects:

    • Ensure connections are secure and redirects are working.

Troubleshooting

  • 502 Bad Gateway:

    • Check Docker containers: docker ps
    • Verify Nginx Proxy Manager configuration and domain settings.
  • Database Connection Issues:

    • Ensure the database container is running and accessible from the backend container.

Benefits and Learnings

Completing this project as part of the HNG DevOps Stage 2 task has given me practical skills in Docker, AWS, and Nginx Proxy Manager. It’s been a fantastic learning experience that has laid a solid foundation for my future DevOps endeavors.

Project Structure

The repository is organized into two main directories:

  • frontend: Contains the ReactJS application.
  • backend: Contains the FastAPI application and PostgreSQL database integration.

Each directory has its own README file with detailed instructions specific to that part of the application.

Getting Started

To get started with this template, please follow the instructions in the respective directories:

HNG_devops_stage_2

hng_devops_stage_2's People

Contributors

khingdave avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.