-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements and instructions on how to build Docker container #7
base: master
Are you sure you want to change the base?
Conversation
Where is the new config function useful for? I don't actually understand the reason behind it, can't we just bind the config and make it sync with the docker container? |
Yes you are right, no need for that, removed it! (But left the nice check in place) |
Alright cool |
// Check if we have a local config file or a docker volume | ||
try { | ||
if (fs.existsSync("./config/config.json")) { | ||
config = require("./config/config.json"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why you decided to make config a folder, isn't it fine to keep it in the root directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I can explain that:
Docker volumes are intended to bind to a folder (and not a single file). While it is possible to bind a single file this can be confusing. For example if you bind /host/a.txt
to /container/a.txt
and the file on the host does NOT exists then Docker wil l create a FOLDER called a.txt
. Then it tries to start and you can get strange error messages. See for example the problems @ https://stackoverflow.com/questions/42248198/how-to-mount-a-single-file-in-a-volume
But technically it is possible it's just not best practice. I also thought about mounting the entire Factorio directory but that gives a bit more access then I'd like so I kept that to a single file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, alright.. My own Dockerfile for my bot just binds the entire bot's folder to the docker volume.. Any reasons to not use a /src
folder and bind the files to it as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that works for development yes. But someone wanting to run the bot does not have (or needs) the source files. He just downloads/uses a pre-built docker image and only binds the config. (Or use env vars)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I've never ran any docker images without using source files though. But having an entire config
folder when the rest is in the root directory sounds weird to me. Guess it's time to move the files to /src
and make a /src/config
folder for it
Added instructions on how to build the Docker container and added support for both a local config file and a config file from a docker volume.