Skip to content

Instantly share code, notes, and snippets.

@ymjing
Created May 7, 2022 02:08
Show Gist options
  • Save ymjing/1302bee87298480cab1bd712431d6247 to your computer and use it in GitHub Desktop.
Save ymjing/1302bee87298480cab1bd712431d6247 to your computer and use it in GitHub Desktop.
A minimal docker file for running Grasscutter

Overview

This gist provides a minimal docker-compose.yml for setting up a Grasscutter instance on x86_64 with Docker Compose.

Quick start:

$ mkdir grasscutter && cd grasscutter
$ git clone https://github.com/Koko-boya/Grasscutter_Resources.git
$ nano sample_config.json && mv sample_config.json config.json
$ docker compose up -d

mitmproxy is not included.

Notes

If deployed on a public server, modify the PUBLIC_IP in config.json to match your configuration.

The Grasscutter Container ID can be acquired with docker ps; attach to the console with docker attach SOME_CONTAINER_ID.

Stop the service with docker compose down; restart with docker compose restart.

The Dockerfile provided in this gist simply builds a Grasscutter jar from the development branch. The image is NOT regularly updated.

LICENSE

WTFPL

version: '3'
services:
grasscuter:
image: kevinis/grasscutter
restart: unless-stopped
depends_on:
- mongodb
ports:
- "22102:22102/udp"
- "443:443/tcp"
volumes:
- ./Grasscutter_Resources/Resources:/resources
- ./config.json:/config.json:ro
stdin_open: true
tty: true
mongodb:
image: mongo
restart: unless-stopped
volumes:
- ./data_db:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: genshin
MONGO_INITDB_ROOT_PASSWORD: paimon
FROM azul/zulu-openjdk:17 AS builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends git libprotobuf-dev \
&& git clone -b development --depth 1 https://github.com/Grasscutters/Grasscutter /work
WORKDIR /work
RUN export GRADLE_OPTS="-Dfile.encoding=utf-8" \
&& git submodule update --init \
&& chmod +x gradlew \
&& ./gradlew jar \
&& mkdir /rootfs \
&& cp -rf grasscutter*.jar /rootfs/grasscutter.jar \
&& cp -rf keys /rootfs \
&& cp -rf keystore.p12 /rootfs \
&& cp -rf data /rootfs
FROM azul/zulu-openjdk-alpine:17-jre
COPY --from=builder /rootfs /
EXPOSE 443/tcp 22102/udp
VOLUME [ "/resources", "/config.json" ]
ENTRYPOINT ["java", "-jar", "/grasscutter.jar"]
{
"DatabaseUrl": "mongodb://genshin:paimon@mongodb:27017",
"DatabaseCollection": "grasscutter",
"RESOURCE_FOLDER": "./resources/",
"DATA_FOLDER": "./data/",
"PACKETS_FOLDER": "./packets/",
"DUMPS_FOLDER": "./dumps/",
"KEY_FOLDER": "./keys/",
"SCRIPTS_FOLDER": "./resources/Scripts/",
"PLUGINS_FOLDER": "./plugins/",
"LANGUAGE_FOLDER": "./languages/",
"DebugMode": "NONE",
"RunMode": "HYBRID",
"GameServer": {
"Name": "Test",
"Ip": "0.0.0.0",
"PublicIp": "127.0.0.1",
"Port": 22102,
"PublicPort": 0,
"DispatchServerDatabaseUrl": "mongodb://genshin:paimon@mongodb:27017",
"DispatchServerDatabaseCollection": "grasscutter",
"InventoryLimitWeapon": 2000,
"InventoryLimitRelic": 2000,
"InventoryLimitMaterial": 2000,
"InventoryLimitFurniture": 2000,
"InventoryLimitAll": 30000,
"MaxAvatarsInTeam": 4,
"MaxAvatarsInTeamMultiplayer": 4,
"MaxEntityLimit": 1000,
"WatchGacha": false,
"ServerNickname": "Ganyu",
"ServerAvatarId": 10000037,
"WelcomeEmotes": [
2007,
1002,
4010
],
"WelcomeMotd": "Welcome to Grasscutter emu",
"WelcomeMailTitle": "Welcome to Grasscutter!",
"WelcomeMailSender": "Lawnmower",
"WelcomeMailContent": "Hi there!\r\nFirst of all, welcome to Grasscutter. If you have any issues, please let us know so that Lawnmower can help you! \r\n\r\nCheck out our:\r\n\u003ctype\u003d\"browser\" text\u003d\"Discord\" href\u003d\"https://discord.gg/T5vZU6UyeG\"/\u003e \u003ctype\u003d\"browser\" text\u003d\"GitHub\" href\u003d\"https://github.com/Melledy/Grasscutter\"/\u003e",
"WelcomeMailItems": [
{
"itemId": 13509,
"itemCount": 1,
"itemLevel": 1
},
{
"itemId": 201,
"itemCount": 10000,
"itemLevel": 1
}
],
"EnableOfficialShop": true,
"Game": {
"ADVENTURE_EXP_RATE": 1.0,
"MORA_RATE": 1.0,
"DOMAIN_DROP_RATE": 1.0
}
},
"DispatchServer": {
"Ip": "0.0.0.0",
"PublicIp": "127.0.0.1",
"Port": 443,
"PublicPort": 0,
"KeystorePath": "./keystore.p12",
"KeystorePassword": "123456",
"UseSSL": true,
"FrontHTTPS": true,
"AutomaticallyCreateAccounts": false,
"defaultPermissions": [
""
],
"GameServers": []
},
"LocaleLanguage": "en_US",
"OpenStamina": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment