-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1150d5
commit 1d6a59a
Showing
8 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.git | ||
.github | ||
.vscode | ||
config.toml | ||
data.db | ||
docker/commands/ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
FROM clux/muslrust:stable AS chef | ||
WORKDIR /app | ||
RUN cargo install cargo-chef | ||
|
||
|
||
FROM chef AS planner | ||
WORKDIR /app | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
|
||
FROM chef AS builder | ||
WORKDIR /app | ||
ARG UID=1000 | ||
# Create the app user | ||
ENV USER=appuser | ||
ENV UID=$UID | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
# Build dependencies | ||
COPY --from=planner /app/recipe.json recipe.json | ||
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json | ||
# Build the application | ||
# todo: it seems the previous cache layer is not working. The dependencies are compiled always. | ||
COPY . . | ||
RUN cargo build --release --target x86_64-unknown-linux-musl --bin torrust-tracker | ||
|
||
|
||
FROM alpine:latest | ||
WORKDIR /app | ||
RUN apk --no-cache add ca-certificates | ||
ENV TZ=Etc/UTC APP_USER=appuser | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /etc/group /etc/group | ||
COPY --from=builder --chown=$APP_USER \ | ||
/app/target/x86_64-unknown-linux-musl/release/torrust-tracker \ | ||
/app/torrust-tracker | ||
RUN chown -R $APP_USER:$APP_USER /app | ||
USER $APP_USER:$APP_USER | ||
EXPOSE 6969 | ||
EXPOSE 1212 | ||
ENTRYPOINT ["/app/torrust-tracker"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# Generate the default settings file if it does not exist | ||
if ! [ -f "./config.toml" ]; then | ||
cp ./config.toml.local ./config.toml | ||
fi | ||
|
||
# Generate the sqlite database if it does not exist | ||
if ! [ -f "./data.db" ]; then | ||
# todo: it should get the path from config.toml and only do it when we use sqlite | ||
touch ./data.db | ||
echo ";" | sqlite3 ./data.db | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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:6969" | ||
ssl_enabled = false | ||
ssl_cert_path = "" | ||
ssl_key_path = "" | ||
|
||
[http_api] | ||
enabled = true | ||
bind_address = "127.0.0.1:1212" | ||
|
||
[http_api.access_tokens] | ||
admin = "MyAccessToken" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Docker | ||
|
||
## Requirements | ||
|
||
- Docker version 20.10.21 | ||
|
||
## Dev environment | ||
|
||
Build and run locally: | ||
|
||
```s | ||
export TORRUST_TRACKER_USER_UID=1000 | ||
./docker/bin/build.sh $TORRUST_TRACKER_USER_UID | ||
./bin/install.sh | ||
./docker/bin/run.sh $TORRUST_TRACKER_USER_UID | ||
``` | ||
|
||
Run using the pre-built public docker image: | ||
|
||
```s | ||
export TORRUST_TRACKER_USER_UID=1000 | ||
docker run -it \ | ||
--user="$TORRUST_TRACKER_USER_UID" \ | ||
-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 \ | ||
josecelano/torrust-tracker | ||
``` | ||
|
||
> NOTES: | ||
> | ||
> - You have to create the SQLite DB (`data.db`) and configuration (`config.toml`) before running the tracker. See `bin/install.sh`. | ||
> - You have to replace the user UID (`1000`) with yours. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
TORRUST_TRACKER_USER_UID=${TORRUST_TRACKER_USER_UID:-1000} | ||
|
||
echo "Building docker image ..." | ||
echo "TORRUST_TRACKER_USER_UID: $TORRUST_TRACKER_USER_UID" | ||
|
||
docker build \ | ||
--build-arg UID="$TORRUST_TRACKER_USER_UID" \ | ||
-t torrust-tracker . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
./docker/bin/build.sh | ||
./bin/install.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
TORRUST_TRACKER_USER_UID=${TORRUST_TRACKER_USER_UID:-1000} | ||
|
||
docker run -it \ | ||
--user="$TORRUST_TRACKER_USER_UID" \ | ||
-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 |