Skip to content

Commit

Permalink
Merge torrust#270: Fix docker compose configuration with the new tr…
Browse files Browse the repository at this point in the history
…acker container image

bf95d85 fix: docker compose with the new tracker container image (Jose Celano)

Pull request description:

  The [Torrust Tracker container image has changed](torrust/torrust-tracker@7d133ae).

  We have to upgrade the configuration to use the latest version.

  Integration tests fail for pull requests because the tracker container cannot start.

  The significant changes introduced were:

  - Rename some env vars: TORRUST_TRACKER_API_TOKEN->TORRUST_TRACKER_API_ADMIN_TOKEN
  - Database folder was moved to a new location

Top commit has no ACKs.

Tree-SHA512: 397ba6dbcd99ca38a6dd9d932e899303ea8e67068fdb2180bcf313887bea1972353f5017ca30139b9e48a79a7f746f29dc644e2c7ecf32a12597adbe6a7c5f62
  • Loading branch information
josecelano committed Sep 11, 2023
2 parents b3fe7f9 + bf95d85 commit 158757b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ DATABASE_URL=sqlite://storage/database/data.db?mode=rwc
TORRUST_IDX_BACK_CONFIG=
TORRUST_IDX_BACK_USER_UID=1000
TORRUST_TRACKER_CONFIG=
TORRUST_TRACKER_USER_UID=1000
TORRUST_TRACKER_API_TOKEN=MyAccessToken
TORRUST_TRACKER_DATABASE=sqlite3
TORRUST_TRACKER_API_ADMIN_TOKEN=MyAccessToken
22 changes: 7 additions & 15 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,21 @@ services:

tracker:
image: torrust/tracker:develop
user: ${TORRUST_TRACKER_USER_UID:-1000}:${TORRUST_TRACKER_USER_UID:-1000}
tty: true
environment:
- TORRUST_TRACKER_CONFIG=${TORRUST_TRACKER_CONFIG}
- TORRUST_TRACKER_API_TOKEN=${TORRUST_TRACKER_API_TOKEN:-MyAccessToken}
- TORRUST_TRACKER_DATABASE=${TORRUST_TRACKER_DATABASE:-sqlite3}
- TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken}
networks:
- server_side
ports:
- 6969:6969/udp
- 1212:1212/tcp
# todo: implement healthcheck
#healthcheck:
# test:
# [
# "CMD-SHELL",
# "/app/main healthcheck"
# ]
# interval: 10s
# retries: 5
# start_period: 10s
# timeout: 3s
- 7070:7070
- 1212:1212
volumes:
- ./storage:/app/storage
- ./storage/tracker/lib:/var/lib/torrust/tracker:Z
- ./storage/tracker/log:/var/log/torrust/tracker:Z
- ./storage/tracker/etc:/etc/torrust/tracker:Z
depends_on:
- mysql

Expand Down
2 changes: 1 addition & 1 deletion config-tracker.local.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
log_level = "info"
mode = "public"
db_driver = "Sqlite3"
db_path = "./storage/database/torrust_tracker_e2e_testing.db"
db_path = "/var/lib/torrust/tracker/database/torrust_tracker_e2e_testing.db"
announce_interval = 120
min_announce_interval = 120
max_peer_timeout = 900
Expand Down
3 changes: 2 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ Build and run it locally:
```s
TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \
TORRUST_IDX_BACK_CONFIG=$(cat config-idx-back.local.toml) \
TORRUST_TRACKER_DATABASE=${TORRUST_TRACKER_DATABASE:-mysql} \
TORRUST_TRACKER_CONFIG=$(cat config-tracker.local.toml) \
TORRUST_TRACKER_API_TOKEN=${TORRUST_TRACKER_API_TOKEN:-MyAccessToken} \
TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken} \
docker compose up -d --build
```

Expand Down
9 changes: 4 additions & 5 deletions docker/bin/e2e/mysql/e2e-env-reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD -e "DROP DATABASE IF EXIST
# Tracker

# Delete tracker database
rm -f ./storage/database/torrust_tracker_e2e_testing.db
rm -f ./storage/tracker/lib/database/torrust_tracker_e2e_testing.db

# Generate storage directory if it does not exist
mkdir -p "./storage/database"
mkdir -p "./storage/tracker/lib/database"

# Generate the sqlite database for the tracker if it does not exist
if ! [ -f "./storage/database/torrust_tracker_e2e_testing.db" ]; then
touch ./storage/database/torrust_tracker_e2e_testing.db
echo ";" | sqlite3 ./storage/database/torrust_tracker_e2e_testing.db
if ! [ -f "./storage/tracker/lib/database/torrust_tracker_e2e_testing.db" ]; then
sqlite3 ./storage/tracker/lib/database/torrust_tracker_e2e_testing.db "VACUUM;"
fi

./docker/bin/e2e/mysql/e2e-env-up.sh
3 changes: 2 additions & 1 deletion docker/bin/e2e/mysql/e2e-env-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \
TORRUST_IDX_BACK_CONFIG=$(cat config-idx-back.mysql.local.toml) \
TORRUST_IDX_BACK_MYSQL_DATABASE="torrust_index_backend_e2e_testing" \
TORRUST_TRACKER_CONFIG=$(cat config-tracker.local.toml) \
TORRUST_TRACKER_API_TOKEN=${TORRUST_TRACKER_API_TOKEN:-MyAccessToken} \
TORRUST_TRACKER_DATABASE=${TORRUST_TRACKER_DATABASE:-mysql} \
TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken} \
docker compose up -d

10 changes: 4 additions & 6 deletions docker/bin/e2e/sqlite/e2e-env-reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@
docker compose down

rm -f ./storage/database/torrust_index_backend_e2e_testing.db
rm -f ./storage/database/torrust_tracker_e2e_testing.db
rm -f ./storage/tracker/lib/database/torrust_tracker_e2e_testing.db

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

# Generate the sqlite database for the index backend if it does not exist
if ! [ -f "./storage/database/torrust_index_backend_e2e_testing.db" ]; then
# todo: it should get the path from config.toml and only do it when we use sqlite
touch ./storage/database/torrust_index_backend_e2e_testing.db
echo ";" | sqlite3 ./storage/database/torrust_index_backend_e2e_testing.db
sqlite3 ./storage/database/torrust_index_backend_e2e_testing.db "VACUUM;"
fi

# Generate the sqlite database for the tracker if it does not exist
if ! [ -f "./storage/database/torrust_tracker_e2e_testing.db" ]; then
touch ./storage/database/torrust_tracker_e2e_testing.db
echo ";" | sqlite3 ./storage/database/torrust_tracker_e2e_testing.db
if ! [ -f "./storage/tracker/lib/database/torrust_tracker_e2e_testing.db" ]; then
sqlite3 ./storage/tracker/lib/database/torrust_tracker_e2e_testing.db "VACUUM;"
fi

./docker/bin/e2e/sqlite/e2e-env-up.sh
5 changes: 4 additions & 1 deletion docker/bin/e2e/sqlite/e2e-env-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \

TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \
TORRUST_IDX_BACK_CONFIG=$(cat config-idx-back.sqlite.local.toml) \
TORRUST_IDX_BACK_MYSQL_DATABASE="torrust_index_backend_e2e_testing" \
TORRUST_TRACKER_CONFIG=$(cat config-tracker.local.toml) \
TORRUST_TRACKER_API_TOKEN=${TORRUST_TRACKER_API_TOKEN:-MyAccessToken} \
TORRUST_TRACKER_DATABASE=${TORRUST_TRACKER_DATABASE:-sqlite3} \
TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken} \
docker compose up -d

0 comments on commit 158757b

Please sign in to comment.