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

Docker support #55

Closed
wants to merge 1 commit into from
Closed

Conversation

josecelano
Copy link
Member

I've added docker configuration. In order to run it with docker you need to execute:

./bin/docker/build.sh && ./bin/docker/run.sh

Since I do not know Rust I have followed instructions from this article https://www.lpalmieri.com/posts/fast-rust-docker-builds/ by @LukeMathWalker

I have moved the SQLite data file (data.db) to a new directory (storage) because I thought I could not mount two files in the same directory but it's possible so I can revert the change. If we want to keep the data.db file in the root dir we can run the docker container with:

docker run --rm -it \
    -p 6969:6969 -p 1212:1212 \
    --mount type=bind,source="$(pwd)/data.db",target=/app/data.db \
    --mount type=bind,source="$(pwd)/config.toml",target=/app/config.toml \
    torrust-tracker

I would keep the storage folder even if we only have one file now. I think it is a good thing to make it more explicit.

Besides, I would keep in the config.toml file only the variables that are read-only. I mean, the variables you need to pass to the program only when you start it. For example, I would move the "Site Name" to the storage dir in a new file or even the database.

Other apps have these three different types of data:

  • User-generated data at runtime (right now the site name belongs to this category).
  • Configuration files that are read-only and included in the git repo.
  • Environment variables. Values that depend on the environment. You usually use a .env file generated when you deploy/install de environment or env variables. The .env file is usually the option for development environments.

Configuration files can contain default values and can also get values from env vars if they are provided when the app starts.

What I would do:

  1. Remove values from the config file that can be updated at runtime without restarting the app. We can move them to a new file or the database (eg Site Name).
  2. Add the config.toml to the Git repo.
  3. Allow using env vars in the config file.

We do not need to do those changes in order to merge this PR. And I can also ever the new storage folder. I do not think that's a breaking change because the config.toml file already allows you to change the path. People using docker would use the new default location (it can be changed anyway but you have to create your own docker "run" command).

@josecelano josecelano requested a review from mickvandijke July 6, 2022 15:44
@josecelano josecelano linked an issue Jul 6, 2022 that may be closed by this pull request
@josecelano josecelano mentioned this pull request Dec 6, 2022
17 tasks
@josecelano
Copy link
Member Author

I've created a new PR

@josecelano josecelano closed this Dec 6, 2022
@josecelano josecelano deleted the issue-11-docker-support branch January 16, 2023 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Docker Support
1 participant