|
| 1 | +# 🌐 Deployment Guide |
| 2 | + |
| 3 | +## Overview of VTMUNC Website Architecture |
| 4 | +The VTMUNC website is hosted on an Amazon EC2 instance, which serves as the core infrastructure for the web application. This EC2 instance also functions as a reverse proxy, efficiently managing incoming traffic to ensure smooth and secure operations. Additionally, the server interacts with AWS DynamoDB, providing scalable and rapid access to the database for handling data-related tasks. |
| 5 | + |
| 6 | +## Initial Setup |
| 7 | + |
| 8 | +### Step 1: Create an EC2 Instance |
| 9 | + |
| 10 | +1. **Launch an EC2 Instance**: |
| 11 | + - Go to the AWS Management Console and navigate to the EC2 Dashboard. |
| 12 | + - Click on "Launch Instance". |
| 13 | + - Select "Ubuntu" as the AMI (Amazon Machine Image). |
| 14 | + - Choose an instance type (e.g., t2.micro for free tier eligibility). |
| 15 | + |
| 16 | +2. **Configure Instance**: |
| 17 | + - **Key Pair**: Create a new key pair or select an existing key pair. This will be used for SSH access. |
| 18 | + - **Security Group**: Create a new security group with the following rules: |
| 19 | + * Inbound rules: |
| 20 | + - Allow SSH on port 22 from ony you and your collaborators ip addresses. |
| 21 | + - Allow HTTP on port 80 from anywhere. |
| 22 | + - Allow HTTPS on port 443 from anywhere. |
| 23 | + * Outbound rules: |
| 24 | + - Allow all traffic to a to anywhere |
| 25 | + |
| 26 | +3. **Launch the Instance**: Complete the instance launch process. |
| 27 | + |
| 28 | +### Step 2: Connect to Your EC2 Instance |
| 29 | + |
| 30 | +1. **SSH into the EC2 Instance**: |
| 31 | + - Open a terminal on your local machine. |
| 32 | + - Run the following command, replacing `<path-to-key-pair>` with the path to your key pair file and `<ec2-user>` and `<public-ip>` with your EC2 instance's username and public IP address: |
| 33 | + |
| 34 | + ```bash |
| 35 | + ssh -i <path-to-key-pair> <ec2-user>@<public-ip> |
| 36 | + ``` |
| 37 | + |
| 38 | +### Step 3: Run the Initial Setup Script |
| 39 | + |
| 40 | +1. **Execute the Setup Script**: |
| 41 | + - Run the following command to execute the initial setup script. This will set up your reverse proxy and do the initial setups for the github runners: |
| 42 | + |
| 43 | + ```bash |
| 44 | + curl -sSL https://raw.githubusercontent.com/Trafix120/VTMUNC/main/aws/ec2-setup.sh | bash |
| 45 | + ``` |
| 46 | + |
| 47 | +### Step 4: Configure GitHub Runner |
| 48 | + |
| 49 | +1. **Edit the GitHub Runner Configuration**: |
| 50 | + - Navigate to your GitHub repository. |
| 51 | + - Go to `Settings` > `Actions` > `Runners` > `New self-hosted runner` |
| 52 | + - Select the option to configure a new self-hosted runner. |
| 53 | + - Most of the commands have already been done in the ec2-setup.sh script but you need to run the config script, which is unique to each repository. It should look like this: ./config.cmd --url https://github.com/<Username>/<Repository> --token <Token> |
| 54 | + |
| 55 | +2. **Run the GitHub Runner as a Systemd Daemon**: |
| 56 | + - Once configured, execute the following command to run the setup script again, which will configure the GitHub runner to run as a systemd daemon: |
| 57 | + |
| 58 | + ```bash |
| 59 | + curl -ssL https://github.com/Trafix120/VTMUNC/blob/main/aws/start-githubrunner.sh | bash |
| 60 | + ``` |
| 61 | + |
| 62 | +### Step 5: Create a DynamoDB Table |
| 63 | + |
| 64 | +1. **Create the DynamoDB Table**: |
| 65 | + - Navigate to the DynamoDB service in the AWS Management Console. |
| 66 | + - Click on "Create table". |
| 67 | + - Set the table name to `vtmunc_applicants`. |
| 68 | + - Define the primary key (e.g., `_id`) as per your application requirements. |
| 69 | + - Click "Create" to create the table. |
| 70 | + |
| 71 | +## Subsequent Deploys |
| 72 | + |
| 73 | +For subsequent deployments, simply push your changes to the `main` branch of your GitHub repository. The configured GitHub Actions workflow will automatically deploy the updates. |
| 74 | + |
| 75 | +```bash |
| 76 | +git add . |
| 77 | +git commit -m "Your commit message" |
| 78 | +git push origin main |
| 79 | +``` |
| 80 | + |
| 81 | +That's it! Your deployment process is now automated, and your application will be deployed upon every push to the main branch. |
0 commit comments