-
Notifications
You must be signed in to change notification settings - Fork 1
Install
- Prerequisites
- Node v18.15.0+
- npm 9.5.0+
- Mysql server
- git
- Clone the repo
$ cd ~/vswork
$ git clone git@github.com:huoyijie/infinity.git
- Install deps
$ cd infinity/backend
$ npm i
- Add .env file
$ cat <<EOF > .env
PORT=5000
DATABASE_URL="mysql://your_mysql_username:your_mysql_password@localhost:3306/infinity"
EOF
Don't forget to change your_mysql_username
and your_mysql_password
.
- Create database
infinity
$ mysql -u your_mysql_username -p
# Input your_mysql_password
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4986
Server version: 8.0.32-0ubuntu0.22.04.2 (Ubuntu)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# create database `infinity`
mysql> CREATE DATABASE `infinity` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
Query OK, 1 row affected (0.53 sec)
# exit
mysql> exit
- Creating the database schemas
$ npx prisma db push
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": MySQL database "infinity" at "localhost:3306"
🚀 Your database is now in sync with your Prisma schema. Done in 545ms
✔ Generated Prisma Client (5.1.1 | library) to ./node_modules/@prisma/client in 72ms
Query the database:
mysql> use infinity
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+--------------------+
| Tables_in_infinity |
+--------------------+
| Drawing |
+--------------------+
1 row in set (0.00 sec)
- Run server
$ npm start
- HOST (default: localhost)
Backend server listen addr.
- PORT (default: 5000)
Backend server listen port.
- BASE_PATH (default: /)
You shoud deploy backend server behind nginx with ssl/htt2 enabled.
Such as wss://huoyijie.cn:1024/infinity/socket.io
, bashPath is /infinity
.
- ALLOW_ORIGIN (default: *)
You should config like this ALLOW_ORIGIN=https://huoyijie.github.io
for security
- Prerequisites
- Node 18.15.0+
- npm 9.5.0+
- git
$ cd ~/vswork
$ git clone git@github.com:huoyijie/infinity.git
- Install deps
$ cd infinity/frontend
$ npm i
- Add .env file
$ cat <<EOF > .env
NEXT_PUBLIC_SOCKETIO_URL=ws://your_bankend_server_domain_or_ip:your_bankend_server_port
EOF
Don't forget to change your_bankend_server_domain_or_ip
(localhost) and your_bankend_server_port
(5000).
If you run the bankend server behind reverse server (such as Nginx) and use tls, change ws
to wss
.
- Run server
$ npm run dev
See .github/workflows/nextjs.yml
- NEXT_PUBLIC_SOCKETIO_URL=ws://localhost:5000
If your backend server is deployed behind nginx with ssl/http2 enabled, you shoud forward the websocket upgrade request from nginx to backend server, and you shoud config NEXT_PUBLIC_SOCKETIO_URL=wss://your_domain
.
- NEXT_PUBLIC_BASE_PATH=/
If your backend server configed with BASH_PATH=/infinity
, then you shoud config NEXT_PUBLIC_BASE_PATH=/infinity
too.