Contributing to Lokahostcp’s development
Lokahostcp is an open-source project, and we welcome contributions from the community. Please read the contributing guidelines for additional information.
Lokahostcp is designed to be installed on a web server. To develop Lokahostcp 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 Lokahostcp for development.
These instructions use Multipass to create an Ubuntu VM. Feel free to adapt the commands for any virtualization software you prefer.
Install Multipass for your OS
Fork Lokahostcp and clone the repository to your local machine
bashgit clone https://github.com/YourUsername/lokahostcp.git ~/projectsCreate an Ubuntu VM with at least 2GB of memory and 15GB of disk space
(if running VM on ARM architecture e.g. Apple M1, use at least 12GB of memory)
bashmultipass launch --name lokahostcp-dev --memory 4G --disk 15G --cpus 4Mount your cloned repository to the VM's home directory
bashmultipass mount ~/projects/lokahostcp lokahostcp-dev:/home/ubuntu/lokahostcpSSH into the VM as root then install some required packages
bashmultipass exec lokahostcp-dev -- sudo bash sudo apt update && sudo apt install -y jq libjq1Navigate to
/srcin the VM then build Lokahostcp packagesbashcd src ./lcp_autocompile.sh --all --noinstall --keepbuild '~localsrc'Navigate to
/installin the VM then install Lokahostcp with these flags(update the installation flags to your liking, note that login credentials are set here)
bashcd ../install bash lcp-install-ubuntu.sh --hostname demo.lokahost.online --email admin@example.com --username admin --password Password123 --with-debs /tmp/lokahostcp-src/deb/ --interactive no --forceReboot the VM (and exit SSH session)
bashrebootOn your local machine, find the IP address of the VM
(give the VM time to reboot for the IP to appear)
bashmultipass listVisit the VM's IP address in your browser using the default Lokahostcp port and login with
admin/Password123(proceed past any SSL errors you see when loading the page)
Lokahostcp is now running in a virtual machine. If you'd like to make changes to the source code and test them in your browser, please continue to the next section.
WARNING
Sometimes (with Multipass) the mapping between the source code directory on your local machine to the directory in the VM can be lost with a "failed to obtain exit status for remote process" error. If this happens simply unmount and remount e.g.
multipass unmount lokahostcp-dev
multipass mount ~/projects/lokahostcp lokahostcp-dev:/home/ubuntu/lokahostcpMaking changes to Lokahostcp
After setting up Lokahostcp in a development VM you can now make changes to the source code at ~/projects/lokahostcp on your local machine (outside of the VM) using your editor of choice.
Below are some instructions for making a change to Lokahostcp's UI, running the build script and testing the change locally.
On your local machine, make a change to a file that is easy to test
e.g. change the body background color to red in
web/css/src/base.cssSSH into the VM as root and navigate to
/srcbashmultipass exec lokahostcp-dev -- sudo bash cd srcRun the Lokahostcp build script
bash./lcp_autocompile.sh --lokahostcp --install '~localsrc'Reload the page in your browser to see the change
Please refer to the contributing guidelines for more details on submitting code changes for review.
INFO
A backup is created each time the Lokahostcp build script is run. If you run this often it can fill up your VM's disk space. You can delete the backups by running rm -rf /root/lcp_backups as root user on the VM.
Running automated tests
We currently use Bats to run our automated tests.
Install
# Clone Lokahostcp repo with testing submodules
git clone --recurse-submodules https://github.com/lokahostcp/lokahostcp
# 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/localRun
DANGER
Do not run any testing script on a live server. It might cause issues or downtime!
# Run Lokahostcp tests
test/test.bats