Grasscutter
Grasscutter copied to clipboard
Added docker support
Description
- Added the multi-staged Dockerfile
- Added the docker-compose.yml file
- It also includes a MongoDB service
- Added the entrypoint for the Docker image
Issues fixed by this PR
Closes #2038 Closes #2250 Closes #2018
Type of changes
- [ ] Bug fix
- [ ] New feature
- [X] Enhancement
- [ ] Documentation
Checklist:
- [X] My code follows the style guidelines of this project
- [X] My pull request is unique and no other pull requests have been opened for these changes
- [X] I have read the Contributing note and Code of conduct
- [X] I am responsible for any copyright issues with my code if it occurs in the future.
it would be a bit of a hassle to maintain
I think the same about the configuration file - it would be far better if GrassCutter would use environment variables directly - so we could get rid of the workaround (even without having all the reflection stuff) :)
My current approach was:
- Build the server from scratch
- Running the container via docker-compose (luckily the MongoDB adapter has a timeout of 30 seconds)
-
cat
the config to the host system
Sadly GrassCutter doesn't provide a default configuration file in the source code :/
is there a specific reason you can't generate a config using Java and reflection
For me particular I've never worked with gradle - so we would need another entrypoint where also GSON is loaded - so we could easily generate the config.
But as said above - it would be far better if GrassCutter would use environment variables.
additionally, it would be nice to have an environment variable to change where the image gets its resources.
You mean the GIT repository? That would be doable :)
It also seems that there is another problem with the configuration file:
In the code it states that it is at version 13 - but the server only generates a config of version 4...
Also if we would refactor GC to use environment variables - this would be a breaking change :)
@KingRainbow44 Could you please verify the latest changes if they work for you? :)
I've refactored the ConfigContainer to use environment variables instead of a file configuration :)
The last TODO is only to refactor the Dockerfile to use an "ARG" for the resources URL - but thats a no-brainer :)
The server is starting correctly in Docker (even with the MongoDB connection) - but I cant test it with the client (need to download it first with this slow connection here)
how does this read from the traditional 'config.json' file?
how does this read from the traditional 'config.json' file?
It does not anymore - everything was converted to environment variables.
Due to the lack of Docker supporting only mounting specific files (AFAIK) you cannot even mount the config into the container under a specific path.
in it's current state, i don't think this pr will be going through. dropping complete support for config.json
would be a disaster for the many users which already use grasscutter.
in it's current state, i don't think this pr will be going through. dropping complete support for
config.json
would be a disaster for the many users which already use grasscutter.
What about reading out the config.json file (like before) and generating a script (.bat / .sh) based on the old configuration and then deleting the file (so the generated script wont be overwritten)?
not everyone uses a script to start grasscutter, instead why can't you read from a config.json
if it exists and set environment variables like that?
not everyone uses a script to start grasscutter, instead why can't you read from a
config.json
if it exists and set environment variables like that?
Because it would bloat up the Docker image - you would need dependencies like jq and an extensive bash script which are only used once in the whole lifecycle.
And we all know that data transformations (which would be needed for nested config keys) isn't that comfortable to maintain.