Skip to content

Commit 66cfe53

Browse files
authored
feat: make it easier to run locally (#1684)
1 parent 3707ac2 commit 66cfe53

8 files changed

Lines changed: 639 additions & 14 deletions

File tree

.env.example

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# BanManager WebUI - Environment Configuration
2+
# Copy this file to .env and update values as needed
3+
4+
# Server display name (shown in footer)
5+
SERVER_FOOTER_NAME=BanManagement
6+
7+
# Contact email for push notification registration
8+
CONTACT_EMAIL=youremail@example.com
9+
10+
# Database connection (defaults match docker-compose.yml)
11+
DB_HOST=127.0.0.1
12+
DB_PORT=3306
13+
DB_USER=root
14+
DB_PASSWORD=password
15+
DB_NAME=bm_local_dev
16+
DB_CONNECTION_LIMIT=5
17+
18+
# Security keys (generate unique values for production)
19+
# Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
20+
ENCRYPTION_KEY=b097b390a68441cc3bb151dd0171f25c3aabc688c50eeb26dc5e13254b333911
21+
SESSION_KEY=a73545a5f08d2906e39a4438014200303f9269f3ade9227525ffb141294f1b62
22+
23+
# Push notification VAPID keys (generate with: npx web-push generate-vapid-keys)
24+
NOTIFICATION_VAPID_PUBLIC_KEY=
25+
NOTIFICATION_VAPID_PRIVATE_KEY=
26+
27+
# Admin user credentials (used by seed script and Cypress tests)
28+
ADMIN_USERNAME=admin@banmanagement.com
29+
ADMIN_PASSWORD=testing
30+
31+
# Server configuration
32+
PORT=3000
33+
LOG_LEVEL=info
34+
35+
# Set to 'production' for production builds
36+
NODE_ENV=development

.naverc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

README.md

Lines changed: 106 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,60 +37,160 @@
3737
</p>
3838

3939
## Overview
40+
4041
- **Always connected.** Manage punishments from anywhere with seamless logins
4142
- **Cross platform.** It doesn't matter what OS you use, it just works wherever Node.js runs
4243
- **Responsive interface.** Manage your community from any device at any time
4344

4445
To learn more about configuration, usage and features of BanManager, take a look at [the website](https://banmanagement.com/) or view [the demo](https://demo.banmanagement.com).
4546

4647
## Features
48+
4749
- Appeal punishments
4850
- Ban, unban, mute, and warn players
4951
- Review and manage reports on the go
5052
- Custom roles and flexible permissions
5153
- A single interface for multiple Minecraft servers
5254

53-
## Requirements
54-
- The latest [Node.js](https://nodejs.org/) LTS version (even numbered)
55+
## Installation (Production)
56+
57+
For deploying BanManager WebUI on your own server, see the **[full installation guide](https://banmanagement.com/docs/webui/install)**.
58+
59+
### Requirements
60+
61+
- [Node.js](https://nodejs.org/) LTS (v20 or v22)
5562
- MySQL v5+ or MariaDB v10+
5663
- Minecraft server with [BanManager](https://github.com/BanManagement/BanManager) & [BanManager-WebEnhancer](https://ci.frostcast.net/job/BanManager-WebEnhancer/) plugins configured to [use MySQL or MariaDB](https://banmanagement.com/docs/banmanager/install#setup-shared-database-optional)
5764

58-
## Installation
59-
See [setup instructions](https://banmanagement.com/docs/webui/install)
65+
### Quick Install
6066

61-
## Development
67+
```bash
68+
git clone https://github.com/BanManagement/BanManager-WebUI.git
69+
cd BanManager-WebUI
70+
npm ci --production
71+
npm run setup
6272
```
73+
74+
The setup wizard will guide you through configuring your database connection and creating an admin account.
75+
76+
---
77+
78+
## Development
79+
80+
Want to contribute or run a local development environment? This section is for you.
81+
82+
### Prerequisites
83+
84+
- [Node.js](https://nodejs.org/) LTS (v20 or v22)
85+
- [Docker](https://www.docker.com/) (for local MySQL database)
86+
87+
### Quick Start
88+
89+
```bash
90+
# Clone the repository
6391
git clone git@github.com:BanManagement/BanManager-WebUI.git
92+
cd BanManager-WebUI
93+
94+
# Install dependencies
6495
npm install
65-
npm run setup
96+
97+
# Copy environment configuration
98+
cp .env.example .env
99+
100+
# Start MySQL and seed the database (first time setup)
101+
npm run dev:setup
102+
103+
# Start the development server
66104
npm run dev
67105
```
68106

107+
The application will be available at http://localhost:3000
108+
109+
### Test Accounts
110+
111+
After seeding, the following accounts are available:
112+
113+
| Role | Email | Password |
114+
| ----- | ----------------------- | -------- |
115+
| Guest | guest@banmanagement.com | testing |
116+
| User | user@banmanagement.com | testing |
117+
| Admin | admin@banmanagement.com | testing |
118+
119+
### Available Scripts
120+
121+
| Script | Description |
122+
| -------------------- | ------------------------------------------------- |
123+
| `npm run dev:setup` | Start MySQL container and seed the database |
124+
| `npm run dev` | Start development server with hot reloading |
125+
| `npm run db:start` | Start the MySQL Docker container |
126+
| `npm run db:stop` | Stop the MySQL Docker container |
127+
| `npm run seed` | Run migrations and seed data (fails if DB exists) |
128+
| `npm run seed:reset` | Drop existing database and re-seed |
129+
| `npm run build` | Build for production |
130+
| `npm run test` | Run linting and tests |
131+
| `npm run lint` | Run linting only |
132+
| `npm run cypress` | Open Cypress for E2E tests |
133+
134+
### Environment Configuration
135+
136+
Copy `.env.example` to `.env` and adjust as needed. Key variables:
137+
138+
- `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD`, `DB_NAME` - Database connection
139+
- `ADMIN_USERNAME`, `ADMIN_PASSWORD` - Admin account credentials (also used by Cypress)
140+
- `ENCRYPTION_KEY`, `SESSION_KEY` - Security keys (generate unique values for production)
141+
142+
### Resetting the Database
143+
144+
To reset the database with fresh seed data:
145+
146+
```bash
147+
npm run seed:reset
148+
```
149+
150+
### Running Tests
151+
152+
```bash
153+
# Run all tests
154+
npm run test
155+
156+
# Run Cypress E2E tests
157+
npm run cypress
158+
```
159+
69160
## Contributing
161+
70162
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.
71163

72164
## Help / Bug / Feature Request
165+
73166
If you have found a bug please [open an issue](https://github.com/BanManagement/BanManager-WebUI/issues/new) with as much detail as possible, including relevant logs and screenshots where applicable
74167

75168
Have an idea for a new feature? Feel free to [open an issue](https://github.com/BanManagement/BanManager-WebUI/issues/new) or [join us on Discord](https://discord.gg/59bsgZB) to chat
76169

77170
## License
171+
78172
Free to use under the [MIT](LICENSE)
79173

80174
## Screenshots
175+
81176
Click to view
82177

83178
### Home
179+
84180
[![Home](https://github.com/BanManagement/BanManager-WebUI/blob/assets/welcome.png?raw=true)](welcome.png)
85181

86182
### Player
183+
87184
[![Player](https://github.com/BanManagement/BanManager-WebUI/blob/assets/player.png?raw=true)](player.png)
88185

89186
### Dashboard
187+
90188
[![Dashboard](https://github.com/BanManagement/BanManager-WebUI/blob/assets/dashboard.png?raw=true)](dashboard.png)
91189

92190
### Appeal
191+
93192
[![Appeal](https://github.com/BanManagement/BanManager-WebUI/blob/assets/appeal.png?raw=true)](appeal.png)
94193

95194
### Report
195+
96196
[![Report](https://github.com/BanManagement/BanManager-WebUI/blob/assets/report.png?raw=true)](report.png)

docker-compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
services:
2+
mysql:
3+
image: mysql:8.0
4+
container_name: banmanager-mysql
5+
restart: unless-stopped
6+
environment:
7+
MYSQL_ROOT_PASSWORD: password
8+
MYSQL_DATABASE: bm_local_dev
9+
ports:
10+
- "3306:3306"
11+
volumes:
12+
- mysql_data:/var/lib/mysql
13+
healthcheck:
14+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-ppassword"]
15+
interval: 5s
16+
timeout: 5s
17+
retries: 10
18+
start_period: 30s
19+
command:
20+
- --character-set-server=utf8mb4
21+
- --collation-server=utf8mb4_unicode_ci
22+
- --default-authentication-plugin=mysql_native_password
23+
24+
volumes:
25+
mysql_data:

0 commit comments

Comments
 (0)