Moon-Trek server, a express backend
You need to configure this application before running it.
- Create a
dev.config.json
under folderserver/config/
.- You can use
server/config/dev.config.json.template
as your start - We separate config file for development & production environment by their name. We use
dev.config.json
in dev environment, and we useproduction.config.json
in production environment. - You are in production environment when environment variable
NODE_ENV
exists and set to string"production"
. - If you want to deploy server with Docker or Docker Compose, you should use
server/config/production.config.json.docker
as your start.
- You can use
- here is an example
{
"log_file": "/path/to/moontrek-server.log",
"log_level": "debug",
"dataServer": {
"ip": "data server ip",
"port": "data server port"
}
}
To deploy server with Docker.
- In directory
server
, build docker image with:
docker build -t moontrek-server .
- Run docker container with:
docker run -d --name moontrek-server \
-p 8888:8888 \
-v "$(pwd)/config:/src/config" \
-v "$(pwd)/data:/src/data" \
moontrek-server
Note:
- We use argument
-p
here to export container port 5173 to host port 5173.- We use argument
-v
to mount configuration folderserver/config
to container/src/config
- We use argument
-v
to mount data folderserver/data
to container/src/data
. This folder holds data generated by server application (e.g. log files)
- Install dependencies
npm install
- Compile and Hot-Reload for Development
npm run dev
You can modify
server/server.js
to change the server port
- Run for Production
node server.js