This directory contains the necessary files to build and run the DNF Server in a Docker container.
- All-in-One: Provides unified GM management services, including GM basic functions (game accounts, roles, mail management, etc.) and game gateways (login, registration), etc.
- Multi-Arch Support: Supports both
linux/amd64(x86_64) andlinux/arm64(Apple Silicon/Raspberry Pi). - Auto-Initialization:
- Database: Automatically initializes the database schema on the first run using the provided connection settings.
- Keys: Automatically generates RSA keys (
private.key,publickey.pem) if they are missing.
- Data Persistence: Keys and other data are persisted via Docker volumes.
- Docker installed on your system.
- Docker can access the game database (MySQL 5).
Replace the environment variables with your actual database configuration.
docker run -d \
--name dnf-server \
-p 80:80 \
-v $(pwd)/data:/app/data \
-e SPRING_DATASOURCE_URL="jdbc:mysql://YOUR_DB_IP:3306/dnf_service?useUnicode=true&characterEncoding=utf8&autoReconnect=true" \
-e SPRING_DATASOURCE_USERNAME="root" \
-e SPRING_DATASOURCE_PASSWORD="your_password" \
guoshengkai/dnf-server:latestNote: The container listens on port 80 by default.
- Web Interface: Open
http://localhostin your browser. - Logs: Check logs with
docker logs -f dnf-server.
| Variable | Description | Default |
|---|---|---|
SPRING_DATASOURCE_URL |
JDBC Connection URL. The image will parse this to determine the DB host, port, and database name for initialization. | Required |
SPRING_DATASOURCE_USERNAME |
Database username. | Required |
SPRING_DATASOURCE_PASSWORD |
Database password. | Required |
NGINX_PORT |
The port Nginx listens on inside the container. | 80 |
SERVER_PORT |
The port the Java backend listens on (internal). | 8080 |
TZ |
Timezone setting. | Asia/Shanghai |
| path | Description |
|---|---|
/app/data |
Stores generated RSA keys (private.key, publickey.pem) and the database initialization marker. Map this to a host directory to persist keys across restarts. |
Warning: Ensure the mapped
datadirectory has appropriate permissions for the container to read/write.
- The public and private keys in the
datadirectory must match.- The public key in the game's
gamedirectory must match the public key in thedatadirectory.- If you change the keys, you need to restart the game service.
If you only need to run the image on your current machine:
docker build -t dnf-server .To build for both Linux x64 servers and Mac M1/M2/M3 (ARM64), use the provided script. Note: You must be logged in to a Docker Registry (e.g., Docker Hub) as multi-arch builds require pushing.
-
Login to Docker Hub:
docker login
-
Run the build script:
./build-multi-arch.sh
The script will prompt you for your Docker Hub repository name (e.g.,
yourusername/dnf-server) and then build & push the images automatically.
The container includes a mechanism to automatically initialize the database:
- On startup, it checks for a marker file in
/app/data. - If the marker is missing (first run), it parses the
SPRING_DATASOURCE_URL. - It extracts the database name (e.g.,
dnf_service) and creates it if it doesn't exist. - It executes the included SQL schema to set up tables.
- Success: It creates the marker file so subsequent restarts skip this step.
Warning: Ensure your database user has permissions to CREATE DATABASE and CREATE TABLE.
The application requires RSA keys for operation.
- If
private.keyandpublickey.pemare not found in/app/data/, the container automatically generates a 2048-bit PKCS#8 key pair. - If you have existing keys, simply place them in your mapped
datavolume directory before starting the container.