From 33f96f6fd9c6c270e6bb3deae4f16e5ee5bf8ead Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Thu, 26 Oct 2023 12:43:09 +0100 Subject: [PATCH] fix: docker compose configuration to use the new index container --- bin/install.sh | 7 ++++--- compose.yaml | 16 +++++++++------- config-idx-back.local.toml | 4 ++-- config-tracker.local.toml | 2 +- cypress.config.ts | 2 +- docker/bin/e2e-env-down.sh | 2 +- docker/bin/e2e-env-install.sh | 23 +++++++++++++++++++++++ docker/bin/e2e-env-up.sh | 2 +- docker/bin/run-e2e-tests.sh | 2 +- dot.env.local | 2 +- 10 files changed, 44 insertions(+), 18 deletions(-) create mode 100755 docker/bin/e2e-env-install.sh diff --git a/bin/install.sh b/bin/install.sh index 308c7514..88bd2ac9 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -7,11 +7,12 @@ if ! [ -f "./.env" ]; then fi # Generate storage directory if it does not exist -mkdir -p "./storage/database" +mkdir -p "./storage/index/lib/database/" +mkdir -p "./storage/tracker/lib/database/" # Generate the sqlite database for the index backend if it does not exist -if ! [ -f "./storage/database/data.db" ]; then - sqlite3 ./storage/database/data.db "VACUUM;" +if ! [ -f "./storage/index/lib/database/sqlite3.db" ]; then + sqlite3 ./storage/index/lib/database/sqlite3.db "VACUUM;" fi # Generate the sqlite database for the tracker if it does not exist diff --git a/compose.yaml b/compose.yaml index 88aefd1a..36ed2308 100644 --- a/compose.yaml +++ b/compose.yaml @@ -27,19 +27,19 @@ services: volumes: - ./:/app depends_on: - - idx-back + - index - tracker - mailcatcher - mysql - idx-back: + index: image: torrust/index-backend:develop - user: ${TORRUST_IDX_BACK_USER_UID:-1000}:${TORRUST_IDX_BACK_USER_UID:-1000} tty: true environment: - - TORRUST_IDX_BACK_CONFIG=${TORRUST_IDX_BACK_CONFIG} - - TORRUST_IDX_BACK_CORS_PERMISSIVE=true - - CARGO_HOME=/home/appuser/.cargo + - TORRUST_INDEX_CONFIG=${TORRUST_INDEX_CONFIG} + - TORRUST_INDEX_DATABASE_DRIVER=${TORRUST_TRACKER_DATABASE_DRIVER:-sqlite3} + - TORRUST_INDEX_BACK_CORS_PERMISSIVE=${TORRUST_INDEX_BACK_CORS_PERMISSIVE:-true} + - TORRUST_INDEX_TRACKER_API_TOKEN=${TORRUST_INDEX_TRACKER_API_TOKEN:-MyAccessToken} networks: - server_side ports: @@ -56,7 +56,9 @@ services: # start_period: 10s # timeout: 3s volumes: - - ./storage:/app/storage + - ./storage/index/lib:/var/lib/torrust/index:Z + - ./storage/index/log:/var/log/torrust/index:Z + - ./storage/index/etc:/etc/torrust/index:Z depends_on: - tracker - mailcatcher diff --git a/config-idx-back.local.toml b/config-idx-back.local.toml index bebaf8c0..6fd42216 100644 --- a/config-idx-back.local.toml +++ b/config-idx-back.local.toml @@ -20,8 +20,8 @@ max_password_length = 64 secret_key = "MaxVerstappenWC2021" [database] -connect_url = "sqlite://storage/database/torrust_index_backend_e2e_testing.db?mode=rwc" # SQLite -#connect_url = "mysql://root:root_secret_password@mysql:3306/torrust_index_backend_e2e_testing" # MySQL +connect_url = "sqlite:///var/lib/torrust/index/database/e2e_testing_sqlite3.db?mode=rwc" # SQLite +#connect_url = "mysql://root:root_secret_password@mysql:3306/torrust_index_e2e_testing" # MySQL [mail] email_verification_enabled = false diff --git a/config-tracker.local.toml b/config-tracker.local.toml index 2c7cb704..28b63f4c 100644 --- a/config-tracker.local.toml +++ b/config-tracker.local.toml @@ -1,7 +1,7 @@ log_level = "info" mode = "public" db_driver = "Sqlite3" -db_path = "/var/lib/torrust/tracker/database/torrust_tracker_e2e_testing.db" +db_path = "/var/lib/torrust/tracker/database/e2e_testing_sqlite3.db" announce_interval = 120 min_announce_interval = 120 max_peer_timeout = 900 diff --git a/cypress.config.ts b/cypress.config.ts index 0297ae27..c694f08c 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -37,6 +37,6 @@ export default defineConfig({ } }, env: { - db_file_path: "./storage/database/torrust_index_backend_e2e_testing.db" + db_file_path: "./storage/index/lib/database/e2e_testing_sqlite3.db" } }); diff --git a/docker/bin/e2e-env-down.sh b/docker/bin/e2e-env-down.sh index 0d402ee5..4badef06 100755 --- a/docker/bin/e2e-env-down.sh +++ b/docker/bin/e2e-env-down.sh @@ -1,7 +1,7 @@ #!/bin/bash TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \ - TORRUST_IDX_BACK_CONFIG=$(cat config-idx-back.local.toml) \ + TORRUST_INDEX_CONFIG=$(cat config-idx-back.local.toml) \ TORRUST_TRACKER_CONFIG=$(cat config-tracker.local.toml) \ TORRUST_TRACKER_DATABASE=${TORRUST_TRACKER_DATABASE:-sqlite3} \ TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken} \ diff --git a/docker/bin/e2e-env-install.sh b/docker/bin/e2e-env-install.sh new file mode 100755 index 00000000..66bb39e3 --- /dev/null +++ b/docker/bin/e2e-env-install.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Generate the .env file if it does not exist +if ! [ -f "./.env" ]; then + # Copy .env file from development template + cp dot.env.local .env +fi + +# Generate storage directory if it does not exist +mkdir -p "./storage/index/lib/database/" +mkdir -p "./storage/tracker/lib/database/" + +# Generate the sqlite database for the index backend if it does not exist +if ! [ -f "./storage/index/lib/database/e2e_testing_sqlite3.db" ]; then + sqlite3 ./storage/index/lib/database/e2e_testing_sqlite3.db "VACUUM;" +fi + +# Generate the sqlite database for the tracker if it does not exist +if ! [ -f "./storage/tracker/lib/database/e2e_testing_sqlite3.db" ]; then + sqlite3 ./storage/tracker/lib/database/e2e_testing_sqlite3.db "VACUUM;" +fi + +npm install diff --git a/docker/bin/e2e-env-up.sh b/docker/bin/e2e-env-up.sh index 75d0be16..c20096d9 100755 --- a/docker/bin/e2e-env-up.sh +++ b/docker/bin/e2e-env-up.sh @@ -4,7 +4,7 @@ TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \ docker compose build TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \ - TORRUST_IDX_BACK_CONFIG=$(cat config-idx-back.local.toml) \ + TORRUST_INDEX_CONFIG=$(cat config-idx-back.local.toml) \ TORRUST_TRACKER_CONFIG=$(cat config-tracker.local.toml) \ TORRUST_TRACKER_DATABASE=${TORRUST_TRACKER_DATABASE:-sqlite3} \ TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken} \ diff --git a/docker/bin/run-e2e-tests.sh b/docker/bin/run-e2e-tests.sh index cbd2c6d2..a1097c53 100755 --- a/docker/bin/run-e2e-tests.sh +++ b/docker/bin/run-e2e-tests.sh @@ -37,7 +37,7 @@ wait_for_container_to_be_healthy() { return 1 } -./bin/install.sh || exit 1 +./docker/bin/e2e-env-install.sh || exit 1 # Start E2E testing environment ./docker/bin/e2e-env-up.sh || exit 1 diff --git a/dot.env.local b/dot.env.local index 2c74a1d7..a857d349 100644 --- a/dot.env.local +++ b/dot.env.local @@ -5,7 +5,7 @@ API_BASE_URL=http://localhost:3001/v1 DATABASE_URL=sqlite://storage/database/data.db?mode=rwc # Docker compose -TORRUST_IDX_BACK_CONFIG= +TORRUST_INDEX_CONFIG= TORRUST_IDX_BACK_USER_UID=1000 TORRUST_TRACKER_CONFIG= TORRUST_TRACKER_USER_UID=1000