hippofish/dev/manually
2024-03-05 18:05:30 +08:00
..
README.md doc: new env init docs for dev and prod, clear docs, update dependencies 2024-03-05 18:05:30 +08:00

Manually Make Development Environment

For scenarios with special needs, you may want to manually create a development environment. Hope this article can help you.

Introduction

This article is written based on the Debian Bookworm. Other systems can refer to this article for deployment. However, it is recommended that new users use the same system or Docker environment as ours to avoid wasting time on environment configuration issues.

The versions of Node.js, Rust, PostgreSQL, DragonflyDB that come with Debian Bookworm are low or not have, the latest official versions of these components are used to install them. Other components are installed using the apt package manager that comes with the system.

Allow sudo command

su -
apt install -y -V sudo
# user is your username
usermod -aG sudo user
reboot

Install Base Requirements

sudo apt update
sudo apt install -y -V wget curl git ca-certificates

Install Node.js

The latest version at the time of writing is v21.6.2. Please replace it with the latest Node.js version number during installation. Details can be found in nodejs.org .

  1. Download and extract.
VERSION=v21.6.2
DISTRO=linux-x64
sudo mkdir -p /usr/local/lib/nodejs
wget https://nodejs.org/dist/v21.6.2/node-$VERSION-$DISTRO.tar.xz
sudo tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs
  1. Open your .profile and /root/.profile files.
nano ~/.profile
sudo nano /root/.profile
  1. Add below content at below of this two file to set the environment variable.
# Nodejs
VERSION=v21.6.2
DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH
  1. Refresh PATH and test.
. ~/.profile
node -v
# Switching to root
sudo -i
. ~/.profile
node -v
exit

Install Rust

  1. Running this script and choose "Proceed with installation" option.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. ~/.profile
cargo -V

Install PostgreSQL with PGroonga extension

wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
wget https://packages.groonga.org/debian/groonga-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt install -y -V ./groonga-apt-source-latest-$(lsb_release --codename --short).deb
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release --codename --short)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt install -y -V postgresql-16-pgdg-pgroonga

Configuration PostgreSQL

  1. Execute this to running psql as postgres user.
sudo -u postgres psql
  1. Create Firefish database, user and PGroonga extension. Please change the password.
CREATE DATABASE firefish_db WITH ENCODING = 'UTF8';
\connect firefish_db
CREATE EXTENSION IF NOT EXISTS pgroonga;
CREATE USER firefish WITH PASSWORD 'password';
ALTER USER firefish WITH SUPERUSER;
GRANT ALL ON DATABASE firefish_db TO firefish;
  1. Run exit to return.

Install Redis, Python 3 and build-essential

sudo apt update
sudo apt install -y -V redis python3 build-essential

Download and configuration Firefish

  1. Download Firefish and Copy example configuration file.
# cd /path/to/your/firefish
git clone https://firefish.dev/firefish/firefish.git
cd firefish/
cp .config/devenv.yml .config/default.yml
sed -i "s/host: firefish_db/host: localhost/" .config/default.yml
sed -i "s/host: firefish_redis/host: localhost/" .config/default.yml
  1. Open your default.yml files and make changes like URL, db/host redis/host.
nano .config/default.yml

Install package

  1. Let corepack enable.
# Switching to root
sudo -i
# cd /path/to/your/firefish
cd /home/user/firefish
corepack enable
exit
  1. Install dependency.
corepack prepare pnpm@latest --activate
pnpm install --frozen-lockfile --prod false

Start

  1. Build and migrate
pnpm install --prod false
NODE_ENV=production
pnpm run build:debug
pnpm run migrate
  1. Start Firefish
pnpm run start
  1. Wait until the following message shows up.
DONE *  [core boot]     All workers started
DONE *  [core boot]     Now listening on port 3030 on https://your_firefish_url.example.com
  1. A fresh Firefish environment is created on the URL you have set!