Skip to content

Latest commit

 

History

History
74 lines (52 loc) · 1.84 KB

README.md

File metadata and controls

74 lines (52 loc) · 1.84 KB

Moon-Trek server

Moon-Trek server, a express backend

Configuration

You need to configure this application before running it.

  1. Create a dev.config.json under folder server/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 use production.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.
  2. here is an example
{
    "log_file": "/path/to/moontrek-server.log",
    "log_level": "debug",
    "dataServer": {
        "ip": "data server ip",
        "port": "data server port"
    }
}

Deploy with Docker (Recommand)

To deploy server with Docker.

  1. In directory server, build docker image with:
docker build -t moontrek-server .
  1. 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:

  1. We use argument -p here to export container port 5173 to host port 5173.
  2. We use argument -v to mount configuration folder server/config to container /src/config
  3. We use argument -v to mount data folder server/data to container /src/data. This folder holds data generated by server application (e.g. log files)

Deploy manually

  1. Install dependencies
npm install
  1. Compile and Hot-Reload for Development
npm run dev

You can modify server/server.js to change the server port

  1. Run for Production
node server.js