To run Fiora, you need Node.js (v10 LTS version, eg 10.6.3) development environment and MongoDB database
- Install Node.js
- Official website https://nodejs.org/en/download/
- It is recommended to use nvm to install Node.js
- Install nvm https://github.com/nvm-sh/nvm#install--update-script
- Install Node.js via nvm https://github.com/nvm-sh/nvm#usage
- Install MongoDB
- Official website https://docs.mongodb.com/manual/installation/#install-mongodb
Recommended for running on Linux and MacOS systems
- Clone the project to the local
git clone https://github.com/yinxin630/fiora.git -b master
- Installation project dependencies, strongly recommended to use yarn installation, execute
yarn
. You can also usenpm
to install and executenpm i
- Modify the configuration as needed. It is also possible to use the default configuration. For details, please refer to Project Configuration
- Start the server
npm run server
- Start the client
npm run client
- Use a browser to open
http://localhost:8080
Modify the code will automatically restart the server and refresh the client
- Reference Running on the local Step 1
- Reference Running on the local Step 2
- Reference Running on the local Step 3
- Build a static client
npm run build
- Move the client build artifact to the server static resource directory
npm run move-dist
- Start the server
npm start
- Use a browser to open
http://[server ip]:[fiora port number]
When deploying on the server, it is strongly recommended to configure the 七牛 CDN. For details, please refer to 七牛 CDN Configuration
First install docker https://docs.docker.com/install/
- Pull the mongo image
docker pull mongo
- Pull the fiora image
docker pull suisuijiang/fiora
- Create a virtual network
docker network create fiora-network
- Start the database
docker run --name fioradb -p 27017:27017 --network fiora-network mongo
- Start fiora
docker run --name fiora -p 9200:9200 --network fiora-network -e Database=mongodb://fioradb:27017/fiora suisuijiang/fiora
- Clone the project to the local
git clone https://github.com/yinxin630/fiora.git -b master
- Build the image
docker-compose build --no-cache --force-rm
- Run it
docker-compose up
You can edit the configuration file directly and modify the corresponding configuration values.
Because the contents of the file have been modified, subsequent new code may cause conflicts
- Direct runtime
./node_modules/.bin/ts-node server/main.ts --xxx "yyy"
- Run through npm
npm start -- --xxx "yyy"
- Run through pm2
pm2 start npm -- start --xxx "yyy"
xxx
is the configuration name, yyy
is the value to be configured, and the configuration name can be viewed in the configuration file.
Recommended to modify the configuration using this method
- Linux and MaxOS systems
export XXX="yyy" && ./node_modules/.bin/ts-node server/main.ts
- Windows system
SET "xxx=yyy" && ./node_modules/.bin/ts-node server/main.ts
Other CDN operators did not support, welcome PR
- Register the 七牛 account and create a storage space https://developer.qiniu.com/kodo/manual/1233/console-quickstart#step1
- Get the space name and extranet url
- Get the key, mouse to the top right corner of the avatar, click "Key Management", get AccessKey and SecretKey
- Download and install the 七牛 Command Line tool https://developer.qiniu.com/kodo/tools/1302/qshell, rename it to
qshell
and add it to the environment variable. - Log in to the 七牛
qshell account AccessKey SecretKey name
- Create a
.qiniurc
configuration file in the fiora directory, as follows:
{
"src_dir" : "./dist",
"bucket" : "七牛 bucket name",
"overwrite": true,
"rescan_local": true
}
- Build the client, pass the 七牛 public url as publicPath `npm run build -- --publicPath "http://example address/fiora/"
- Upload the build structure to the CDN
qshell qupload .qiniurc
- Update the client index.html
npm run move-dist
, if it is a local build upload CDN, please manually update index.html to the server under the fiora public directory
- Repeat 4~6 steps after each update of the client code*
- Modify the configuration items in
config/server.ts
:qiniuAccessKey
/qiniuSecretKey
/qiniuBucket
/qiniuUrlPrefix
Note that the qiniuUrlPrefix configuration value should be slashed/terminated, for example:http://example address/fiora/
- Modify the configuration item in
config/webpack.ts
:build.assetsPublicPath
, which is the same as thepublicPath
value when building the client. - Restart the server
- Install pm2
yarn global add pm2
on the server and client respectively. - Create a directory to store the project on the server, for example
mkdir -p ~/fiora
- Pull the project to the source folder under the directory
git clone -b master [email protected]:yinxin630/fiora.git ~/fiora/source
- Create the pm2 ecosystem configuration file
cp ecosystem.config.js.example ecosystem.config.js
- Modify the contents of the configuration file
- Deploy or update
./deploy.sh
for the first time.
For details, please refer to http://pm2.keymetrics.io/docs/usage/deployment/
https://www.moerats.com/archives/978/
- Get the user id, note that it is not username, is the _id in the mongoDB database
- Modify the
administrator
field inconfig/server.ts
to change the id obtained in the previous step. - Restart the server
- Modify the
defaultGroupName
field inconfig/server.ts
- Restart the server
Please modify the configuration of the comment item
Example config
server {
listen 80;
# Change to your domain name
server_name fiora.suisuijiang.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://localhost:9200;
}
}
HTTPS + HTTP 2.0 config
server {
listen 80;
# Change to your domain name
server_name fiora.suisuijiang.com;
return 301 https://fiora.suisuijiang.com$request_uri;
}
server {
listen 443 ssl http2;
# Change to your domain name
server_name fiora.suisuijiang.com;
ssl on;
# Modify to your ssl certificate location
ssl_certificate ./ssl/fiora.suisuijiang.com.crt;
ssl_certificate_key ./ssl/fiora.suisuijiang.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://localhost:9200;
}
}