Skip to content

Deployment Overview of Restyaboard on Server

Prerequisites and Basic Requirements

The deployment of Restyaboard requires a server running Ubuntu with the following specifications:

  • Operating System: Ubuntu (compatible with apt package manager)
  • Privileges: Root access or sudo privileges are required to install Docker and manage system services
  • Domain: A valid domain name is required for the Nginx reverse proxy and SSL certificate generation via Certbot
  • Ports:
  • Port 80 and 443 must be open for the Nginx reverse proxy
  • Port 8080 is used internally by the Restyaboard application container (bound to 127.0.0.1)
  • Port 5432 is used internally by the PostgreSQL database container

File and Directory Structure

The deployment utilizes specific directories on the host system to store application data, database files, and proxy configurations:

  • /opt/restyaboard/postgres: Persistent storage volume for the PostgreSQL database data
  • /opt/restyaboard/uploads: Directory for Restyaboard file uploads
  • /root/nginx: Directory containing the Nginx and Certbot Docker Compose configuration
  • /root/nginx/compose.yml: The Docker Compose file defining the Nginx and Certbot services
  • /data/nginx/user_conf.d: Directory containing custom Nginx configuration files for the host
  • /data/nginx/nginx-certbot.env: Environment file containing configuration for the Nginx-Certbot service
  • /etc/letsencrypt: Volume mount for Let's Encrypt SSL certificates

Application Installation Process

The Restyaboard application is deployed using Docker containers. The process involves installing Docker Engine, creating a dedicated network, and running the application and database containers.

  1. Docker Installation: The system installs Docker CE, Docker CLI, containerd.io, and the Docker Compose plugin.
  2. Network Creation: A dedicated Docker network named restya_net is created to isolate the application and database containers.
  3. Image Pulling: The following Docker images are pulled from the registry:
    • postgres:15
    • restyaplatform/restyaboard:v1.7.1
  4. Database Initialization:
    • A PostgreSQL container named restya_db is started.
    • The database restyaboard is created.
    • A database role named restya is created with login privileges.
    • The schema is imported from a SQL file located inside the application container if the tables do not already exist.
  5. Application Launch:
    • The Restyaboard container named restya_app is started.
    • The application connects to the database using the restya role.
    • The application listens on port 8080 bound to 127.0.0.1.

Docker Containers and Their Deployment

The deployment consists of three primary Docker containers:

  • restya_db:
  • Image: postgres:15
  • Network: restya_net
  • Environment Variables:
    • POSTGRES_USER=postgres
    • POSTGRES_PASSWORD: Set via the restya_db_password variable
    • POSTGRES_DB=restyaboard
  • Volume Mount: /opt/restyaboard/postgres:/var/lib/postgresql/data
  • Restart Policy: unless-stopped

  • restya_app:

  • Image: restyaplatform/restyaboard:v1.7.1
  • Network: restya_net
  • Environment Variables:
    • POSTGRES_HOST=restya_db
    • POSTGRES_PORT=5432
    • POSTGRES_ADMIN_USER=postgres
    • POSTGRES_ADMIN_PASS: Set via the restya_db_password variable
    • RESTYA_DB_USERNAME=restya
    • RESTYA_DB_USERPASS: Set via the restya_db_password variable
    • RESTYA_DB=restyaboard
  • Port Mapping: 127.0.0.1:8080:80
  • Restart Policy: unless-stopped

  • nginx:

  • Image: jonasal/nginx-certbot:latest
  • Network Mode: host
  • Environment Variables:
  • Volume Mounts:
    • nginx_secrets:/etc/letsencrypt
    • /data/nginx/user_conf.d:/etc/nginx/user_conf.d
  • Restart Policy: unless-stopped

Databases

The application uses a PostgreSQL database hosted within a Docker container.

  • Connection Method: The application connects to the database via the internal Docker network using the hostname restya_db.
  • Storage Location: Database data is persisted in the host directory /opt/restyaboard/postgres.
  • Database Name: restyaboard
  • User Credentials:
  • Application User: restya
  • Admin User: postgres
  • Password: Defined by the restya_db_password variable during deployment.
  • Schema Initialization: If the oauth_clients or settings tables are missing, the deployment script automatically copies the appropriate SQL schema file from the application container to the database container and executes it.

Proxy Servers

Access to the Restyaboard application is provided through an Nginx reverse proxy managed by Docker Compose.

  • Proxy Service: The nginx container runs the jonasal/nginx-certbot image.
  • Configuration:
  • The proxy configuration is located in /data/nginx/user_conf.d.
  • A specific configuration file (e.g., {{ prefix }}{{ server_id }}.hostkey.in.conf) is updated to include the proxy pass directive.
  • Routing:
  • The Nginx configuration routes traffic to the Restyaboard application at http://127.0.0.1:8080.
  • The proxy_pass directive is set to http://127.0.0.1:8080; within the location block.
  • SSL/TLS: SSL certificates are managed automatically by Certbot within the Nginx container, storing secrets in the nginx_secrets volume.
  • Deployment Command: The proxy service is started using docker compose -p certproxy up -d nginx from the /root/nginx directory.

Starting, Stopping, and Updating

The following commands are used to manage the lifecycle of the deployed containers:

  • Start the Nginx Proxy:

    docker compose -p certproxy up -d nginx
    
    This command is executed from the /root/nginx directory.

  • Restart the Application Container:

    docker restart restya_app
    

  • Remove Containers:

    docker rm -f restya_app
    docker rm -f restya_db
    

  • Check Container Status:

    docker inspect -f '{{.State.Status}}' restya_app
    docker inspect -f '{{.State.Running}}' restya_db
    

  • Verify Database Readiness:

    docker exec restya_db pg_isready -U postgres -d restyaboard -h 127.0.0.1
    

  • Verify Application Availability: The application is considered ready when port 8080 on 127.0.0.1 is reachable.

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×