Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Mattie112
Copy link

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.

@Mattie112 Mattie112 mentioned this pull request Jan 26, 2022
@AGuyNamedJens
Copy link
Owner

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?

@Mattie112
Copy link
Author

Yes you are right, no need for that, removed it! (But left the nice check in place)

@AGuyNamedJens
Copy link
Owner

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");
Copy link
Owner

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?

Copy link
Author

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.

Copy link
Owner

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?

Copy link
Author

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)

Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants