|
|
|
@ -14,6 +14,10 @@ setting_up_container |
|
|
|
|
network_check |
|
|
|
|
update_os |
|
|
|
|
|
|
|
|
|
## Following Ghostfolio's Dockerfile and docker-compose for versions/steps, but installing all postgres/redis on the same host |
|
|
|
|
# - https://github.com/ghostfolio/ghostfolio/blob/main/Dockerfile |
|
|
|
|
# - https://github.com/ghostfolio/ghostfolio/blob/main/docker/docker-compose.yml |
|
|
|
|
|
|
|
|
|
msg_info "Installing Dependencies" |
|
|
|
|
$STD apt-get update |
|
|
|
|
$STD apt-get install -y \ |
|
|
|
@ -23,7 +27,7 @@ $STD apt-get install -y \ |
|
|
|
|
msg_ok "Installed Dependencies" |
|
|
|
|
|
|
|
|
|
# POSTGRES ================================= |
|
|
|
|
msg_info "Setting up postgresql" |
|
|
|
|
msg_info "Setting up Postgresql" |
|
|
|
|
|
|
|
|
|
POSTGRES_HOST=localhost |
|
|
|
|
POSTGRES_PORT=5432 |
|
|
|
@ -49,17 +53,17 @@ $STD pg_isready -d "$POSTGRES_DB" -U "$POSTGRES_USER" |
|
|
|
|
$STD psql -d "$DATABASE_URL" -c "select now()" |
|
|
|
|
|
|
|
|
|
# Store creds |
|
|
|
|
echo "" >~/ghostery.creds |
|
|
|
|
echo "Ghostery Database Credentials" >>~/ghostery.creds |
|
|
|
|
echo "" >>~/ghostery.creds |
|
|
|
|
echo -e "ghostery Database User: \e[32m$POSTGRES_USER\e[0m" >>~/ghostery.creds |
|
|
|
|
echo -e "ghostery Database Password: \e[32m$POSTGRES_PASSWORD\e[0m" >>~/ghostery.creds |
|
|
|
|
echo -e "ghostery Database Name: \e[32m$POSTGRES_DB\e[0m" >>~/ghostery.creds |
|
|
|
|
msg_ok "Set up postgresql" |
|
|
|
|
echo "" >~/ghostfolio.creds |
|
|
|
|
echo "Ghostfolio Database Credentials" >>~/ghostfolio.creds |
|
|
|
|
echo "" >>~/ghostfolio.creds |
|
|
|
|
echo -e "Ghostfolio Database User: \e[32m$POSTGRES_USER\e[0m" >>~/ghostfolio.creds |
|
|
|
|
echo -e "Ghostfolio Database Password: \e[32m$POSTGRES_PASSWORD\e[0m" >>~/ghostfolio.creds |
|
|
|
|
echo -e "Ghostfolio Database Name: \e[32m$POSTGRES_DB\e[0m" >>~/ghostfolio.creds |
|
|
|
|
msg_ok "Set up Postgresql" |
|
|
|
|
#-- END POSTGRES |
|
|
|
|
|
|
|
|
|
# REDIS CACHE ================================= |
|
|
|
|
msg_info "Setting up redis" |
|
|
|
|
msg_info "Setting up Redis" |
|
|
|
|
REDIS_HOST=localhost |
|
|
|
|
REDIS_PORT=6379 |
|
|
|
|
REDIS_PASSWORD="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)" |
|
|
|
@ -74,19 +78,19 @@ $STD systemctl restart redis |
|
|
|
|
# Test Redis with password auth |
|
|
|
|
$STD redis-cli -a "$REDIS_PASSWORD" ping |
|
|
|
|
|
|
|
|
|
echo "" >~/ghostery.creds |
|
|
|
|
echo "Ghostery Redis Credentials" >>~/ghostery.creds |
|
|
|
|
echo "" >>~/ghostery.creds |
|
|
|
|
echo -e "ghostery Redis Password: \e[32m$REDIS_PASSWORD\e[0m" >>~/ghostery.creds |
|
|
|
|
echo "" >>~/ghostfolio.creds |
|
|
|
|
echo "Ghostfolio Redis Credentials" >>~/ghostfolio.creds |
|
|
|
|
echo "" >>~/ghostfolio.creds |
|
|
|
|
echo -e "Ghostfolio Redis Password: \e[32m$REDIS_PASSWORD\e[0m" >>~/ghostfolio.creds |
|
|
|
|
|
|
|
|
|
msg_ok "Set up Redis" |
|
|
|
|
#-- END REDIS CACHE |
|
|
|
|
|
|
|
|
|
# GHOSTFOLIO ================================= |
|
|
|
|
## Setup Vars |
|
|
|
|
## default node to 20 (current required version, but determine from nvmrc later) |
|
|
|
|
NODE_VERSION=20 |
|
|
|
|
## read this from the project in a way that doesnt break |
|
|
|
|
GHOSTFOLIO_VERSION='latest' |
|
|
|
|
GHOSTFOLIO_VERSION='latest' # tested with 2.117.0 |
|
|
|
|
|
|
|
|
|
cd /opt/ |
|
|
|
|
|
|
|
|
@ -108,6 +112,7 @@ $STD rm ghostfolio-$GHOSTFOLIO_VERSION.tgz |
|
|
|
|
|
|
|
|
|
cd /opt/ghostfolio-$GHOSTFOLIO_VERSION |
|
|
|
|
|
|
|
|
|
# Get node version and install node |
|
|
|
|
test -f .nvmrc && NODE_VERSION=$(sed 's/^v\([0-9]*\)[.]*.*/\1/g' .nvmrc) # get first digits after an v, excluding potential .minor.patch versions |
|
|
|
|
$STD curl -fsSL https://deb.nodesource.com/setup_$NODE_VERSION.x -o nodesource_setup.sh |
|
|
|
|
$STD bash nodesource_setup.sh |
|
|
|
@ -119,19 +124,14 @@ $STD apt-get install -y --no-install-suggests nodejs |
|
|
|
|
$STD npm install |
|
|
|
|
$STD npm run build:production |
|
|
|
|
|
|
|
|
|
# package.json was generated by the build process, however the original |
|
|
|
|
# package-lock.json needs to be used to ensure the same versions |
|
|
|
|
# curl -o package-lock.json https://raw.githubusercontent.com/ghostfolio/ghostfolio/refs/tags/$GHOSTFOLIO_VERSION/package-lock.json |
|
|
|
|
# package.json was generated by the build process, however the original package-lock.json needs to be used to ensure the same versions |
|
|
|
|
mv /opt/ghostfolio-$GHOSTFOLIO_VERSION/package-lock.json /opt/ghostfolio-$GHOSTFOLIO_VERSION/dist/apps/api/ |
|
|
|
|
#cp package-lock.json dist/apps/api/ |
|
|
|
|
|
|
|
|
|
cd /opt/ghostfolio-$GHOSTFOLIO_VERSION/dist/apps/api/ |
|
|
|
|
$STD npm install |
|
|
|
|
mv /opt/ghostfolio-$GHOSTFOLIO_VERSION/prisma . |
|
|
|
|
|
|
|
|
|
# Overwrite the generated package.json with the original one to ensure having |
|
|
|
|
# all the scripts |
|
|
|
|
# curl -o package.json https://raw.githubusercontent.com/ghostfolio/ghostfolio/refs/tags/$GHOSTFOLIO_VERSION/package.json |
|
|
|
|
# Overwrite the generated package.json with the original one to ensure having all the scripts |
|
|
|
|
mv /opt/ghostfolio-$GHOSTFOLIO_VERSION/package.json /opt/ghostfolio-$GHOSTFOLIO_VERSION/dist/apps/api/ |
|
|
|
|
$STD npm run database:generate-typings |
|
|
|
|
|
|
|
|
@ -148,8 +148,6 @@ rm -rf /opt/ghostfolio-$GHOSTFOLIO_VERSION |
|
|
|
|
# Create env file |
|
|
|
|
msg_info "Creating Environment File" |
|
|
|
|
cat <<EOF >/opt/ghostfolio/api/.env |
|
|
|
|
# Node |
|
|
|
|
NODE_OPTIONS=--max_old_space_size=2048 |
|
|
|
|
# CACHE |
|
|
|
|
REDIS_HOST=$REDIS_HOST |
|
|
|
|
REDIS_PORT=$REDIS_PORT |
|
|
|
|