Skip to content

Commit

Permalink
Merge #385: Refactor: rename env vars to follow repo renaming
Browse files Browse the repository at this point in the history
5b1a3c1 refactor: [#361] rename env vars to follow repo renaming (Jose Celano)

Pull request description:

  - Repo `torrust-index-backend` was renamed to `torrust-index`.
  - We are not using the `IDX` abbreviation for `INDEX`.
  - `USER_ID` was renamed when @da2ce7  did the container overhaul.

  ```
  TORRUST_INDEX_BACK_CORS_PERMISSIVE -> TORRUST_INDEX_API_CORS_PERMISSIVE
  TORRUST_IDX_BACK_CONFIG            -> TORRUST_INDEX_CONFIG
  TORRUST_IDX_BACK_USER_UID          -> USER_ID
  TORRUST_IDX_BACK_RUN_AS_USER       -> TORRUST_INDEX_RUN_AS_USER
  TORRUST_IDX_BACK_MYSQL_DATABASE    -> TORRUST_INDEX_MYSQL_DATABASE
  ```

ACKs for top commit:
  josecelano:
    ACK 5b1a3c1

Tree-SHA512: fcec9979ba75d7fbca0c939fbe526d54971304411b89702bb51619525fc5aa6e07cbd09b6dc177913da2948e217747771b8a86071c0aebc34d895e5c7a81ed2f
  • Loading branch information
josecelano committed Nov 15, 2023
2 parents 7c0c86b + 5b1a3c1 commit fe73268
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
5 changes: 3 additions & 2 deletions .env.local
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DATABASE_URL=sqlite://storage/database/data.db?mode=rwc
TORRUST_IDX_BACK_CONFIG=
TORRUST_IDX_BACK_USER_UID=1000
TORRUST_INDEX_CONFIG=
USER_ID=1000
TORRUST_TRACKER_CONFIG=
TORRUST_TRACKER_DATABASE_DRIVER=sqlite3
TORRUST_TRACKER_API_ADMIN_TOKEN=MyAccessToken

2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ services:
environment:
- MYSQL_ROOT_HOST=%
- MYSQL_ROOT_PASSWORD=root_secret_password
- MYSQL_DATABASE=${TORRUST_IDX_BACK_MYSQL_DATABASE:-torrust_index_e2e_testing}
- MYSQL_DATABASE=${TORRUST_INDEX_MYSQL_DATABASE:-torrust_index_e2e_testing}
- MYSQL_USER=db_user
- MYSQL_PASSWORD=db_user_secret_password
networks:
Expand Down
12 changes: 6 additions & 6 deletions contrib/dev-tools/container/build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000}
TORRUST_IDX_BACK_RUN_AS_USER=${TORRUST_IDX_BACK_RUN_AS_USER:-appuser}
USER_ID=${USER_ID:-1000}
TORRUST_INDEX_RUN_AS_USER=${TORRUST_INDEX_RUN_AS_USER:-appuser}

echo "Building docker image ..."
echo "TORRUST_IDX_BACK_USER_UID: $TORRUST_IDX_BACK_USER_UID"
echo "TORRUST_IDX_BACK_RUN_AS_USER: $TORRUST_IDX_BACK_RUN_AS_USER"
echo "USER_ID: $USER_ID"
echo "TORRUST_INDEX_RUN_AS_USER: $TORRUST_INDEX_RUN_AS_USER"

docker build \
--build-arg UID="$TORRUST_IDX_BACK_USER_UID" \
--build-arg RUN_AS_USER="$TORRUST_IDX_BACK_RUN_AS_USER" \
--build-arg UID="$USER_ID" \
--build-arg RUN_AS_USER="$TORRUST_INDEX_RUN_AS_USER" \
-t torrust-index .
2 changes: 1 addition & 1 deletion contrib/dev-tools/container/e2e/mysql/e2e-env-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ USER_ID=${USER_ID:-1000} \
TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.container.mysql.toml) \
TORRUST_INDEX_DATABASE_DRIVER="mysql" \
TORRUST_INDEX_TRACKER_API_TOKEN="MyAccessToken" \
TORRUST_IDX_BACK_MYSQL_DATABASE="torrust_index_e2e_testing" \
TORRUST_INDEX_MYSQL_DATABASE="torrust_index_e2e_testing" \
TORRUST_TRACKER_CONFIG=$(cat ./share/default/config/tracker.container.sqlite3.toml) \
TORRUST_TRACKER_DATABASE_DRIVER="sqlite3" \
TORRUST_TRACKER_API_ADMIN_TOKEN="MyAccessToken" \
Expand Down
4 changes: 2 additions & 2 deletions contrib/dev-tools/container/e2e/mysql/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ CURRENT_USER_ID=$(id -u)
echo "User name: $CURRENT_USER_NAME"
echo "User id: $CURRENT_USER_ID"

TORRUST_IDX_BACK_USER_UID=$CURRENT_USER_ID
USER_ID=$CURRENT_USER_ID
TORRUST_TRACKER_USER_UID=$CURRENT_USER_ID
export TORRUST_IDX_BACK_USER_UID
export USER_ID
export TORRUST_TRACKER_USER_UID

# todo: remove duplicate funtion
Expand Down
4 changes: 2 additions & 2 deletions contrib/dev-tools/container/e2e/sqlite/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ CURRENT_USER_ID=$(id -u)
echo "User name: $CURRENT_USER_NAME"
echo "User id: $CURRENT_USER_ID"

TORRUST_IDX_BACK_USER_UID=$CURRENT_USER_ID
USER_ID=$CURRENT_USER_ID
TORRUST_TRACKER_USER_UID=$CURRENT_USER_ID
export TORRUST_IDX_BACK_USER_UID
export USER_ID
export TORRUST_TRACKER_USER_UID

# todo: remove duplicate funtion
Expand Down
8 changes: 4 additions & 4 deletions contrib/dev-tools/container/run.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000}
TORRUST_IDX_BACK_CONFIG=$(cat config.toml)
USER_ID=${USER_ID:-1000}
TORRUST_INDEX_CONFIG=$(cat config.toml)

docker run -it \
--user="$TORRUST_IDX_BACK_USER_UID" \
--user="$USER_ID" \
--publish 3001:3001/tcp \
--env TORRUST_IDX_BACK_CONFIG="$TORRUST_IDX_BACK_CONFIG" \
--env TORRUST_INDEX_CONFIG="$TORRUST_INDEX_CONFIG" \
--volume "$(pwd)/storage":"/app/storage" \
torrust-index
2 changes: 1 addition & 1 deletion src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub const ENV_VAR_PATH_CONFIG: &str = "TORRUST_INDEX_PATH_CONFIG";
pub const DEFAULT_PATH_CONFIG: &str = "./share/default/config/index.development.sqlite3.toml";

/// If present, CORS will be permissive.
pub const ENV_VAR_CORS_PERMISSIVE: &str = "TORRUST_INDEX_BACK_CORS_PERMISSIVE";
pub const ENV_VAR_CORS_PERMISSIVE: &str = "TORRUST_INDEX_API_CORS_PERMISSIVE";

/// It loads the application configuration from the environment.
///
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@
//!
//! ```text
//! mkdir -p ./storage/database \
//! && export TORRUST_IDX_BACK_USER_UID=1000 \
//! && export USER_ID=1000 \
//! && docker run -it \
//! --user="$TORRUST_IDX_BACK_USER_UID" \
//! --user="$USER_ID" \
//! --publish 3001:3001/tcp \
//! --volume "$(pwd)/storage":"/app/storage" \
//! torrust/index
Expand Down Expand Up @@ -204,20 +204,20 @@
//!
//! For more information about configuration you can visit the documentation for the [`config`]) module.
//!
//! Alternatively to the `config.toml` file you can use one environment variable `TORRUST_IDX_BACK_CONFIG` to pass the configuration to the tracker:
//! Alternatively to the `config.toml` file you can use one environment variable `TORRUST_INDEX_CONFIG` to pass the configuration to the tracker:
//!
//! ```text
//! TORRUST_IDX_BACK_CONFIG=$(cat config.toml)
//! TORRUST_INDEX_CONFIG=$(cat config.toml)
//! cargo run
//! ```
//!
//! In the previous example you are just setting the env var with the contents of the `config.toml` file.
//!
//! The env var contains the same data as the `config.toml`. It's particularly useful in you are [running the index with docker](https://github.com/torrust/torrust-index/tree/develop/docker).
//!
//! > **NOTICE**: The `TORRUST_IDX_BACK_CONFIG` env var has priority over the `config.toml` file.
//! > **NOTICE**: The `TORRUST_INDEX_CONFIG` env var has priority over the `config.toml` file.
//!
//! > **NOTICE**: You can also change the location for the configuration file with the `TORRUST_IDX_BACK_CONFIG_PATH` env var.
//! > **NOTICE**: You can also change the location for the configuration file with the `TORRUST_INDEX_CONFIG_PATH` env var.
//!
//! # Usage
//!
Expand Down

0 comments on commit fe73268

Please sign in to comment.