EYouth Server Deployment Automation


CMS - EMARKETING


Solution

  • Codedeploy Application (2)
  • Codepipeline (2)
  • Codecommit repositories (2)

How it works

  • Push your new code into your source code repository
    • Once a new code is pushed to the repo the pipeline will be triggered and a new deployment will be triggered by codedeploy service.
  • VIP: Codedeploy needes a file and a direcotory to be at the root level of your repo(both repositories) appspec.yml and scripts directory

Appspec.yml and scripts directory already exsists in the codecommit repositories for both servers

You have to run this script once (for a brand new server)

sudo apt-get install ruby-full ruby-webrick wget -y

cd /tmp

wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/releases/codedeploy-agent_1.3.2-1902_all.deb

mkdir codedeploy-agent_1.3.2-1902_ubuntu22

dpkg-deb -R codedeploy-agent_1.3.2-1902_all.deb codedeploy-agent_1.3.2-1902_ubuntu22

sed 's/Depends:.*/Depends:ruby3.0/' -i ./codedeploy-agent_1.3.2-1902_ubuntu22/DEBIAN/control

dpkg-deb -b codedeploy-agent_1.3.2-1902_ubuntu22/

sudo dpkg -i codedeploy-agent_1.3.2-1902_ubuntu22.deb

sudo systemctl list-units --type=service | grep codedeploy

sudo service codedeploy-agent status

CMS Server Configuration

CMS Nginx Configurations

server {
    server_name cms.eyouthlearning.com;


  location /static {
    autoindex on;
    alias /var/www/cms.eyouthlearning.com/staticfiles/;
  }

  location /media {
    autoindex on;
    alias /var/www/cms.eyouthlearning.com/media/;
  }

    location / {
        proxy_set_header Host $host;
        proxy_pass http://localhost:8000;
        proxy_redirect off;
    }
}

Install Dependencies

git clone -b prod https://github.com/AlaaTarekOkasha/src.git into /var/www/cms.eyouthlearning.com

sudo apt-get install python3-pip

sudo apt install virtualenv

python -m venv venv

source venv/bin/activate

pip install gunicorn 
  • To start the project use bash start
  • To Stop backend app bash stop
  • Use certbot to generate certificate for this subdomain

EMARKETING Server Configuration

EMARKETING Nginx Configurations

server    {
    root /var/www/emarketing.eyouthlearning.com;
    index index.html index.htm index.nginx-debian.html;
    server_name emarketing.eyouthlearning.com;
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.html;
        }

}

Install Dependencies

git clone https://gitlab.com/bm-kids-app/marketing-landing-page-react.git -b elham into /var/www/emarketing-react-app
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
$SHELL
nvm install 16
cd /var/www/emarketing-react-app
npm install
npm run build
sudo cp -r build/* /var/www/emarketing.eyouthlearning.com/
  • Use certbot to generate certificate for this subdomain