Skip to content

Commit

Permalink
feat: add redis_host as an env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
meienberger committed Jan 23, 2023
1 parent 257966c commit 71d106b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docker-compose.dev.yml
Expand Up @@ -106,6 +106,7 @@ services:
api:
condition: service_started
environment:
NODE_ENV: development
INTERNAL_IP: ${INTERNAL_IP}
TIPI_VERSION: ${TIPI_VERSION}
JWT_SECRET: ${JWT_SECRET}
Expand All @@ -118,6 +119,7 @@ services:
APPS_REPO_URL: ${APPS_REPO_URL}
DOMAIN: ${DOMAIN}
ARCHITECTURE: ${ARCHITECTURE}
REDIS_HOST: ${REDIS_HOST}
networks:
- tipi_main_network
volumes:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.rc.yml
Expand Up @@ -118,6 +118,7 @@ services:
APPS_REPO_URL: ${APPS_REPO_URL}
DOMAIN: ${DOMAIN}
ARCHITECTURE: ${ARCHITECTURE}
REDIS_HOST: ${REDIS_HOST}
volumes:
- ${PWD}/state:/runtipi/state
- ${PWD}/logs:/app/logs
Expand Down
1 change: 1 addition & 0 deletions docker-compose.test.yml
Expand Up @@ -123,6 +123,7 @@ services:
APPS_REPO_URL: ${APPS_REPO_URL}
DOMAIN: ${DOMAIN}
ARCHITECTURE: ${ARCHITECTURE}
REDIS_HOST: ${REDIS_HOST}
volumes:
- ${PWD}/state:/runtipi/state
- ${PWD}/logs:/app/logs
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Expand Up @@ -119,6 +119,7 @@ services:
APPS_REPO_URL: ${APPS_REPO_URL}
DOMAIN: ${DOMAIN}
ARCHITECTURE: ${ARCHITECTURE}
REDIS_HOST: ${REDIS_HOST}
volumes:
- ${PWD}/state:/runtipi/state
- ${PWD}/logs:/app/logs
Expand Down
1 change: 1 addition & 0 deletions scripts/common.sh
@@ -1,5 +1,6 @@
#!/usr/bin/env bash

ROOT_FOLDER="${PWD}"
# Get field from json file
function get_json_field() {
local json_file="$1"
Expand Down
4 changes: 4 additions & 0 deletions scripts/start-dev.sh
Expand Up @@ -8,6 +8,8 @@ fi

source "${BASH_SOURCE%/*}/common.sh"

clean_logs

### --------------------------------
### General variables
### --------------------------------
Expand All @@ -26,6 +28,7 @@ POSTGRES_USERNAME=tipi
POSTGRES_DBNAME=tipi
POSTGRES_PORT=5432
POSTGRES_HOST=tipi-db
REDIS_HOST=tipi-redis
TIPI_VERSION=$(get_json_field "${ROOT_FOLDER}/package.json" version)
INTERNAL_IP=localhost
storage_path="${ROOT_FOLDER}"
Expand Down Expand Up @@ -109,6 +112,7 @@ for template in ${ENV_FILE}; do
sed "${sed_args[@]}" "s/<postgres_dbname>/${POSTGRES_DBNAME}/g" "${template}"
sed "${sed_args[@]}" "s/<postgres_port>/${POSTGRES_PORT}/g" "${template}"
sed "${sed_args[@]}" "s/<postgres_host>/${POSTGRES_HOST}/g" "${template}"
sed "${sed_args[@]}" "s/<redis_host>/${REDIS_HOST}/g" "${template}"
done

mv -f "$ENV_FILE" "$ROOT_FOLDER/.env.dev"
Expand Down
2 changes: 2 additions & 0 deletions scripts/start.sh
Expand Up @@ -54,6 +54,7 @@ storage_path="${ROOT_FOLDER}"
STORAGE_PATH_ESCAPED="$(echo "${storage_path}" | sed 's/\//\\\//g')"
NETWORK_INTERFACE="$(ip route | grep default | awk '{print $5}' | uniq)"
NETWORK_INTERFACE_COUNT=$(echo "$NETWORK_INTERFACE" | wc -l)
REDIS_HOST=tipi-redis

if [[ "$NETWORK_INTERFACE_COUNT" -eq 0 ]]; then
echo "No network interface found!"
Expand Down Expand Up @@ -233,6 +234,7 @@ for template in ${ENV_FILE}; do
sed -i "s/<apps_repo_url>/${APPS_REPOSITORY_ESCAPED}/g" "${template}"
sed -i "s/<domain>/${DOMAIN}/g" "${template}"
sed -i "s/<storage_path>/${STORAGE_PATH_ESCAPED}/g" "${template}"
sed -i "s/<redis_host>/${REDIS_HOST}/g" "${template}"
done

mv -f "$ENV_FILE" "$ROOT_FOLDER/.env"
Expand Down
1 change: 1 addition & 0 deletions templates/env-sample
Expand Up @@ -19,3 +19,4 @@ POSTGRES_DBNAME=<postgres_dbname>
POSTGRES_USERNAME=<postgres_username>
POSTGRES_PASSWORD=<postgres_password>
POSTGRES_PORT=<postgres_port>
REDIS_HOST=<redis_host>

0 comments on commit 71d106b

Please sign in to comment.