110 lines
2.5 KiB
Markdown
110 lines
2.5 KiB
Markdown
---
|
|
gitea: none
|
|
include_toc: true
|
|
---
|
|
|
|
# Trigger Home Page
|
|
|
|
A homepage replacement for your browser built on React and SQL.
|
|
|
|
|
|
## Prerequisite Setup
|
|
|
|
* Install MariaDB/MySQL
|
|
|
|
* Install Git
|
|
|
|
* Install Node 20+
|
|
|
|
Navigate to the TriggerFrontend and TriggerBackend folders and run:
|
|
|
|
* npm install --legacy-peer-deps
|
|
|
|
### WARNING !!!
|
|
|
|
Trigger does not handle authentication of any kind. It is designed to be used behind a reverse proxy, such as NGINX, or other service that can request authentication prior to serving the page.
|
|
|
|
## MariaDB/MySQL setup
|
|
|
|
Connect to your server:
|
|
|
|
```shell
|
|
sudo mariadb
|
|
```
|
|
|
|
Create the database and new administration user:
|
|
|
|
```sql
|
|
create database trigger_database;
|
|
|
|
grant all privileges on trigger_database.* TO 'triggeradmin'@'localhost' identified by 'trigger';
|
|
|
|
flush privileges;
|
|
```
|
|
|
|
⚠️ Update the above grant line to use a username and password other than the default. ⚠️
|
|
|
|
Import defaultDatabase.sql into your database server using your preferred management application or run the following via the terminal:
|
|
|
|
```shell
|
|
sudo mariadb -u triggeradmin -p trigger_database < defaultDatabase.sql
|
|
```
|
|
|
|
## Configuration
|
|
|
|
Clone both the [TriggerFrontend](https://sean.bet/gitea/smedmunds/TriggerFrontend) and [TriggerBackend](https://sean.bet/gitea/smedmunds/TriggerBackend) repositories. They do not need to be run from the same folder, or even the same machine.
|
|
|
|
Trigger uses .env files to configure the connection to the database as well as the base url for the application. Prior to running or building the app, you will need to edit the file at TriggerBackend/.env and TriggerFrontend/.env to match your environment.
|
|
|
|
Make a copy of the example file:
|
|
|
|
```shell
|
|
cp TriggerFrontend/.env.example TriggerFrontend/.env
|
|
cp TriggerBackend/.env.example TriggerBackend/.env
|
|
```
|
|
|
|
⚠️ Update the following fields to match your environment's URLs. The Domains and Base URL here must be defined without a leading '/'! ⚠️
|
|
|
|
Frontend .env.example
|
|
```shell
|
|
VITE_DOMAIN_DEV='http://localhost:5000'
|
|
VITE_DOMAIN_PROD='https://domain.local'
|
|
VITE_BASE_URL='trigger'
|
|
```
|
|
|
|
Backend .env.example
|
|
|
|
```shell
|
|
DB_HOST='127.0.0.1'
|
|
DB_USER='triggeradmin'
|
|
DB_PASS='trigger'
|
|
```
|
|
|
|
## Run/build
|
|
To run the application without building:
|
|
|
|
```shell
|
|
npm run dev
|
|
```
|
|
|
|
To build the application for production:
|
|
|
|
#### ⚠️ Add any background images to public/backgrounds to include them in the build ⚠️
|
|
|
|
```shell
|
|
npm run build
|
|
```
|
|
|
|
Run with pm2:
|
|
|
|
```shell
|
|
sudo npm install -g pm2
|
|
|
|
sudo pm2 serve ./dist --no-daemon --spa --port 3000
|
|
|
|
sudo pm2 start server.cjs
|
|
```
|
|
|
|
### TODO
|
|
|
|
- Image uploads for backgrounds? |