SanjinDedic / agent_games

Secure, extensible agent competition platform API build with FastAPI, SQLmodel, Pydantic and Docker
9 stars 2 forks source link

Update deplloy.yml to run a check if docker is installed and running. If not then install and run docker #51

Closed SanjinDedic closed 3 months ago

SanjinDedic commented 3 months ago

Check if docker is installed anr running If not then install and run docker. The is extremely important in terms of the app being portable and making it easy for anyone to get an agent games server running.

The code below attempts to do this but needs a debug

          # Check if Docker is installed and running
          if ! command -v docker &> /dev/null; then
            echo "Docker not found. Installing Docker..."
            sudo apt-get update
            sudo apt-get install -y docker.io
            sudo systemctl start docker
            sudo systemctl enable docker
          else
            echo "Docker is already installed."
          fi
          # Check Docker version
          docker_version=$(docker --version | cut -d " " -f 3 | cut -d "," -f 1)
          required_version="24.0.7"
          if [ "$docker_version" != "$required_version" ]; then
            echo "Updating Docker to version $required_version..."
            sudo apt-get update
            sudo apt-get install -y docker.io=$required_version*
          fi
          # Ensure Docker is running
          if ! sudo systemctl is-active --quiet docker; then
            echo "Starting Docker service..."
            sudo systemctl start docker
          fi
          # Pull the latest Docker image
          sudo docker pull matthewhee/agent_games:latest

@DawoodLaiq can you look into this. From the history on the server I can see you used different commands:

sudo docker start run_with_docker