Installation and Deployment
This page provides detailed instructions for installing and deploying the Kotatsu Sync Server. The server requires a MySQL database for storing user data, favorites, and reading history. For detailed configuration options after installation, see Configuration Options.
Prerequisites
Before installing the Kotatsu Sync Server, ensure you have:
- MySQL database (version 5.7 or higher)
- For Docker deployment:
- Docker installed (version 19.03 or higher)
- For Systemd deployment:
- JDK 17 or higher
- Gradle 8.3 or higher
Database Setup
The first step in deploying the sync server is setting up the MySQL database schema:
- Download the database.sql script from the repository
- Run the following command to set up the schema:
Replace hostname, user, and database with your MySQL server hostname, username, and database name.
Deployment Methods
Docker Deployment
Docker deployment is the recommended method for deploying the Kotatsu Sync Server. The Dockerfile uses a multi-stage build process:
-
Build the Docker image:
-
Run the Docker container:
docker run -d -p 8081:8080 \ -e DATABASE_HOST=your_mysql_db_host \ -e DATABASE_USER=your_mysql_db_user \ -e DATABASE_PASSWORD=your_mysql_db_password \ -e DATABASE_NAME=your_mysql_db_name \ -e DATABASE_PORT=your_mysql_db_port \ -e JWT_SECRET=your_secret \ -e ALLOW_NEW_REGISTER=true \ --restart always \ --name kotatsu-sync kotatsuapp/syncserver
After initial setup, if you want to prevent others from using your server instance, register your accounts first, then set ALLOW_NEW_REGISTER to false and restart the server.
Docker Compose Deployment
For users who want to deploy both the server and database together, Docker Compose provides a convenient solution:
-
Use the provided docker-compose.yaml file or create one with the following content:
services: db: image: mysql:8.4 environment: MYSQL_USER: your_user MYSQL_PASSWORD: your_password MYSQL_DATABASE: kotatsu_db MYSQL_ALLOW_EMPTY_PASSWORD: true volumes: - /var/lib/mysql:/var/lib/mysql ports: - "3306:3306" server: container_name: kotatsu-sync build: ./ depends_on: - db links: - db ports: - "8081:8080" environment: DATABASE_HOST: db DATABASE_USER: your_user DATABASE_PASSWORD: your_password DATABASE_NAME: kotatsu_db DATABASE_PORT: 3306 JWT_SECRET: your_secret ALLOW_NEW_REGISTER: true restart: always -
Run the following command in the directory containing docker-compose.yaml:
Systemd Deployment
For users who prefer running the server directly on their Linux system:
-
Clone the repository and build the server:
-
Edit the
kotatsu-sync.servicefile, replacing the placeholder values with your actual configuration -
Deploy the service:
cp kotatsu-sync.service /etc/systemd/system
systemctl daemon-reload
systemctl enable kotatsu-sync
systemctl start kotatsu-sync
Configuration Options
The server supports the following configuration options, which can be set as environment variables:
| Variable | Desciption | Default | Required |
|---|---|---|---|
| PORT | Server listening port | 8080 | |
| JWT_SECRET | Secret for signing JWT tokens | - | |
| DATABASE_NAME | MySQL database name | kotatsu_db | |
| DATABASE_HOST | MySQL server hostname | localhost | |
| DATABASE_PORT | MySQL server port | 3306 | |
| DATABASE_USER | MySQL username | - | |
| DATABASE_PASSWORD | MySQL password | - | |
| ALLOW_NEW_REGISTER | Allow new user registrations | true |
These options can be set differently depending on your deployment method:
- Docker: Use
-eflags - Docker Compose: Set in the
environmentsection - Systemd: Define in the Environment directives of the service file
Post-Installation Steps
After deployment, complete these steps:
- Verify the server is running by accessing the root endpoint (e.g.,
http://your-server:8081/) - Configure the Kotatsu app to use your server:
- Go to
Options -> Settings -> Services -> Synchronization settings -> Server address - Enter your server's URL
- Go to
- Register an account through the app
- Enable synchronization in the app and select which data to sync (favorites, history, or both)
Troubleshooting
Common issues and solutions:
- Server doesn't start: Verify all required environment variables are set correctly
- Database connection failures: Ensure your MySQL server is running and accessible
- Authentication issues: Check that
JWT_SECRETis properly configured - Registration fails: Confirm
ALLOW_NEW_REGISTERis set to true
For further assistance, contact the Kotatsu App community in the Telegram group or create an issue on GitHub.