{"id":17601076,"url":"https://github.com/interviewandhealth/deployment","last_synced_at":"2025-03-29T21:41:18.057Z","repository":{"id":258791191,"uuid":"868458891","full_name":"InterviewAndHealth/Deployment","owner":"InterviewAndHealth","description":"Deploy the application on EC2 instance","archived":false,"fork":false,"pushed_at":"2024-10-06T12:55:07.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-04T22:24:38.590Z","etag":null,"topics":["aws","deployment","ec2"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/InterviewAndHealth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-06T12:43:03.000Z","updated_at":"2024-10-16T18:29:01.000Z","dependencies_parsed_at":"2024-10-20T20:08:38.851Z","dependency_job_id":null,"html_url":"https://github.com/InterviewAndHealth/Deployment","commit_stats":null,"previous_names":["interviewandhealth/deployment"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InterviewAndHealth%2FDeployment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InterviewAndHealth%2FDeployment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InterviewAndHealth%2FDeployment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InterviewAndHealth%2FDeployment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InterviewAndHealth","download_url":"https://codeload.github.com/InterviewAndHealth/Deployment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246249222,"owners_count":20747167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","deployment","ec2"],"created_at":"2024-10-22T12:08:30.425Z","updated_at":"2025-03-29T21:41:18.037Z","avatar_url":"https://github.com/InterviewAndHealth.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to deploy the application on EC2 instance\n\n## Prerequisites\n\n- Create a Ubuntu EC2 instance on AWS.\n- Update the security group to allow incoming traffic on port 80, 443, 22 and other ports as required.\n- Connect to the instance using SSH.\n- Update the instance.\n\n```bash\nsudo apt-get update -y\n```\n\n## Python application setup\n\n- Install python3 and pip3.\n\n```bash\nsudo apt install python3 python3-pip -y\n```\n\n## Node.js application setup\n\n- Install Node.js and npm.\n\n```bash\nsudo apt-get install nodejs npm -y\n```\n\n## Docker and Docker Compose setup\n\n- Install and configure Docker.\n\n```bash\nsudo apt install docker.io -y\nsudo systemctl start docker\nsudo systemctl enable docker\nsudo usermod -aG docker ubuntu\n```\n\n- Install Docker Compose.\n\n```bash\nsudo curl -L \"https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose\nsudo chmod +x /usr/local/bin/docker-compose\n```\n\n- Check the installation by running the following commands.\n\n```bash\ndocker --version\ndocker-compose --version\n```\n\n## Deploy the application\n\n- Clone the repository you want to deploy.\n\n```bash\ngit clone \u003crepository-url\u003e\ncd \u003crepository-name\u003e\n```\n\n- If you are using Docker Compose, run the following command.\n\n```bash\ndocker-compose up -d\n```\n\n- Start the new screen session. Replace `\u003cscreen-name\u003e` with the name of the screen you want to create.\n\n```bash\nscreen -S \u003cscreen-name\u003e\n```\n\n- If you want to copy the environment file from the local machine to the EC2 instance, use the following command.\n\n```bash\nrsync -avz -e \"ssh -i \u003ckey-file\u003e\" \u003clocal-path\u003e ubuntu@\u003cpublic-ip\u003e:\u003cremote-path\u003e\n```\n\n- Run the following command to start the application.\n\n  - ### Python application\n\n    - Create a virtual environment and install the dependencies.\n\n    ```bash\n    python3 -m venv .venv\n    source .venv/bin/activate\n    pip install -r requirements.txt\n    ```\n\n    - Run application specific commands like environment variable setup, etc.\n\n    - Start the application.\n\n    ```bash\n    python app.py\n    ```\n\n  - ### Node.js application\n\n    - Install the dependencies.\n\n    ```bash\n    npm install\n    ```\n\n    - Run application specific commands like environment variable setup, etc.\n\n    - Start the application.\n\n    ```bash\n    npm start\n    ```\n\n- Detach the screen session by pressing `Ctrl + A` followed by `D`.\n\n- To reattach the screen session, run the following command.\n\n```bash\nscreen -ls\nscreen -x \u003cscreen-id\u003e\n```\n\n## Setup Apache as a reverse proxy\n\n- Create a `A` record in the DNS settings of the domain pointing to the public IP of the EC2 instance.\n\n- Install Apache server.\n\n```bash\nsudo apt-get install apache2 -y\n```\n\n- Install certbot and python3-certbot-apache.\n\n```bash\nsudo apt install certbot python3-certbot-apache -y\n```\n\n- Configure Apache to use the SSL certificate.\n\n```bash\nsudo certbot --apache -d \u003cdomain-name\u003e\n```\n\n- Update the Apache configuration file.\n\n```bash\ncd /etc/apache2/sites-available/\nsudo nano 000-default-le-ssl.conf\n```\n\n- Add the following lines just before the `ServerName` directive. Replace `\u003cport\u003e` with the port on which the application is running.\n\n```apache\nProxyPass / http://127.0.0.1:\u003cport\u003e\nProxyPassReverse / http://127.0.0.1:\u003cport\u003e\n```\n\n- Enable the configuration and restart Apache.\n\n```bash\nsudo a2enmod proxy\nsudo a2enmod proxy_http\nsudo systemctl restart apache2\n```\n\n- Access the application using the domain name.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterviewandhealth%2Fdeployment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finterviewandhealth%2Fdeployment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterviewandhealth%2Fdeployment/lists"}