development.md 6.7 KB

Contributing to Hestia’s development

Hestia is an open-source project, and we welcome contributions from the community. Please read the contributing guidelines for additional information.

Hestia is designed to be installed on a web server. To develop Hestia on your local machine, a virtual machine is recommend.

::: warning Development builds are unstable. If you encounter a bug please report it via GitHub or submit a Pull request. :::

Creating a virtual machine for development

These are example instructions for creating a virtual machine running Hestia for development.

These instructions use Multipass to create the VM. Feel free to adapt the commands for any virtualization software you prefer.

  1. Install Multipass for your OS.

  2. Fork Hestia and clone the repository to your local machine

    git clone https://github.com/YourUsername/hestiacp.git $HOME/projects
    
  3. Create an Ubuntu VM with at least 2G of memory

    multipass launch --name hestia-dev --mem 2G
    
  4. Map your cloned repository to the VM's home directory

    multipass mount $HOME/projects/hestiacp hestia-dev:/home/ubuntu/hestiacp
    
  5. SSH into the VM as root and install some required packages

    multipass exec hestiacp-dev -- sudo bash
    sudo apt update && sudo apt install -y jq libjq1
    
  6. Navigate to /src and build Hestia packages

    cd src
    ./hst_autocompile.sh --hestia --noinstall --keepbuild '~localsrc'
    
  7. Navigate to /install and install Hestia

(update the installation flags to your liking, note that login credentials are set here)

   cd ../install
   bash hst-install.sh -D /tmp/hestiacp-src/deb/ --interactive no --email admin@example.com --password password123 --hostname demo.hestiacp.com -f
  1. Reboot VM (and exit SSH session)

    reboot
    
  2. Find the IP address of the VM

    multipass list
    
  3. Visit the VM's IP address in your browser using the default Hestia port and login with admin/password123

(bypass any SSL errors you see when loading the page)

   e.g. https://192.168.64.15:8083

Hestia is now running in a virtual machine. If you'd like to make changes to the source code and test them, please continue to the next section.

Making changes to Hestia

After setting up Hestia in a VM you can now make changes to the source code in $HOME/projects/hestiacp on your local machine using your editor of choice.

The following are example instructions for making a change to Hestia's UI and testing it locally.

::: info Please ensure you have Yarn v3 installed and are using Node.js v16 or higher. :::

  1. At the root of the project on your local machine, install Node dependencies

    yarn install
    
  2. Make a change to a file that we can later test, then build the UI assets

e.g. change the body background color to red in web/css/src/base.css then run:

   yarn build
  1. SSH into the VM as root and navigate to /src

    multipass exec hestia-dev -- sudo bash
    cd src
    
  2. Run the Hestia build script

    ./hst_autocompile.sh --hestia --install '~localsrc'
    
  3. Reload the page in your browser to see your changes

::: info A backup is created each time the Hestia build script is run. If you run this a lot it can fill up your VM's disk space. You can delete the backups by running rm -rf /root/hst_backups as root user on the VM. :::

Please refer to the contributing guidelines for more details on submitting code changes for review.

Building packages

::: info For building hestia-nginx or hestia-php, at least 2 GB of memory is required! :::

Here is more detailed information about the build scripts that are run from src:

Build packages only

# Only Hestia
./hst_autocompile.sh --hestia --noinstall --keepbuild '~localsrc'
# Hestia + hestia-nginx and hestia-php
./hst_autocompile.sh --all --noinstall --keepbuild '~localsrc'

Build and install packages

::: info Use if you have Hestia already installed, for your changes to take effect. :::

# Only Hestia
./hst_autocompile.sh --hestia --install '~localsrc'
# Hestia + hestia-nginx and hestia-php
./hst_autocompile.sh --all --install '~localsrc'

Installing Hestia from a branch

The following is useful for testing a Pull Request or a branch on a fork.

# Replace with https://github.com/username/hestiacp.git if you want to test a branch that you created yourself
git clone https://github.com/hestiacp/hestiacp.git
cd ./hestiacp/

# Replace main with the branch you want to test
git checkout main

cd ./src/

# Compile packages
./hst_autocompile.sh --all --noinstall --keepbuild '~localsrc'

cd ../install

bash hst-install-{os}.sh --with-debs /tmp/hestiacp-src/deb/

Any option can be appended to the installer command. See the complete list.

Updating Hestia from GitHub

The following is useful for pulling the latest staging/beta changes from GitHub and compiling the changes.

::: info The following method only supports building the hestia package. If you need to build hestia-nginx or hestia-php, use one of the previous commands. :::

v-update-sys-hestia-git [USERNAME] [BRANCH]

Note: Sometimes dependencies will get added or removed when the packages are installed with dpkg. It is not possible to preload the dependencies. If this happens, you will see an error like this:

dpkg: error processing package hestia (–install):
dependency problems - leaving unconfigured

To solve this issue, run:

apt install -f

Running automated tests

For automated tests we currently use Bats.

Install

# Clone Hestia repo with testing submodules
git clone --recurse-submodules https://github.com/hestiacp/hestiacp
# Or, using an existing local repo with an up-to-date main branch
git submodule update --init --recursive

# Install Bats
test/test_helper/bats-core/install.sh /usr/local

Run

::: danger Do not run any testing script on a live server. It might cause issues or downtime! :::

# Run Hestia tests
test/test.bats