2024-03-03 16:36:46 +01:00
|
|
|
#!/bin/sh
|
2024-03-03 07:02:27 +01:00
|
|
|
|
2024-03-03 16:36:46 +01:00
|
|
|
set -xeu
|
|
|
|
node --version
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
# Check Environment Initialized Flag
|
2024-03-03 16:36:46 +01:00
|
|
|
if [ ! -f '/.firefish_env_initialized' ]; then
|
2024-03-03 07:02:27 +01:00
|
|
|
|
2024-03-11 14:12:50 +01:00
|
|
|
# Install entrypoint dependencies
|
|
|
|
apt-get update
|
|
|
|
DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends wget curl ca-certificates lsb-release gnupg
|
|
|
|
|
|
|
|
# Create the PostgreSQL file repository configuration
|
|
|
|
sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
|
|
|
|
|
|
|
# Import the PostgreSQL repository signing key
|
|
|
|
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
|
|
|
|
|
2024-03-03 07:02:27 +01:00
|
|
|
# Install compilation dependencies
|
2024-03-08 17:24:22 +01:00
|
|
|
apt-get update
|
2024-03-18 16:21:02 +01:00
|
|
|
DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends build-essential python3 ffmpeg git postgresql-client-12
|
2024-03-03 07:02:27 +01:00
|
|
|
curl -vvv --proto '=https' --tlsv1.2 --show-error --fail https://sh.rustup.rs | sh -s -- -y
|
|
|
|
|
|
|
|
# Add Cargo PATH
|
|
|
|
PATH="/root/.cargo/bin:${PATH}"
|
|
|
|
|
2024-03-04 10:09:59 +01:00
|
|
|
# If Firefish not exist
|
2024-03-03 16:36:46 +01:00
|
|
|
if [ ! -f '/firefish/README.md' ]; then
|
2024-03-03 07:02:27 +01:00
|
|
|
|
2024-03-04 10:09:59 +01:00
|
|
|
# Clone Firefish
|
|
|
|
cd /
|
|
|
|
git clone -v https://firefish.dev/firefish/firefish.git
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
# Configuring a new server
|
|
|
|
cd /firefish
|
|
|
|
cp .config/devenv.yml .config/default.yml
|
2024-03-03 16:59:00 +01:00
|
|
|
|
2024-03-03 17:45:25 +01:00
|
|
|
URL="$(echo "${URL}" | sed 's#/#\\/#g')"
|
2024-03-04 10:09:59 +01:00
|
|
|
sed -i'.bak' "s/http:\/\/localhost:3030/${URL}/" .config/default.yml
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Configure postgres, add pgroonga search
|
2024-03-03 18:13:13 +01:00
|
|
|
psql --user=firefish --host=firefish_db --dbname=firefish_db --command='CREATE EXTENSION IF NOT EXISTS pgroonga;'
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
# Configure pnpm, and install dev mode dependencies for compilation
|
|
|
|
cd /firefish
|
|
|
|
corepack enable
|
|
|
|
corepack prepare pnpm@latest --activate
|
2024-03-03 18:13:13 +01:00
|
|
|
pnpm install --prod false
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Add Environment Initialized Flag
|
2024-03-03 16:36:46 +01:00
|
|
|
touch /.firefish_env_initialized
|
2024-03-03 07:02:27 +01:00
|
|
|
|
|
|
|
# Add Cargo PATH
|
|
|
|
PATH="/root/.cargo/bin:${PATH}"
|
|
|
|
|
|
|
|
# Start a new server
|
|
|
|
cd /firefish
|
2024-03-03 18:13:13 +01:00
|
|
|
pnpm install --prod false
|
2024-03-03 16:36:46 +01:00
|
|
|
pnpm run build:debug
|
2024-03-03 07:02:27 +01:00
|
|
|
pnpm run migrate
|
|
|
|
pnpm run start
|