Upload to server - Miol-Mor/battle-game GitHub Wiki

Update project on server

  1. Get ssh-key from @bronvic
  2. Login to server
ssh -i <PATH_TO_KEY>/myamazon.pem [email protected]
  1. Go to the game folder
cd /www/battle-game
  1. Pull changes (make sure you are on the master branch)
git pull
  1. Remove everything from docker!
docker system prune --all
  1. Restart containers and run
docker-compose up -d --build

Restart backend

docker-compose restart backend

Upload to server first time

Instruction for uploading from scratch (ubuntu):

  1. Set up docker the repository
sudo apt-get update

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  1. Install docker-engine
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io
  1. Install docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose
  1. Add current user to docker group and reboot
sudo usermod -aG docker $USER

sudo reboot
  1. Create a directory for the project and clone it
sudo mkdir /www
sudo chown -R $USER:$USER /www

git clone https://github.com/Miol-Mor/battle-game.git /www
  1. Change environment variable for backend with the real one
vim /www/battle-game/frontend/.env
  1. Build and run
docker-compose --project-directory /www/battle-game build
docker-compose --project-directory /www/battle-game up