Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DevOps] Config and start prd server on Vscale with new OS version, fix deply #2605

Closed
ElenaSpb opened this issue Sep 11, 2024 · 7 comments
Closed
Assignees
Labels

Comments

@ElenaSpb
Copy link
Contributor

ElenaSpb commented Sep 11, 2024

[DevOps] Config and start prd server on Vscale with new OS version, fix deploy

https://vds.selectel.ru/
ask creds Lena https://t.me/ElenaLovesSpb

@DmitriyStoyanov
Copy link
Collaborator

DmitriyStoyanov commented Oct 1, 2024

Little action plan:

  • Create new server brain-up-new on vds.selectel.ru - Created with ubuntu 22.04 64bit. 512MB Memory / 20GB SSD / 1CPU
  • Install docker
  • install docker-compose
  • Install github self-hosted runner - installed with label selectel - vds_selectel_brain-up-new
  • look how to copy db from old instance - created backup from old db 2024-10-03 01:06 and copied to new instance
  • switch pipelines to deploy into new instance - PR Devops/new instance #2618
  • enable swap with 1GB, because 512MB is not enough for our app
  • deploy new app on new instance
  • update db from backup (possibly create new backup when all testing is done
  • copy cert volumes from previous instance
  • switch domain name from old instance to new one
  • check if all works fine

@DmitriyStoyanov
Copy link
Collaborator

started app without certs on new instance here: http://188.68.222.249/

@DmitriyStoyanov
Copy link
Collaborator

certificates copied, frontend with tls was started and dns records changed from old to new instance
So now https://brainup.site/ should point to new instance

@DmitriyStoyanov
Copy link
Collaborator

hm, after merge PR #2618 there are some errors:
https://github.com/Brain-up/brn/actions/runs/11163834931/job/31031943111
ERROR: for brn 'ContainerConfig'

@DmitriyStoyanov
Copy link
Collaborator

fixed by stopping locally front and backend containers and deploying it via pipeline
https://github.com/Brain-up/brn/actions/runs/11163834931/job/31033549957

@DmitriyStoyanov
Copy link
Collaborator

about brief documentation:
scripts used during this new instance creation and moving data from old one

# login as root and update all packages and kernels
apt update
apt upgrade

reboot


# install docker from the doc https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04

apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update

apt install docker-ce
systemctl status docker


# install docker-compose
apt install docker-compose

# create user for github-runner

useradd github-runner
mkdir /home/github-runner
chown github-runner:github-runner /home/github-runner

su - github-runner

# install github-runner from documentation described on page https://github.com/Brain-up/brn/settings/actions/runners/new
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64-2.319.1.tar.gz -L https://github.com/actions/runner/releases/download/v2.319.1/actions-runner-linux-x64-2.319.1.tar.gz
echo "3f6efb7488a183e291fc2c62876e14c9ee732864173734facc85a1bfb1744464  actions-runner-linux-x64-2.319.1.tar.gz" | shasum -a 256 -c
tar xzf ./actions-runner-linux-x64-2.319.1.tar.gz
./config.sh --url https://github.com/Brain-up/brn --token AAXXXXXX # taken from https://github.com/Brain-up/brn/settings/actions/runners/new

# to create backup from volumes on old system
for i in brn_dbdata brn_certbot-etc brn_certbot-var brn_web-root-for-certbot; do echo $i; docker run --rm -v ${i}:/data -v $(pwd):/backup busybox tar czf /backup/backup_${i}.tar.gz /data; done

# then copy backup.tar.gz file
scp -r root@31.184.253.199:/root/backup ./
scp -r backup root@188.68.222.249:/root/

# restore backup to volume with db
docker run --rm -v brn_dbdata:/dest -v $(pwd):/source busybox tar xvzf "/source/backup.tar.gz" -C /dest

# install git for checkout process
apt install git

# provide access to docker from github-runner
usermod -aG docker github-runner

# add swap with 1GB
dd if=/dev/zero of=/swapfile bs=1024 count=1048576
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap defaults 0 0">>/etc/fstab

# start db from github-runner
docker-compose up -d --no-deps db_brn

@DmitriyStoyanov
Copy link
Collaborator

So this issue can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants