File tree Expand file tree Collapse file tree 8 files changed +157
-0
lines changed Expand file tree Collapse file tree 8 files changed +157
-0
lines changed Original file line number Diff line number Diff line change 1+ .git 
2+ .github 
3+ .vscode 
4+ config.toml 
5+ data.db 
6+ docker /commands /
7+ target /
Original file line number Diff line number Diff line change 1+ FROM  clux/muslrust:stable AS chef
2+ WORKDIR  /app
3+ RUN  cargo install cargo-chef
4+ 
5+ 
6+ FROM  chef AS planner
7+ WORKDIR  /app
8+ COPY  . .
9+ RUN  cargo chef prepare --recipe-path recipe.json
10+ 
11+ 
12+ FROM  chef AS builder
13+ WORKDIR  /app
14+ ARG  UID=1000
15+ #  Create the app user
16+ ENV  USER=appuser
17+ ENV  UID=$UID
18+ RUN  adduser \
19+   --disabled-password \
20+   --gecos ""  \
21+   --home "/nonexistent"  \
22+   --shell "/sbin/nologin"  \
23+   --no-create-home \
24+   --uid "${UID}"  \
25+   "${USER}" 
26+ #  Build dependencies
27+ COPY  --from=planner /app/recipe.json recipe.json
28+ RUN  cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
29+ #  Build the application
30+ #  todo: it seems the previous cache layer is not working. The dependencies are compiled always.
31+ COPY  . .
32+ RUN  cargo build --release --target x86_64-unknown-linux-musl --bin torrust-tracker
33+ 
34+ 
35+ FROM  alpine:latest
36+ WORKDIR  /app
37+ RUN  apk --no-cache add ca-certificates
38+ ENV  TZ=Etc/UTC APP_USER=appuser
39+ COPY  --from=builder /etc/passwd /etc/passwd
40+ COPY  --from=builder /etc/group /etc/group
41+ COPY  --from=builder --chown=$APP_USER \
42+   /app/target/x86_64-unknown-linux-musl/release/torrust-tracker \
43+   /app/torrust-tracker
44+ RUN  chown -R $APP_USER:$APP_USER /app
45+ USER  $APP_USER:$APP_USER
46+ EXPOSE  6969
47+ EXPOSE  1212
48+ ENTRYPOINT  ["/app/torrust-tracker" ]
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ 
3+ #  Generate the default settings file if it does not exist
4+ if  !  [ -f  " ./config.toml"   ];  then 
5+     cp ./config.toml.local ./config.toml
6+ fi 
7+ 
8+ #  Generate the sqlite database if it does not exist
9+ if  !  [ -f  " ./data.db"   ];  then 
10+     #  todo: it should get the path from config.toml and only do it when we use sqlite
11+     touch ./data.db
12+     echo  " ;"   |  sqlite3 ./data.db
13+ fi 
14+ 
Original file line number Diff line number Diff line change 1+ log_level = "info"
2+ mode = "public"
3+ db_driver = "Sqlite3"
4+ db_path = "data.db"
5+ announce_interval = 120
6+ min_announce_interval = 120
7+ max_peer_timeout = 900
8+ on_reverse_proxy = false
9+ external_ip = "0.0.0.0"
10+ tracker_usage_statistics = true
11+ persistent_torrent_completed_stat = false
12+ inactive_peer_cleanup_interval = 600
13+ remove_peerless_torrents = true
14+ 
15+ [[udp_trackers]]
16+ enabled = false
17+ bind_address = "0.0.0.0:6969"
18+ 
19+ [[http_trackers]]
20+ enabled = false
21+ bind_address = "0.0.0.0:6969"
22+ ssl_enabled = false
23+ ssl_cert_path = ""
24+ ssl_key_path = ""
25+ 
26+ [http_api]
27+ enabled = true
28+ bind_address = "127.0.0.1:1212"
29+ 
30+ [http_api.access_tokens]
31+ admin = "MyAccessToken"
Original file line number Diff line number Diff line change 1+ # Docker  
2+ 
3+ ## Requirements  
4+ 
5+ -  Docker version 20.10.21
6+ 
7+ ## Dev environment  
8+ 
9+ Build and run locally:
10+ 
11+ ``` s 
12+ export TORRUST_TRACKER_USER_UID=1000 
13+ ./docker/bin/build.sh $TORRUST_TRACKER_USER_UID 
14+ ./bin/install.sh 
15+ ./docker/bin/run.sh $TORRUST_TRACKER_USER_UID 
16+ ``` 
17+ 
18+ Run using the pre-built public docker image:
19+ 
20+ ``` s 
21+ export TORRUST_TRACKER_USER_UID=1000 
22+ docker run -it \ 
23+     --user="$TORRUST_TRACKER_USER_UID" \ 
24+     -p 6969:6969 -p 1212:1212 \ 
25+     --mount type=bind,source="$(pwd)/data.db",target=/app/data.db \ 
26+     --mount type=bind,source="$(pwd)/config.toml",target=/app/config.toml \ 
27+     josecelano/torrust-tracker 
28+ ``` 
29+ 
30+ >  NOTES:
31+ > 
32+ >  -  You have to create the SQLite DB (` data.db ` ) and configuration (` config.toml ` ) before running the tracker. See ` bin/install.sh ` .
33+ >  -  You have to replace the user UID (` 1000 ` ) with yours.
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ 
3+ TORRUST_TRACKER_USER_UID=${TORRUST_TRACKER_USER_UID:- 1000} 
4+ 
5+ echo  " Building docker image ..." 
6+ echo  " TORRUST_TRACKER_USER_UID: $TORRUST_TRACKER_USER_UID " 
7+ 
8+ docker build \
9+     --build-arg UID=" $TORRUST_TRACKER_USER_UID "   \
10+     -t torrust-tracker . 
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ 
3+ ./docker/bin/build.sh
4+ ./bin/install.sh
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ 
3+ TORRUST_TRACKER_USER_UID=${TORRUST_TRACKER_USER_UID:- 1000} 
4+ 
5+ docker run -it \
6+     --user=" $TORRUST_TRACKER_USER_UID "   \
7+     -p 6969:6969 -p 1212:1212 \
8+     --mount type=bind,source=" $( pwd)  /data.db"  ,target=/app/data.db \
9+     --mount type=bind,source=" $( pwd)  /config.toml"  ,target=/app/config.toml \
10+     torrust-tracker
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments