Skip to content

Commit 7d4178f

Browse files
committed
dev: more docker work
1 parent 971b26e commit 7d4178f

File tree

18 files changed

+217
-115
lines changed

18 files changed

+217
-115
lines changed

.dockerignore

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
.git
2-
.git-blame-ignore
3-
.github
4-
.gitignore
5-
.vscode
6-
bin/
7-
config.toml
8-
config.toml.local
9-
cSpell.json
10-
data.db
1+
/.git
2+
/.git-blame-ignore
3+
/.github
4+
/.gitignore
5+
/.vscode
6+
/bin/
7+
/tracker.*
8+
/cSpell.json
9+
/data.db
1110
/docker/bin/
12-
NOTICE
13-
README.md
14-
rustfmt.toml
15-
storage/
16-
target/
11+
/NOTICE
12+
/README.md
13+
/rustfmt.toml
14+
/storage/
15+
/target/
16+
/etc/

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
/.coverage/
44
/.idea/
55
/.vscode/launch.json
6-
/config.toml
6+
/tracker.toml
77
/data.db
88
/database.db
99
/database.json.bz2
1010
/storage/
1111
/target
12+
/tracker.*

Dockerfile

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ WORKDIR /tmp
88
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
99
RUN cargo binstall --no-confirm cargo-chef cargo-nextest
1010

11-
1211
## Tester Image
1312
FROM rust:slim as tester
1413
WORKDIR /tmp
15-
### (fixme) https://github.com/cargo-bins/cargo-binstall/issues/1252
16-
RUN apt-get update; apt-get install -y curl; apt-get autoclean
14+
15+
RUN apt-get update; apt-get install -y curl sqlite3; apt-get autoclean
1716
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
1817
RUN cargo binstall --no-confirm cargo-nextest
1918

19+
COPY ./share/ /app/share/torrust
20+
RUN mkdir -p /app/share/torrust/default/database/; \
21+
touch /app/share/torrust/default/database/tracker.sqlite3.db; \
22+
echo ";" | sqlite3 /app/share/torrust/default/database/tracker.sqlite3.db
23+
2024

2125
## Chef Prepare (look at project and see wat we need)
2226
FROM chef AS recipe
@@ -56,20 +60,16 @@ RUN cargo nextest archive --tests --benches --examples --workspace --all-targets
5660
# Extract and Test (debug)
5761
FROM tester as test_debug
5862
WORKDIR /test
59-
COPY . /test/src
63+
COPY . /test/src/
6064
COPY --from=build_debug \
6165
/build/torrust-tracker-debug.tar.zst \
6266
/test/torrust-tracker-debug.tar.zst
63-
RUN mkdir -p /test/test
6467
RUN cargo nextest run --workspace-remap /test/src/ --extract-to /test/src/ --no-run --archive-file /test/torrust-tracker-debug.tar.zst
6568
RUN cargo nextest run --workspace-remap /test/src/ --target-dir-remap /test/src/target/ --cargo-metadata /test/src/target/nextest/cargo-metadata.json --binaries-metadata /test/src/target/nextest/binaries-metadata.json
6669

6770
RUN mkdir -p /app/bin/; cp -l /test/src/target/debug/torrust-tracker /app/bin/torrust-tracker
6871
RUN mkdir /app/lib/; cp -l $(realpath $(ldd /app/bin/torrust-tracker | grep "libz\.so\.1" | awk '{print $3}')) /app/lib/libz.so.1
69-
70-
RUN chown -R root:root /app
71-
RUN chmod -R u=rw,go=r,a+X /app
72-
RUN chmod -R a+x /app/bin
72+
RUN chown -R root:root /app; chmod -R u=rw,go=r,a+X /app; chmod -R a+x /app/bin
7373

7474
# Extract and Test (release)
7575
FROM tester as test
@@ -83,21 +83,20 @@ RUN cargo nextest run --workspace-remap /test/src/ --target-dir-remap /test/src/
8383

8484
RUN mkdir -p /app/bin/; cp -l /test/src/target/release/torrust-tracker /app/bin/torrust-tracker
8585
RUN mkdir -p /app/lib/; cp -l $(realpath $(ldd /app/bin/torrust-tracker | grep "libz\.so\.1" | awk '{print $3}')) /app/lib/libz.so.1
86-
87-
RUN chown -R root:root /app
88-
RUN chmod -R u=rw,go=r,a+X /app
89-
RUN chmod -R a+x /app/bin
86+
RUN chown -R root:root /app; chmod -R u=rw,go=r,a+X /app; chmod -R a+x /app/bin
9087

9188

9289
## Runtime
93-
FROM gcr.io/distroless/cc:debug as Runtime
90+
FROM gcr.io/distroless/cc:debug as runtime
9491
RUN ["/busybox/cp", "-sp", "/busybox/sh", "/bin/sh"]
9592

93+
ARG TORRUST_TRACKER_PATH_CONFIG="/etc/torrust/tracker/config.toml"
9694
ARG USER_ID=1000
9795
ARG UDP_PORT=6969
9896
ARG HTTP_PORT=7070
9997
ARG API_PORT=1212
10098

99+
ENV TORRUST_TRACKER_PATH_CONFIG=${TORRUST_TRACKER_PATH_CONFIG}
101100
ENV USER_ID=${USER_ID}
102101
ENV UDP_PORT=${UDP_PORT}
103102
ENV HTTP_PORT=${HTTP_PORT}
@@ -110,13 +109,21 @@ EXPOSE ${API_PORT}/tcp
110109

111110
WORKDIR /home/torrust
112111
RUN adduser --disabled-password --uid "${USER_ID}" "torrust"
113-
RUN mkdir -p /var/lib/torrust; chown -R "${USER_ID}":"${USER_ID}" /var/lib/torrust; chmod -R 2775 /var/lib/torrust
112+
RUN mkdir -p /var/lib/torrust/tracker; chown -R "${USER_ID}":"${USER_ID}" /var/lib/torrust; chmod -R 2770 /var/lib/torrust
113+
RUN mkdir -p /etc/torrust/tracker; chown -R "${USER_ID}":"${USER_ID}" /etc/torrust; chmod -R 2770 /etc/torrust
114114

115115
ENV ENV=/etc/profile
116116
COPY ./docker/motd.debug /etc/motd
117+
117118
RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/motd' >> /etc/profile
119+
RUN src="/usr/share/torrust/default/database/tracker.sqlite3.db" && dest="/var/lib/torrust/tracker/database/sqlite3.db" \
120+
&& echo "[ -e \"$src\" ] && [ ! -e \"$dest\" ] && install -D -m 0640 \"$src\" \"$dest\"" >> /etc/profile
121+
RUN src="/usr/share/torrust/default/config/tracker.sqlite3.distribution.toml" && dest="/etc/torrust/tracker/config.toml" \
122+
&& echo "[ -e \"$src\" ] && [ ! -e \"$dest\" ] && install -D -m 0640 \"$src\" \"$dest\"" >> /etc/profile
118123

119124
USER "torrust":"torrust"
125+
VOLUME /var/lib/torrust/tracker
126+
VOLUME /etc/torrust/tracker
120127

121128

122129
## Torrust-Tracker (debug)

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ git clone https://github.com/torrust/torrust-tracker.git \
4545
&& mkdir -p ./storage/ssl_certificates
4646
```
4747

48-
And then run `cargo run` twice. The first time to generate the `config.toml` file and the second time to run the tracker with the default configuration.
48+
And then run `cargo run` twice. The first time to generate the `tracker.toml` file and the second time to run the tracker with the default configuration.
4949

5050
After running the tracker these services will be available:
5151

@@ -78,3 +78,5 @@ The project is licensed under a dual license. See [COPYRIGHT](./COPYRIGHT).
7878
## Acknowledgments
7979

8080
This project was a joint effort by [Nautilus Cyberneering GmbH](https://nautilus-cyberneering.de/) and [Dutch Bits](https://dutchbits.nl). Also thanks to [Naim A.](https://github.com/naim94a/udpt) and [greatest-ape](https://github.com/greatest-ape/aquatic) for some parts of the code. Further added features and functions thanks to [Power2All](https://github.com/power2all).
81+
82+

bin/install-demo.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ if [ -d "./storage" ]; then
88
exit 1
99
fi
1010

11-
# Check if 'config.toml' file exists in the current directory
12-
if [ -f "./config.toml" ]; then
13-
echo "Warning: 'config.toml' file already exists in the root directory. Please remove or rename it before proceeding."
11+
# Check if 'tracker.toml' file exists in the current directory
12+
if [ -f "./tracker.toml" ]; then
13+
echo "Warning: 'tracker.toml' file already exists in the root directory. Please remove or rename it before proceeding."
1414
exit 1
1515
fi
1616

@@ -20,7 +20,7 @@ if ! command -v sqlite3 &> /dev/null; then
2020
exit 1
2121
fi
2222

23-
wget https://raw.githubusercontent.com/torrust/torrust-tracker/v3.0.0-alpha.3/config.toml.local -O config.toml \
23+
wget https://raw.githubusercontent.com/torrust/torrust-tracker/v3.0.0-alpha.3/tracker.toml.local -O tracker.toml \
2424
&& mkdir -p ./storage/database \
2525
&& mkdir -p ./storage/ssl_certificates \
2626
&& touch ./storage/database/data.db \

bin/install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
# This script is only intended to be used for local development or testing environments.
44

55
# Generate the default settings file if it does not exist
6-
if ! [ -f "./config.toml" ]; then
7-
cp ./config.toml.local ./config.toml
6+
if ! [ -f "./tracker.toml" ]; then
7+
cp ./tracker.toml.local ./tracker.toml
88
fi
99

1010
# Generate storage directory if it does not exist
1111
mkdir -p "./storage/database"
1212

1313
# Generate the sqlite database if it does not exist
1414
if ! [ -f "./storage/database/data.db" ]; then
15-
# todo: it should get the path from config.toml and only do it when we use sqlite
15+
# todo: it should get the path from tracker.toml and only do it when we use sqlite
1616
touch ./storage/database/data.db
1717
echo ";" | sqlite3 ./storage/database/data.db
1818
fi

cSpell.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"codegen",
3030
"completei",
3131
"connectionless",
32+
"Cyberneering",
3233
"distroless",
3334
"dockerhub",
3435
"downloadedi",
@@ -49,6 +50,7 @@
4950
"infoschema",
5051
"Intermodal",
5152
"intervali",
53+
"keyout",
5254
"lcov",
5355
"leecher",
5456
"leechers",
@@ -63,6 +65,7 @@
6365
"myacicontext",
6466
"Naim",
6567
"nanos",
68+
"newkey",
6669
"nextest",
6770
"nocapture",
6871
"nologin",

compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
tty: true
77
environment:
88
- TORRUST_TRACKER_CONFIG=${TORRUST_TRACKER_CONFIG}
9-
- TORRUST_TRACKER_API_TOKEN=${TORRUST_TRACKER_API_TOKEN:-MyAccessToken}
9+
- TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken}
1010
networks:
1111
- server_side
1212
ports:

docker/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export TORRUST_TRACKER_USER_UID=1000 \
3131
--publish 7070:7070/tcp \
3232
--publish 1212:1212/tcp \
3333
--volume "$(pwd)/storage":"/app/storage" \
34-
--volume "$(pwd)/config.toml":"/app/config.toml":ro \
34+
--volume "$(pwd)/tracker.toml":"/app/tracker.toml":ro \
3535
torrust/tracker:3.0.0-alpha.3
3636
```
3737

@@ -74,14 +74,14 @@ export TORRUST_TRACKER_USER_UID=1000
7474
In both cases, you will need to:
7575

7676
- Create the SQLite DB (`data.db`) if you are going to use SQLite.
77-
- Create the configuration file (`config.toml`) before running the tracker.
77+
- Create the configuration file (`tracker.toml`) before running the tracker.
7878
- Replace the user UID (`1000`) with yours.
7979

8080
> NOTICE: that the `./bin/install.sh` can setup the application for you. But it
8181
uses a predefined configuration.
8282

8383
Remember to switch to your default docker context `docker context use default`
84-
and to change the API default configuration in `config.toml` to make it
84+
and to change the API default configuration in `tracker.toml` to make it
8585
available from the host machine:
8686

8787
```toml
@@ -91,7 +91,7 @@ bind_address = "0.0.0.0:1212"
9191

9292
### With docker-compose
9393

94-
The docker-compose configuration includes the MySQL service configuration. If you want to use MySQL instead of SQLite you have to change your `config.toml` configuration:
94+
The docker-compose configuration includes the MySQL service configuration. If you want to use MySQL instead of SQLite you have to change your `tracker.toml` configuration:
9595

9696
```toml
9797
db_driver = "MySQL"
@@ -170,7 +170,7 @@ If the database, user or permissions are not created the reason could be the MyS
170170

171171
### SSL Certificates
172172

173-
You can use a certificate for localhost. You can create your [localhost certificate](https://letsencrypt.org/docs/certificates-for-localhost/#making-and-trusting-your-own-certificates) and use it in the `storage` folder and the configuration file (`config.toml`). For example:
173+
You can use a certificate for localhost. You can create your [localhost certificate](https://letsencrypt.org/docs/certificates-for-localhost/#making-and-trusting-your-own-certificates) and use it in the `storage` folder and the configuration file (`tracker.toml`). For example:
174174

175175
The storage folder must contain your certificates:
176176

@@ -184,7 +184,7 @@ storage/
184184
└── localhost.key
185185
```
186186

187-
You have not enabled it in your `config.toml` file:
187+
You have not enabled it in your `tracker.toml` file:
188188

189189
```toml
190190
...

docker/bin/run-local-image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
TORRUST_TRACKER_CONFIG=$(cat config.toml)
3+
TORRUST_TRACKER_CONFIG=$(cat tracker.toml)
44

55
docker run -it \
66
--user="$(whoami)" \

0 commit comments

Comments
 (0)