Star Wars Unlimited Sim
If you need to contact us or would like to get involved in the dev work, please reach out in our Discord server!
We have two options for setting up a development environment: a docker-based method that is fully automatic and supports live debug, or a walkthrough for how to set up the environment manually on your local machine.
We provide a docker environment for local run with built-in xdebug support for live debugging, which can be installed and started in two commands if you already have docker set up. A preconfigured setup is provided for Visual Studio Code (it would be very simple to set up other tools as well).
If you are on Windows, please follow the instructions for installing Docker Desktop on Windows (either WSL or Hyper-V backend should work but we have only tested with WSL): https://docs.docker.com/desktop/install/windows-install/
Run the following commands to start / stop the service
bash karabast.sh start
bash karabast.sh stop
bash karabast.sh restart
Open this address in your browser: http://localhost:8080/SWUOnline/MainMenu.php
If you want to play a game against yourself, open multiple windows / tabs and connect.
Xdebug is already running in the service, you can use these steps to do live debugging with breakpoints in Visual Studio Code:
- Install an extension that supports PHP debugging, such as https://marketplace.visualstudio.com/items?itemName=DEVSENSE.phptools-vscode
- We have a preconfigured launch.json to enable the debug action. In the vscode debug window (Ctrl + Shift + D), select the configuration
SWUOnline: Listen for Xdebug
and hit the Run button. - You are now connected for debugging, add a breakpoint and try it out :)
Additionally, any tool that can connect to xdebug remotely should work as well.
We have a Google Doc with instructions for setting up the environment. Some steps may be missing or require extra detail, if you find any issues please contact us via the Discord so we can improve the document.
https://docs.google.com/document/d/10u3qGpxr1ddvwobq8__lVZfYCgqtanZShHEaYljiA1M/edit?usp=sharing
This guide explains how to set up CI/CD, including deploying with GitHub, securing webhooks, and configuring environment variables.
-
On the server, generate an SSH key pair by running:
ssh-keygen -t rsa -b 4096 -C "deploy-key"
This will create two files:
- Private Key:
~/.ssh/id_rsa
- Public Key:
~/.ssh/id_rsa.pub
- Private Key:
-
In your GitHub repository, go to Settings > Deploy Keys and add the content of
~/.ssh/id_rsa.pub
as a new deploy key. -
Test the SSH connection to GitHub:
ssh -T [email protected]
-
Generate a secret key to secure the webhook:
openssl rand -hex 32
Save this secret for later use.
-
In your GitHub repository, go to Settings > Webhooks and create a new webhook with the following settings:
- Payload URL:
https://karabast.net/SWUOnline/Webhook.php
- Content Type:
application/json
- Secret:
<webhook-secret>
(use the secret generated earlier) - SSL Verification: Enabled
- Events: Select "Just the push event" to trigger the webhook on push events.
- Payload URL:
To secure your project and set environment variables:
- Navigate to your project directory:
/opt/lampp/htdocs/SWUOnline
- Create or edit an
.htaccess
file with the following content:RedirectMatch 404 /\.git SetEnv MYSQL_SERVER_NAME localhost SetEnv MYSQL_SERVER_USER_NAME root SetEnv MYSQL_ROOT_PASSWORD <mysql-root-password> SetEnv WEBHOOK_SECRET <webhook-secret> SetEnv PATREON_CLIENT_ID <patreon-client-id> SetEnv PATREON_CLIENT_SECRET <patreon-client-secret>
This configuration ensures that the .git
folder is inaccessible and adds environment variables for your project.
If your project is not yet connected to GitHub, follow these steps:
-
Initialize the project as a Git repository:
git init
-
Add the GitHub repository as the remote origin:
git remote add origin [email protected]:SWU-Karabast/SWUOnline.git
-
Sync the project with the remote repository:
git fetch --all
-
Ensure the server files match the repository by running:
git reset --hard origin/main
Note: Files listed in
.gitignore
will remain unaffected. Back up important files before running this command to avoid accidental data loss.
The Webhook.php
script will execute using the daemon
user, so it must have permissions to run git pull
.
-
Edit the sudoers file:
sudo visudo
-
Add the following line to grant limited permissions:
daemon ALL=(ALL) NOPASSWD: /usr/bin/git
Your project is now configured for CI/CD. Any commit pushed to the main
branch will trigger the webhook, which executes a git pull
on the server to update the project files automatically.