forked from torrust/torrust-index-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: [torrust#363] fix container configuration
following latest cahgnes in the Tracker and Index.
- Loading branch information
1 parent
8b816ee
commit db968d5
Showing
30 changed files
with
453 additions
and
185 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,12 @@ | ||
# App build variables | ||
API_BASE_URL=http://localhost:3001/v1 | ||
|
||
# Rust SQLx | ||
DATABASE_URL=sqlite://storage/database/data.db?mode=rwc | ||
|
||
# Docker compose | ||
TORRUST_INDEX_CONFIG= | ||
USER_ID=1000 | ||
TORRUST_TRACKER_CONFIG= | ||
TORRUST_TRACKER_USER_UID=1000 | ||
TORRUST_TRACKER_API_TOKEN=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
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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.cache | ||
.env | ||
.env* | ||
!.env.local | ||
.idea | ||
.nitro | ||
.nuxt | ||
|
File renamed without changes.
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
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
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,6 @@ | ||
#!/bin/bash | ||
|
||
USER_ID=${USER_ID:-1000} \ | ||
TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.e2e.container.sqlite3.toml) \ | ||
TORRUST_TRACKER_CONFIG=$(cat ./share/default/config/tracker.e2e.container.sqlite3.toml) \ | ||
docker compose down |
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,15 @@ | ||
#!/bin/bash | ||
|
||
TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.e2e.container.sqlite3.toml) \ | ||
docker compose build | ||
|
||
USER_ID=${USER_ID:-1000} \ | ||
TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.e2e.container.sqlite3.toml) \ | ||
TORRUST_INDEX_DATABASE="e2e_testing_sqlite3" \ | ||
TORRUST_INDEX_DATABASE_DRIVER="sqlite3" \ | ||
TORRUST_INDEX_TRACKER_API_TOKEN="MyAccessToken" \ | ||
TORRUST_TRACKER_CONFIG=$(cat ./share/default/config/tracker.e2e.container.sqlite3.toml) \ | ||
TORRUST_TRACKER_DATABASE="e2e_testing_sqlite3" \ | ||
TORRUST_TRACKER_DATABASE_DRIVER="sqlite3" \ | ||
TORRUST_TRACKER_API_ADMIN_TOKEN="MyAccessToken" \ | ||
docker compose up --detach --pull always --remove-orphans |
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,23 @@ | ||
#!/bin/bash | ||
|
||
# This script is only intended to be used for E2E testing environment. | ||
|
||
## Index | ||
|
||
# Generate the Index sqlite database directory and file if it does not exist | ||
mkdir -p ./storage/index/lib/database | ||
|
||
if ! [ -f "./storage/index/lib/database/${TORRUST_INDEX_DATABASE}.db" ]; then | ||
echo "Creating index database '${TORRUST_INDEX_DATABASE}.db'" | ||
sqlite3 "./storage/index/lib/database/${TORRUST_INDEX_DATABASE}.db" "VACUUM;" | ||
fi | ||
|
||
## Tracker | ||
|
||
# Generate the Tracker sqlite database directory and file if it does not exist | ||
mkdir -p ./storage/tracker/lib/database | ||
|
||
if ! [ -f "./storage/tracker/lib/database/${TORRUST_TRACKER_DATABASE}.db" ]; then | ||
echo "Creating tracker database '${TORRUST_TRACKER_DATABASE}.db'" | ||
sqlite3 "./storage/tracker/lib/database/${TORRUST_TRACKER_DATABASE}.db" "VACUUM;" | ||
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,38 @@ | ||
#!/bin/bash | ||
|
||
CURRENT_USER_NAME=$(whoami) | ||
CURRENT_USER_ID=$(id -u) | ||
echo "User name: $CURRENT_USER_NAME" | ||
echo "User id: $CURRENT_USER_ID" | ||
|
||
TORRUST_INDEX_GUI_USER_UID=$CURRENT_USER_ID | ||
USER_ID=$CURRENT_USER_ID | ||
export USER_ID | ||
export TORRUST_INDEX_GUI_USER_UID | ||
|
||
export TORRUST_INDEX_DATABASE="e2e_testing_sqlite3" | ||
export TORRUST_TRACKER_DATABASE="e2e_testing_sqlite3" | ||
|
||
# Install app | ||
cp .env.local .env || exit 1 | ||
./contrib/dev-tools/container/e2e/sqlite/install.sh || exit 1 | ||
|
||
# Start E2E testing environment | ||
./contrib/dev-tools/container/e2e/sqlite/e2e-env-up.sh || exit 1 | ||
|
||
# Wait for conatiners to be healthy | ||
./contrib/dev-tools/container/functions/wait_for_container_to_be_healthy.sh torrust-mysql-1 10 3 || exit 1 | ||
./contrib/dev-tools/container/functions/wait_for_container_to_be_healthy.sh torrust-tracker-1 10 3 || exit 1 | ||
./contrib/dev-tools/container/functions/wait_for_container_to_be_healthy.sh torrust-index-1 10 3 || exit 1 | ||
|
||
# Wait for the Index GUI to be ready | ||
sleep 10 | ||
|
||
# Just to make sure that everything is up and running | ||
docker ps | ||
|
||
# Run E2E tests with shared app instance | ||
npm run cypress:run || { ./contrib/dev-tools/container/e2e/sqlite/e2e-env-down.sh; exit 1; } | ||
|
||
# Stop E2E testing environment | ||
./contrib/dev-tools/container/e2e/sqlite/e2e-env-down.sh |
26 changes: 26 additions & 0 deletions
26
contrib/dev-tools/container/functions/wait_for_container_to_be_healthy.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,26 @@ | ||
#!/bin/bash | ||
|
||
wait_for_container_to_be_healthy() { | ||
local container_name="$1" | ||
local max_retries="$2" | ||
local retry_interval="$3" | ||
local retry_count=0 | ||
|
||
while [ $retry_count -lt "$max_retries" ]; do | ||
container_health="$(docker inspect --format='{{json .State.Health}}' "$container_name")" | ||
if [ "$container_health" != "{}" ]; then | ||
container_status="$(echo "$container_health" | jq -r '.Status')" | ||
if [ "$container_status" == "healthy" ]; then | ||
echo "Container $container_name is healthy" | ||
return 0 | ||
fi | ||
fi | ||
|
||
retry_count=$((retry_count + 1)) | ||
echo "Waiting for container $container_name to become healthy (attempt $retry_count of $max_retries)..." | ||
sleep "$retry_interval" | ||
done | ||
|
||
echo "Timeout reached, container $container_name is not healthy" | ||
return 1 | ||
} |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.