Hosting Manual: Setting UP QubiC Platform

Existing Server Deployment:

// Go to dir where dockerfile is stored
sudo docker build --no-cache -t my-qubic-app .
sudo docker run -p 3306:3306 -p 5000:5000 my-qubic-app

sudo docker-compose build

sudo docker network create my-network

sudo docker run --network my-network -it mysql:latest mysql -u root --host doltdb --port 3306

sudo docker-compose up

New Server Deployment: From Scratch

API & Platform: Follow these steps

  1. Log in to Qubic3 Server(You must have Qubic3 server access)

  2. sudo apt-get update
    sudo apt-get install docker.io
  3. nano Dockerfile

  4. Copy and paste this content

    # Use a base image with Ubuntu
    FROM ubuntu:latest
    
    # Set non-interactive mode
    ENV DEBIAN_FRONTEND=noninteractive
    
    # Update package sources and install necessary packages
    RUN apt-get update && apt-get install -y \
        git \
        python3 \
        python3-venv \
        curl \
        lsof \
        wget \
        npm \
        && rm -rf /var/lib/apt/lists/*
    
    RUN apt-get update && apt-get install -y supervisor \
        && rm -rf /var/lib/apt/lists/*
    # Clone repositories
    RUN git clone https://gitlab.com/DevanshuBrahmbhatt/qubic-data-storage.git /app/qubic-data-storage 
    
    # Install Dolt
    RUN curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash \
        && useradd -r -m -d /var/lib/doltdb dolt
    
    # Additional steps for Dolt setup
    RUN dolt config --global --add user.email doltServer@company.com \
        && dolt config --global --add user.name "Dolt Server Account"
    
    # Set up and configure MySQL
    RUN apt-get update \
        && apt-get install -y lsb-release \  
        && wget http://repo.mysql.com/mysql-apt-config_0.8.26-1_all.deb \
        && dpkg -i mysql-apt-config_0.8.26-1_all.deb \
        && apt-get update \
        && apt-get install -y mysql-shell mysql-server
    
    # Install required Python packages
    RUN python3 -m venv /app/venv \
        && /app/venv/bin/pip3 install -r /app/qubic-data-storage/requirements.txt 
    
    # Initialize Dolt repository and create the "calibration" database
     RUN cd /app/qubic-data-storage \
        && dolt init \
        && dolt sql -q "CREATE DATABASE calibration"
    
    
    # Set working directory for frontend
    
    WORKDIR /app/qubic-data-storage/qubic-data-storage-frontend
    
    # Install Node.js using NVM
    RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \
        && . ~/.nvm/nvm.sh \
        && nvm install 14 \
        && nvm use 14 \
        && npm install -g yarn
    
    RUN ls -la
    
    ENV PATH="/usr/bin/versions/node/v14.21.3/bin:${PATH}"
    # Build and run Vue.js frontend
    RUN yarn install 
    RUN yarn build
    
    # Expose the necessary ports
    EXPOSE 3306 5000
    
    # Set working directory to qubic-data-storage
    WORKDIR /app/qubic-data-storage
    
    # Activate the virtual environment, run dolt sql-server, and start the services
    # CMD ["/bin/bash", "-c", "\
    #     source /app/venv/bin/activate && \
    #     dolt sql-server -u root & \
    #     /app/venv/bin/flask run --host=0.0.0.0"]
    
    # Copy supervisor configuration
    COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
    
    # Start processes
    CMD ["/usr/bin/supervisord"]
  5. ctrl+o
    Enter
    ctrl+x
  6. nano supervisord.conf

  7. copy and paste this content

    [supervisord]
    nodaemon=true
    
    [program:dolt]
    command=/bin/bash -c "dolt sql-server -u root"
    autostart=true
    autorestart=true
    
    [program:flask]
    command=/bin/bash -c "source /app/venv/bin/activate && /app/venv/bin/flask run --host=0.0.0.0"
    directory=/app/qubic-data-storage
    autostart=true
    autorestart=true
  8. ctrl+o
    Enter
    ctrl+x
  9. sudo docker build --no-cache -t my-qubic-app .

  10. sudo docker run -p 3306:3306 -p 5000:5000 my-qubic-app

Troubleshooting commands for Docker

# checking process on port 5000 server
sudo lsof -i :5000
# kill process 
sudo kill [PID]

# list all containers
sudo docker ps 
# stop container
sudo docker stop [CONTAINER_ID]
# remove container
sudo docker rm [CONTAINER_ID or NAME]

# list all images
sudo docker images
# remove the docker image
sudo docker rmi [IMAGE_ID or REPOSITORY:TAG]

# (Free up space)List docker volumes
sudo docker volume ls
sudo docker volume rm [VOLUME_NAME]

#(Free up network space) List docker networks
sudo docker network ls
sudo docker network rm [NETWORK_NAME]

# Restart docker
sudo systemctl restart docker

Jupyter Notebook: Follow these steps

 python3 setup.py sdist bdist_wheel
 pip3 install .

Last updated