### Run app in development mode Source: https://github.com/147api/new-api-dev/blob/main/electron/README.md Starts the Electron app in development mode. This starts the Go backend on port 3000, opens an Electron window with DevTools, creates a system tray icon, and stores the database in ../data/new-api.db. ```bash npm start ``` -------------------------------- ### Install Electron dependencies Source: https://github.com/147api/new-api-dev/blob/main/electron/README.md Installs the npm dependencies for the Electron app. Run from the electron directory. ```bash cd electron npm install ``` -------------------------------- ### Deploy new-api with Docker Compose Source: https://github.com/147api/new-api-dev/blob/main/README.md Recommended way to deploy new-api. Clone the repository, edit the docker-compose.yml configuration, then start the service with docker-compose up -d. ```bash # Clone the project git clone https://github.com/QuantumNous/new-api.git cd new-api # Edit docker-compose.yml configuration nano docker-compose.yml # Start the service docker-compose up -d ``` -------------------------------- ### Deploy with Docker Compose Source: https://github.com/147api/new-api-dev/blob/main/README.md Deploy New-API using Docker Compose. Clone the repository, edit the docker-compose.yml configuration, then start the service with docker-compose up -d. ```bash # Clone the project git clone https://github.com/QuantumNous/new-api.git cd new-api # Edit configuration nano docker-compose.yml # Start service docker-compose up -d ``` -------------------------------- ### Copy pre-built Go binary Source: https://github.com/147api/new-api-dev/blob/main/electron/README.md Copies a pre-built Go binary (e.g., new-api-macos) to the expected location. This is required if you do not have Go installed. ```bash cp ../new-api-macos ../new-api ``` -------------------------------- ### Build for production Source: https://github.com/147api/new-api-dev/blob/main/electron/README.md Commands to build the app for production. First ensure the Go binary exists in the parent directory, then run the build for the current platform or specific platforms. ```bash # Ensure Go binary exists in parent directory ls ../new-api # Should exist # Build for current platform npm run build # Platform-specific builds npm run build:mac # Creates .dmg and .zip npm run build:win # Creates .exe installer npm run build:linux # Creates .AppImage and .deb ``` -------------------------------- ### Deploy new-api with Docker Commands Source: https://github.com/147api/new-api-dev/blob/main/README.md Alternative deployment using Docker commands. Pull the latest image and run the container with SQLite (default) or MySQL by setting the SQL_DSN environment variable. The -v ./data:/data flag persists data in the current directory's data folder. ```bash # Pull the latest image docker pull calciumion/new-api:latest # Using SQLite (default) docker run --name new-api -d --restart always \ -p 3000:3000 \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest # Using MySQL docker run --name new-api -d --restart always \ -p 3000:3000 \ -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` -------------------------------- ### Run with Docker using SQLite Source: https://github.com/147api/new-api-dev/blob/main/README.md Run New-API with Docker using SQLite as the local database. Mount the ./data directory to /data for persistent storage. The container runs on port 3000 with restart policy always. ```bash docker run --name new-api -d --restart always \ -p 3000:3000 \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` -------------------------------- ### Run with Docker using MySQL Source: https://github.com/147api/new-api-dev/blob/main/README.md Run New-API with Docker using MySQL as the remote database. Set the SQL_DSN environment variable to the MySQL connection string. The container runs on port 3000 with restart policy always. ```bash docker run --name new-api -d --restart always \ -p 3000:3000 \ -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` -------------------------------- ### Change default port in main.js Source: https://github.com/147api/new-api-dev/blob/main/electron/README.md Shows how to change the default port (3000) by editing the PORT constant in main.js. ```javascript const PORT = 3000; // Change to desired port ```