Merge pull request #45 from meienberger/39-request-allow-setting-default-port-for-tipi

Allow setting default port for tipi
This commit is contained in:
Nicolas Meienberger 2022-05-18 21:06:43 +02:00 committed by GitHub
commit d40c4a50f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 94 additions and 63 deletions

View file

@ -2,6 +2,8 @@
[![License](https://img.shields.io/github/license/meienberger/runtipi)](https://github.com/meienberger/runtipi/blob/master/LICENSE)
[![Version](https://img.shields.io/github/v/release/meienberger/runtipi?color=%235351FB&label=version)](https://github.com/meienberger/runtipi/releases)
![Issues](https://img.shields.io/github/issues/meienberger/runtipi)
[![Docker Pulls](https://badgen.net/docker/pulls/meienberger/tipi-dashboard?icon=docker&label=pulls)](https://hub.docker.com/r/meienberger/tipi-dashboard/)
[![Docker Image Size](https://badgen.net/docker/size/meienberger/tipi-dashboard?icon=docker&label=image%20size)](https://hub.docker.com/r/meienberger/tipi-dashboard/)
![RunsOn](https://img.shields.io/badge/Debian-Supported-green?logo=debian)
![RunsOn](https://img.shields.io/badge/Ubuntu-Supported-green?logo=ubuntu)
![Build](https://github.com/meienberger/runtipi/workflows/Tipi%20CI/badge.svg)
@ -11,7 +13,6 @@
Tipi is a personal homeserver orchestrator. It is running docker containers under the hood and provides a simple web interface to manage them. Every service comes with an opinionated configuration in order to remove the need for manual configuration and network setup.
## Apps available
- [Anonaddy](https://github.com/anonaddy/anonaddy) - Anonymous email forwarding
- [Filebrowser](https://github.com/filebrowser/filebrowser) - Web File Browser
- [Freshrss](https://github.com/FreshRSS/FreshRSS) - A free, self-hostable RSS aggregator
- [Invidious](https://github.com/iv-org/invidious) - An alternative front-end to YouTube
@ -71,3 +72,4 @@ Tipi is licensed under the GNU General Public License v3.0. TL;DR — You may co
## 🗣 Community
- [Matrix](https://matrix.to/#/#runtipi:matrix.org)<br />
- [Twitter](https://twitter.com/runtipi)
- [Telegram](https://t.me/+72-y10MnLBw2ZGI0)

View file

@ -6,8 +6,8 @@ services:
image: traefik:v2.6
restart: always
ports:
- 80:80
- 8080:8080
- ${NGINX_PORT}:80
- ${PROXY_PORT}:8080
command: --api.insecure=true --providers.docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro

View file

@ -6,8 +6,8 @@ services:
image: traefik:v2.6
restart: always
ports:
- 80:80
- 8080:8080
- ${NGINX_PORT}:80
- ${PROXY_PORT}:8080
command: --api.insecure=true --providers.docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
@ -15,7 +15,6 @@ services:
networks:
- tipi_main_network
api:
image: meienberger/tipi-api:${TIPI_VERSION}
container_name: api
@ -30,6 +29,7 @@ services:
- TIPI_VERSION=${TIPI_VERSION}
- JWT_SECRET=${JWT_SECRET}
- ROOT_FOLDER_HOST=${ROOT_FOLDER_HOST}
- NGINX_PORT=${NGINX_PORT}
networks:
- tipi_main_network

View file

@ -11,13 +11,13 @@ interface IConfig {
dotenv.config();
const { NODE_ENV = 'development', JWT_SECRET = '', INTERNAL_IP = '', TIPI_VERSION = '', ROOT_FOLDER_HOST = '' } = process.env;
const { NODE_ENV = 'development', JWT_SECRET = '', INTERNAL_IP = '', TIPI_VERSION = '', ROOT_FOLDER_HOST = '', NGINX_PORT = '80' } = process.env;
const config: IConfig = {
NODE_ENV,
ROOT_FOLDER: '/tipi',
JWT_SECRET,
CLIENT_URLS: ['http://localhost:3000', `http://${INTERNAL_IP}`, `http://${INTERNAL_IP}:3000`],
CLIENT_URLS: ['http://localhost:3000', `http://${INTERNAL_IP}`, `http://${INTERNAL_IP}:${NGINX_PORT}`, `http://${INTERNAL_IP}:3000`],
VERSION: TIPI_VERSION,
ROOT_FOLDER_HOST,
};

View file

@ -1 +0,0 @@
ansible

View file

@ -12,7 +12,7 @@ ROOT_FOLDER="$($rdlk -f $(dirname "${BASH_SOURCE[0]}")/..)"
STATE_FOLDER="${ROOT_FOLDER}/state"
show_help() {
cat << EOF
cat <<EOF
app 0.0.1
CLI for managing Tipi apps
@ -31,10 +31,10 @@ EOF
# Get field from json file
function get_json_field() {
local json_file="$1"
local field="$2"
local json_file="$1"
local field="$2"
echo $(jq -r ".${field}" "${json_file}")
echo $(jq -r ".${field}" "${json_file}")
}
list_installed_apps() {
@ -98,7 +98,7 @@ compose() {
# Pick arm architecture if running on arm and if the app has a docker-compose.arm.yml file
if [[ "$architecture" == "arm"* ]] && [[ -f "${app_dir}/docker-compose.arm.yml" ]]; then
app_compose_file="${app_dir}/docker-compose.arm.yml"
fi
fi
local common_compose_file="${ROOT_FOLDER}/apps/docker-compose.common.yml"
local app_dir="${ROOT_FOLDER}/apps/${app}"
@ -183,4 +183,4 @@ fi
# If we get here it means no valid command was supplied
# Show help and exit
show_help
exit 1
exit 1

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e # Exit immediately if a command exits with a non-zero status.
set -e # Exit immediately if a command exits with a non-zero status.
ROOT_FOLDER="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)"
USERNAME="$(id -nu 1000)"
@ -37,25 +37,25 @@ fi
# Add deb repo for docker (Debian)
if [[ "${LSB}" == "Debian" ]]; then
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
fi
# Add deb repo for docker (Ubuntu)
if [[ "${LSB}" == "Ubuntu" ]]; then
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
fi
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# Install docker compose if not here
if ! command -v docker-compose > /dev/null; then
if ! command -v docker-compose >/dev/null; then
sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
fi
# create docker group
if ! getent group docker > /dev/null; then
if ! getent group docker >/dev/null; then
sudo groupadd docker
fi
sudo usermod -aG docker "${USERNAME}"
@ -65,4 +65,4 @@ sudo usermod -aG docker "${USERNAME}"
# find "$ROOT_FOLDER" -path "$ROOT_FOLDER/app-data" -prune -o -exec chown 1000:1000 {} + || true
# Create configured status
touch "${ROOT_FOLDER}/state/configured"
touch "${ROOT_FOLDER}/state/configured"

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e # Exit immediately if a command exits with a non-zero status.
set -e # Exit immediately if a command exits with a non-zero status.
# use greadlink instead of readlink on osx
if [[ "$(uname)" == "Darwin" ]]; then
@ -8,18 +8,42 @@ else
readlink=readlink
fi
while [ -n "$1" ]; do # while loop starts
NGINX_PORT=80
PROXY_PORT=8080
case "$1" in
--rc) rc="true" ;;
--ci) ci="true" ;;
--)
shift # The double dash makes them parameters
break
;;
*) echo "Option $1 not recognized" && exit 1 ;;
esac
shift
while [ -n "$1" ]; do # while loop starts
case "$1" in
--rc) rc="true" ;;
--ci) ci="true" ;;
--port)
port="$2"
if [[ "${port}" =~ ^[0-9]+$ ]]; then
NGINX_PORT="${port}"
else
echo "--port must be a number"
exit 1
fi
shift
;;
--proxy-port)
proxy_port="$2"
if [[ "${proxy_port}" =~ ^[0-9]+$ ]]; then
PROXY_PORT="${proxy_port}"
else
echo "--proxy-port must be a number"
exit 1
fi
shift
;;
--)
shift # The double dash makes them parameters
break
;;
*) echo "Option $1 not recognized" && exit 1 ;;
esac
shift
done
# Check we are on linux
@ -40,10 +64,10 @@ if [[ "$ARCHITECTURE" == "aarch64" ]]; then
fi
if [[ $UID != 0 ]]; then
echo "Tipi must be started as root"
echo "Please re-run this script as"
echo " sudo ./scripts/start"
exit 1
echo "Tipi must be started as root"
echo "Please re-run this script as"
echo " sudo ./scripts/start"
exit 1
fi
# Configure Tipi if it isn't already configured
@ -53,20 +77,20 @@ fi
# Get field from json file
function get_json_field() {
local json_file="$1"
local field="$2"
local json_file="$1"
local field="$2"
echo $(jq -r ".${field}" "${json_file}")
echo $(jq -r ".${field}" "${json_file}")
}
# Deterministically derives 128 bits of cryptographically secure entropy
function derive_entropy() {
SEED_FILE="${STATE_FOLDER}/seed"
identifier="${1}"
tipi_seed=$(cat "${SEED_FILE}") || true
tipi_seed=$(cat "${SEED_FILE}") || true
if [[ -z "$tipi_seed" ]] || [[ -z "$identifier" ]]; then
>&2 echo "Missing derivation parameter, this is unsafe, exiting."
echo >&2 "Missing derivation parameter, this is unsafe, exiting."
exit 1
fi
@ -107,7 +131,7 @@ fi
# Create seed file with cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
if [[ ! -f "${STATE_FOLDER}/seed" ]]; then
echo "Generating seed..."
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 > "${STATE_FOLDER}/seed"
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 >"${STATE_FOLDER}/seed"
fi
export DOCKER_CLIENT_TIMEOUT=240
@ -136,7 +160,8 @@ for template in "${ENV_FILE}"; do
sed -i "s/<root_folder>/${SED_ROOT_FOLDER}/g" "${template}"
sed -i "s/<tipi_version>/$(cat "${ROOT_FOLDER}/VERSION")/g" "${template}"
sed -i "s/<architecture>/${ARCHITECTURE}/g" "${template}"
sed -i "s/<nginx_port>/${NGINX_PORT}/g" "${template}"
sed -i "s/<proxy_port>/${PROXY_PORT}/g" "${template}"
done
mv -f "$ENV_FILE" "$ROOT_FOLDER/.env"
@ -170,7 +195,7 @@ fi
echo "Tipi is now running"
echo ""
cat << "EOF"
cat <<"EOF"
_,.
,` -.)
'( _/'-\\-.
@ -192,8 +217,12 @@ cat << "EOF"
| {__)
()`
EOF
echo ""
echo "Visit http://${INTERNAL_IP}/ to view the dashboard"
echo ""
port_display=""
if [[ $NGINX_PORT != "80" ]]; then
port_display=":${NGINX_PORT}"
fi
echo ""
echo "Visit http://${INTERNAL_IP}${port_display}/ to view the dashboard"
echo ""

View file

@ -8,12 +8,11 @@ else
readlink=readlink
fi
if [[ $UID != 0 ]]; then
echo "Tipi must be stopped as root"
echo "Please re-run this script as"
echo " sudo ./scripts/stop"
exit 1
echo "Tipi must be stopped as root"
echo "Please re-run this script as"
echo " sudo ./scripts/stop"
exit 1
fi
ROOT_FOLDER="$($readlink -f $(dirname "${BASH_SOURCE[0]}")/..)"
@ -27,10 +26,10 @@ export DOCKER_CLIENT_TIMEOUT=240
export COMPOSE_HTTP_TIMEOUT=240
function get_json_field() {
local json_file="$1"
local field="$2"
local json_file="$1"
local field="$2"
echo $(jq -r ".${field}" "${json_file}")
echo $(jq -r ".${field}" "${json_file}")
}
str=$(get_json_field ${STATE_FOLDER}/apps.json installed)
@ -38,11 +37,11 @@ apps_to_start=($str)
# If apps_to_start is not empty, then we're stopping all apps
if [[ ${#apps_to_start[@]} -gt 0 ]]; then
for app in "${apps_to_start[@]}"; do
"${ROOT_FOLDER}/scripts/app.sh" stop $app
done
for app in "${apps_to_start[@]}"; do
"${ROOT_FOLDER}/scripts/app.sh" stop $app
done
fi
echo "Stopping Docker services..."
echo
docker-compose down --remove-orphans --rmi local
docker-compose down --remove-orphans --rmi local

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e # Exit immediately if a command exits with a non-zero status.
set -e # Exit immediately if a command exits with a non-zero status.
ROOT_FOLDER="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)"
STATE_FOLDER="${ROOT_FOLDER}/state"
@ -19,7 +19,7 @@ MEM_USED_BYTES=$(($MEM_TOTAL_BYTES - $MEM_AVAILABLE_BYTES))
# Create temporary json file
TEMP_JSON_FILE=$(mktemp)
echo '{ "cpu": { "load": '"${CPU_LOAD_PERCENTAGE}"' }, "memory": { "total": '"${MEM_TOTAL_BYTES}"' , "used": '"${MEM_USED_BYTES}"', "available": '"${MEM_AVAILABLE_BYTES}"' }, "disk": { "total": '"${TOTAL_DISK_SPACE_BYTES}"' , "used": '"${USED_DISK_SPACE_BYTES}"', "available": '"${AVAILABLE_DISK_SPACE_BYTES}"' } }' > "${TEMP_JSON_FILE}"
echo '{ "cpu": { "load": '"${CPU_LOAD_PERCENTAGE}"' }, "memory": { "total": '"${MEM_TOTAL_BYTES}"' , "used": '"${MEM_USED_BYTES}"', "available": '"${MEM_AVAILABLE_BYTES}"' }, "disk": { "total": '"${TOTAL_DISK_SPACE_BYTES}"' , "used": '"${USED_DISK_SPACE_BYTES}"', "available": '"${AVAILABLE_DISK_SPACE_BYTES}"' } }' >"${TEMP_JSON_FILE}"
# Write to state file
echo "$(cat "${TEMP_JSON_FILE}")" > "${STATE_FOLDER}/system-info.json"
echo "$(cat "${TEMP_JSON_FILE}")" >"${STATE_FOLDER}/system-info.json"

View file

@ -10,3 +10,5 @@ ARCHITECTURE=<architecture>
TIPI_VERSION=<tipi_version>
JWT_SECRET=<jwt_secret>
ROOT_FOLDER_HOST=<root_folder>
NGINX_PORT=<nginx_port>
PROXY_PORT=<proxy_port>