Skip to content

Conversation

josecelano
Copy link
Member

@josecelano josecelano commented Dec 16, 2022

Stacked on/Depends on: #128

This is a reorganization of PR-123

  • I've reorganised the commits
  • I've implemented Solution 1 discussed here. The application can get the configuration from the config.toml file or from an env var TORRUST_TRACKER_CONFIG with the same content as the config.toml file. I think it's the minimum change to deploy the application using docker easily.

The idea is the same as the solution implemented by @Power2All here. But I'm using only one env var. This way, we do not need to change the code if the configuration changes. On the other hand, we are discussing a new implementation for the settings, and I did not want to implement things that will need to be changed afterwards. I'm also a fan of small steps :-).

Testing

I have deployed the application to the Digital Ocean App Platform:

https://lobster-app-dc6o9.ondigitalocean.app/api/stats?token=MyAccessToken

with this PR branch docker image.

If you want to test the feature of getting the configuration from an env var locally (without docker):

TORRUST_TRACKER_CONFIG=`cat config.toml` cargo run

With docker, you only need to follow the instructions in the README:

Notes

Digital Ocean App Platform only allows you to expose one port (0.0.0.0:8080). I've deployed it exposing only the API with this configuration:

log_level = "info"
mode = "public"
db_driver = "Sqlite3"
db_path = "data.db"
announce_interval = 120
min_announce_interval = 120
max_peer_timeout = 900
on_reverse_proxy = false
external_ip = "0.0.0.0"
tracker_usage_statistics = true
persistent_torrent_completed_stat = false
inactive_peer_cleanup_interval = 600
remove_peerless_torrents = true

[[udp_trackers]]
enabled = false
bind_address = "0.0.0.0:6969"

[[http_trackers]]
enabled = false
bind_address = "0.0.0.0:7070"
ssl_enabled = false
ssl_cert_path = ""
ssl_key_path = ""

[http_api]
enabled = true
bind_address = "0.0.0.0:8080"
ssl_enabled = false
ssl_cert_path = ""
ssl_key_path = ""

[http_api.access_tokens]
admin = "MyAccessToken"

I suppose you need to create three apps sharing the state with a MySQL service if you want to deploy all the services. You want to do the same if you want to deploy more than one UDP or HTTP tracker.

New config options have been added to support HTTPs conenctionto the
API:

```
[http_api]
ssl_enabled = false
ssl_cert_path = "./storage/ssl_certificates/localhost.crt"
ssl_key_path = "./storage/ssl_certificates/localhost.key"
```
Instead of using a "debug" log level.
Using "debug" for sensitive data like IP address and info for generic
info we can log even on production.
Azure Container Instances do not allow you to open the same port as UDP
and TCP.
Azure Container Intances do not allow you to mount a single file.
I've created a storage folder where we can put all the things we want to
persist.
The option "strip = true" in the Cargo.toml file prevetns docker to use
the cache for the cargo dependencies.

```
[profile.release]
...
strip = true
```

More info:
LukeMathWalker/cargo-chef#172
You can use an env var to pass the configuration instead of using the
configuration file in the root folder `config.toml`

```
TORRUST_TRACKER_CONFIG=$(cat config.toml)
TORRUST_TRACKER_CONFIG=`cat config.toml` cargo run
```

This allow the applciation to be executed in dockerized environments
whithout needing to mount a file or volume for the configuration.
@josecelano josecelano mentioned this pull request Dec 16, 2022
17 tasks
@josecelano
Copy link
Member Author

ACK 171a37d

@josecelano
Copy link
Member Author

josecelano commented Dec 16, 2022

@da2ce7 @WarmBeer, if you want, you can review first #128, and them I will rebase this one. This one also contains changes in #128. Alternatively, you can review only this one and ignore #128. I would suggest reviewing first #128.

@josecelano josecelano linked an issue Dec 16, 2022 that may be closed by this pull request
@josecelano josecelano mentioned this pull request Dec 19, 2022
The published docker image runs by deafult as non root user.

Some services like ACI could require run the container as root but for
those cases they can run their customs builds or change the user while
launching the container.
@josecelano
Copy link
Member Author

ACK 6851ec5

Copy link
Contributor

@da2ce7 da2ce7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6851ec5

@da2ce7 da2ce7 merged commit 1fd8562 into torrust:develop Dec 22, 2022
@josecelano josecelano deleted the docker-reorganized-pr branch December 22, 2022 07:29
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
2 participants