From 9a63f855675391b961b93ba043b6033f0efcbd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Sun, 3 Mar 2024 14:02:27 +0800 Subject: [PATCH 01/55] feat(dev): add new docker-based dev env to replace broken nix dev env. --- .config/devenv.yml | 33 ++-- .dockerignore | 2 - .envrc | 4 - .gitignore | 4 - dev/docker-compose-onlydb.yml | 17 ++ dev/docker-compose.yml | 39 ++++- dev/docker-entrypoint.sh | 53 ++++++ docs/development.md | 112 ++----------- flake.lock | 294 ---------------------------------- flake.nix | 86 ---------- 10 files changed, 135 insertions(+), 509 deletions(-) delete mode 100644 .envrc create mode 100644 dev/docker-compose-onlydb.yml create mode 100644 dev/docker-entrypoint.sh delete mode 100644 flake.lock delete mode 100644 flake.nix diff --git a/.config/devenv.yml b/.config/devenv.yml index 65b819b569..ee8ab2b17b 100644 --- a/.config/devenv.yml +++ b/.config/devenv.yml @@ -2,31 +2,18 @@ url: http://localhost:3000 port: 3000 db: - host: 127.0.0.1 - port: 5432 + host: db + port: 25432 - db: firefish + db: firefish_db user: firefish - pass: firefish + pass: password redis: - host: localhost - port: 6379 + host: redis + port: 26379 family: 4 -#sonic: -# host: localhost -# port: 1491 -# auth: SecretPassword -# collection: notes -# bucket: default - -#elasticsearch: -# host: localhost -# port: 9200 -# ssl: false -# user: -# pass: id: 'aid' @@ -36,3 +23,11 @@ reservedUsernames: - administrator - me - system + +logLevel: [ + 'error', + 'success', + 'warning', + 'debug', + 'info' +] diff --git a/.dockerignore b/.dockerignore index 2efc98f8fc..f1c6bfd84a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -45,8 +45,6 @@ docker-compose.yml docker-compose.example.yml firefish.apache.conf firefish.nginx.conf -flake.lock -flake.nix title.svg /.gitlab /chart diff --git a/.envrc b/.envrc deleted file mode 100644 index 3ce7171a3c..0000000000 --- a/.envrc +++ /dev/null @@ -1,4 +0,0 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" -fi -use flake . --impure diff --git a/.gitignore b/.gitignore index 2e08a1261e..746aff57c6 100644 --- a/.gitignore +++ b/.gitignore @@ -71,10 +71,6 @@ packages/megalodon/.idea .yarn yarn* -# Nix Development shell items -.devenv -.direnv - # Cargo cache for Docker /.cargo-cache /.cargo-target diff --git a/dev/docker-compose-onlydb.yml b/dev/docker-compose-onlydb.yml new file mode 100644 index 0000000000..d1037fd593 --- /dev/null +++ b/dev/docker-compose-onlydb.yml @@ -0,0 +1,17 @@ +version: "3" + +services: + redis: + image: docker.io/redis:7-alpine + ports: + - "26379:6379" + db: + image: docker.io/groonga/pgroonga:latest-alpine-16-slim + environment: + - "POSTGRES_PASSWORD=password" + - "POSTGRES_USER=firefish" + - "POSTGRES_DB=firefish_db" + ports: + - "25432:5432" + volumes: + - "./install.sql:/docker-entrypoint-initdb.d/install.sql:ro" diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml index d1037fd593..b07352e60e 100644 --- a/dev/docker-compose.yml +++ b/dev/docker-compose.yml @@ -1,12 +1,44 @@ version: "3" services: + web: + image: docker.io/node:21-slim + container_name: firefish_web + restart: unless-stopped + depends_on: + - db + - redis + ports: + - "3000:3000" + networks: + - firefishnet + environment: + # Currently bug in the development env and it cannot run. + NODE_ENV: production + PGPASSWORD: password + URL: http://localhost:3000 + volumes: + - ./firefish:/firefish:rw + - ./docker-entrypoint.sh:/docker-entrypoint.sh:rw + entrypoint: /docker-entrypoint.sh + redis: - image: docker.io/redis:7-alpine + restart: unless-stopped + image: docker.io/redis:7.0-alpine + container_name: firefish_redis + networks: + - firefishnet ports: - "26379:6379" + volumes: + - ./redis:/data + db: + restart: unless-stopped image: docker.io/groonga/pgroonga:latest-alpine-16-slim + container_name: firefish_db + networks: + - firefishnet environment: - "POSTGRES_PASSWORD=password" - "POSTGRES_USER=firefish" @@ -14,4 +46,7 @@ services: ports: - "25432:5432" volumes: - - "./install.sql:/docker-entrypoint-initdb.d/install.sql:ro" + - ./db:/var/lib/postgresql/data + +networks: + firefishnet: diff --git a/dev/docker-entrypoint.sh b/dev/docker-entrypoint.sh new file mode 100644 index 0000000000..11f6f0b51a --- /dev/null +++ b/dev/docker-entrypoint.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +set -xe +node -v + +# Check Environment Initialized Flag +if [ ! -f "/initialized_flag.txt" ];then + + # Install compilation dependencies + apt-get update + DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends curl build-essential ca-certificates python3 postgresql-client-15 + curl -vvv --proto '=https' --tlsv1.2 --show-error --fail https://sh.rustup.rs | sh -s -- -y + + # Add Cargo PATH + PATH="/root/.cargo/bin:${PATH}" + + if [ ! -f "/firefish/README.md" ];then + + # Download Firefish and decompress + curl -vvv -O --proto '=https' --tlsv1.2 --show-error --fail https://firefish.dev/firefish/firefish/-/archive/develop/firefish-develop.tar.bz2 + tar -xjvf firefish-develop.tar.bz2 --strip-components 1 -C /firefish + + # Configuring a new server + cd /firefish + cp .config/devenv.yml .config/default.yml + URL=${URL//\//\\\/} + sed -i "s/http:\/\/localhost:3000/${URL}/g" .config/default.yml + + fi + + # Configure postgres, add pgroonga search + psql -U firefish -p 25432 -h db -c "CREATE EXTENSION pgroonga IF NOT EXISTS;" + + # Configure pnpm, and install dev mode dependencies for compilation + cd /firefish + corepack enable + corepack prepare pnpm@latest --activate + pnpm install --prod false + +fi + +# Add Environment Initialized Flag +touch /initialized_flag.txt + +# Add Cargo PATH +PATH="/root/.cargo/bin:${PATH}" + +# Start a new server +cd /firefish +pnpm install --prod false +pnpm run build +pnpm run migrate +pnpm run start diff --git a/docs/development.md b/docs/development.md index 797c8273ee..f55a817f1e 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1,108 +1,24 @@ # Firefish Developer Docs -## Nix Dev Environment -The Firefish repo comes with a Nix-based shell environment to help make development as easy as possible! +## Docker-based Environment -Please note, however, that this environment will not work on Windows outside of a WSL2 environment. +The Firefish repo comes with a new Docker-based environment to help make development as easy as possible! ### Prerequisites -- Installed the [Nix Package Manager](https://nixos.org/download.html) (use the comman on their website) -- Installed [direnv](https://direnv.net/docs/installation.html) and added its hook to your shell. (package manager) +- Installed [Docker](https://docs.docker.com/get-docker/) (use the comman on their website) . +- If your Docker version is older, you may also need to manually install Docker Compose, and in the following instructions +`docker compose` should be replaced with `docker-compose` . +- It is necessary to confirm that port 3000, 25432 and 26379 are not used by other programs or services. -Once the repo is cloned to your computer, follow these next few steps inside the Firefish folder: +Once Docker is installed to your computer, follow these next few steps to running: -- Run `direnv allow`. This will build the environment and install all needed tools. -- Run `install-deps`, then `prepare-config`, to install the node dependencies and prepare the needed config files. -- In a second terminal, run `devenv up`. This will spawn a **Redis** server, a **Postgres** server, and the **Firefish** server in dev mode. -- Once you see the Firefish banner printed in your second terminal, run `migrate` in the first. -- Once migrations finish, open http://localhost:3000 in your web browser. +- Download `docker-compose.yml` and `docker-entrypoint.sh` in dev folder to the new folder on your computer. +- If you are not running on your PC, open `docker-compose.yml`, set `URL` and save. +- Run `chmod 777 docker-entrypoint.sh`, for initialization script can be execute. +- Run `docker compose up`, This will build the environment, dependencies and prepare the needed config files. +- Once you see the Firefish banner printed in your screen, means initialization finished. +- Open http://localhost:3000 or `URL` on `docker-compose.yml` in your web browser. - You should now see the admin user creation screen! -Note: When you want to restart a dev server, all you need to do is run `devenv up`, no other steps are necessary. - -# Possible Troubles with the dev enviroment -(this doesn't have to be done under normal conditions, this is for future reference) - -### direnv -If you have any trouble with `direnv allow` -Check that the contents of `.envrc` have the same version of nix-direnv that is specified here: -> nix-direnv under -> installation -> using direnv source url -> https://github.com/nix-community/nix-direnv#direnv-source_url - -there should be no errors during `direnv allow` - -### outdated nix packages -if `install-deps` or any subsequent command doesn't run due to versioning problems -`flake.nix` and `flake.lock` may be outdated - -delete `flake.lock`, or better, run `nix flake update --extra-experimental-features flakes --extra-experimental-features nix-command` -after that, run `direnv rebuild` - -if there are any errors, you might have to change `flake.nix` -(because the available options can change between versions - consider getting support in [the matrix channel](https://matrix.to/#/#firefish-community:nitro.chat)) - -### after changing a node version -in my case, i had to change the node version from 19, to 18 - -! before proceeding, make sure to delete all build artifacts! -remove `node_modules` and `built` folders, and maybe `.devenv` and `.direnv` as well -manually, or run `npm cache clean --force` and `pnpm cleanall` - -### Windows Subsystem for Linux -if `devenv up` terminates because of wrong folder permissions, - -create the file `/etc/wsl.conf` in your distro and add -```shell -[automount] -options = "metadata" -``` - -this allows `chmod` calls to actually have an effect. -the build scripts DO actually set the permissions, it just needs to work in wsl. - -### devenv up -devenv up may take a looong time. (some say this is fake news, maybe it was bad luck in my case) - -do not get spooked by this error: -``` -> firefish@14.0.0-dev32 start /mnt/.../firefish -> pnpm --filter backend run start - - -> backend@ start /mnt/.../firefish/packages/backend -> pnpm node ./built/index.js - -node:internal/modules/cjs/loader:1078 - throw err; - ^ - -Error: Cannot find module '/mnt/.../firefish/packages/backend/built/index.js' - at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15) - at Module._load (node:internal/modules/cjs/loader:920:27) - at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) - at node:internal/main/run_main_module:23:47 { - code: 'MODULE_NOT_FOUND', - requireStack: [] -} - -Node.js v18.16.0 -undefined -/mnt/.../firefish/packages/backend: - ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  backend@ start: `pnpm node ./built/index.js` -Exit status 1 - ELIFECYCLE  Command failed with exit code 1. -``` - -the script is designed to constantly try to start the server, while the build is still running. -this just means that the build isn't finished yet. - -at some point you should see a banner that says "Firefish" in big letters - -then you're good to go and can run `migrate` (in another terminal)! - -if you don't see the banner, -and it's for some reason stuck on `Finished 'build' after 917 ms` for a view minutes, - -just leave devenv running and open another terminal in the folder -run `migrate` and then `pnpm --filter backend run start` by yourself -the server should start +Note: When you want to restart a dev server, all you need to do is press `Ctrl+C` and run `docker compose up`, no other steps are necessary. diff --git a/flake.lock b/flake.lock deleted file mode 100644 index f1ff690415..0000000000 --- a/flake.lock +++ /dev/null @@ -1,294 +0,0 @@ -{ - "nodes": { - "devenv": { - "inputs": { - "flake-compat": "flake-compat", - "nix": "nix", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks" - }, - "locked": { - "lastModified": 1685521914, - "narHash": "sha256-0fdFP5IASLwJ0PSXrErW8PZon9TVYmi8VRF8OtjGkV4=", - "owner": "cachix", - "repo": "devenv", - "rev": "e206d8f2e3e8d6aa943656052f15bdfea8146b8d", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "devenv", - "type": "github" - } - }, - "fenix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "rust-analyzer-src": "rust-analyzer-src" - }, - "locked": { - "lastModified": 1685514167, - "narHash": "sha256-urRxF0ZGSNeZjM4kALNg3wTh7fBscbqQmS6S/HU7Wms=", - "owner": "nix-community", - "repo": "fenix", - "rev": "3abfea51663583186f687c49a157eab1639349ca", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "fenix", - "type": "github" - } - }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1685457039, - "narHash": "sha256-bEFtQm+YyLxQjKQAaBHJyPN1z2wbhBnr2g1NJWSYjwM=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "80717d11615b6f42d1ad2e18ead51193fc15de69", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-utils": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "devenv", - "pre-commit-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "lowdown-src": { - "flake": false, - "locked": { - "lastModified": 1633514407, - "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", - "owner": "kristapsdz", - "repo": "lowdown", - "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", - "type": "github" - }, - "original": { - "owner": "kristapsdz", - "repo": "lowdown", - "type": "github" - } - }, - "nix": { - "inputs": { - "lowdown-src": "lowdown-src", - "nixpkgs": [ - "devenv", - "nixpkgs" - ], - "nixpkgs-regression": "nixpkgs-regression" - }, - "locked": { - "lastModified": 1676545802, - "narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=", - "owner": "domenkozar", - "repo": "nix", - "rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f", - "type": "github" - }, - "original": { - "owner": "domenkozar", - "ref": "relaxed-flakes", - "repo": "nix", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1678875422, - "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-lib": { - "locked": { - "dir": "lib", - "lastModified": 1682879489, - "narHash": "sha256-sASwo8gBt7JDnOOstnps90K1wxmVfyhsTPPNTGBPjjg=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "da45bf6ec7bbcc5d1e14d3795c025199f28e0de0", - "type": "github" - }, - "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-regression": { - "locked": { - "lastModified": 1643052045, - "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - } - }, - "nixpkgs-stable": { - "locked": { - "lastModified": 1678872516, - "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-22.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1685399834, - "narHash": "sha256-Lt7//5snriXSdJo5hlVcDkpERL1piiih0UXIz1RUcC4=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "58c85835512b0db938600b6fe13cc3e3dc4b364e", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "pre-commit-hooks": { - "inputs": { - "flake-compat": [ - "devenv", - "flake-compat" - ], - "flake-utils": "flake-utils", - "gitignore": "gitignore", - "nixpkgs": [ - "devenv", - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable" - }, - "locked": { - "lastModified": 1682596858, - "narHash": "sha256-Hf9XVpqaGqe/4oDGr30W8HlsWvJXtMsEPHDqHZA6dDg=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "fb58866e20af98779017134319b5663b8215d912", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, - "root": { - "inputs": { - "devenv": "devenv", - "fenix": "fenix", - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs_2" - } - }, - "rust-analyzer-src": { - "flake": false, - "locked": { - "lastModified": 1685465261, - "narHash": "sha256-aJ2nUinUrNcFi+pb47bS5IIAeSiUEEPLJY8W4Q8Pcjk=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "d2b3caa5b5694125fad04a9699e919444439f6a2", - "type": "github" - }, - "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 60e2d54a25..0000000000 --- a/flake.nix +++ /dev/null @@ -1,86 +0,0 @@ -{ - description = "Firefish development flake"; - - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - # Flake Parts framework(https://flake.parts) - flake-parts.url = "github:hercules-ci/flake-parts"; - # Devenv for better devShells(https://devenv.sh) - devenv.url = "github:cachix/devenv"; - # Fenix for rust development - fenix.url = "github:nix-community/fenix"; - fenix.inputs.nixpkgs.follows = "nixpkgs"; - }; - outputs = inputs@{ flake-parts, ... }: - flake-parts.lib.mkFlake { inherit inputs; } { - imports = [ - inputs.devenv.flakeModule - ]; - - # Define the systems that this works on. Only tested with x66_64-linux, add more if you test and it works. - systems = [ - "x86_64-linux" - ]; - # Expose these attributes for every system defined above. - perSystem = { config, pkgs, ... }: { - # Devenv shells - devenv = { - shells = { - # The default shell, used by nix-direnv - default = { - name = "firefish-dev-shell"; - # Add additional packages to our environment - packages = [ - pkgs.nodePackages.pnpm - - pkgs.python3 - ]; - # No need to warn on a new version, we'll update as needed. - devenv.warnOnNewVersion = false; - # Enable typescript support - languages.typescript.enable = true; - # Enable javascript for NPM and PNPM - languages.javascript.enable = true; - languages.javascript.package = pkgs.nodejs_18; - # Enable stable Rust for the backend - languages.rust.enable = true; - languages.rust.version = "stable"; - processes = { - dev-server.exec = "pnpm run dev"; - }; - scripts = { - build.exec = "pnpm run build"; - clean.exec = "pnpm run clean"; - clear-state.exec = "rm -rf .devenv/state/redis .devenv/state/postgres"; - format.exec = "pnpm run format"; - install-deps.exec = "pnpm install"; - migrate.exec = "pnpm run migrate"; - prepare-config.exec = "cp .config/devenv.yml .config/default.yml"; - }; - services = { - postgres = { - enable = true; - package = pkgs.postgresql_12; - initialDatabases = [{ - name = "firefish"; - }]; - initialScript = '' - CREATE USER firefish WITH PASSWORD 'firefish'; - ALTER USER firefish WITH SUPERUSER; - GRANT ALL ON DATABASE firefish TO firefish; - ''; - listen_addresses = "127.0.0.1"; - port = 5432; - }; - redis = { - enable = true; - bind = "127.0.0.1"; - port = 6379; - }; - }; - }; - }; - }; - }; - }; -} From cc33cfbb3ee6f9b54c9392c568f6030d9ee0057c Mon Sep 17 00:00:00 2001 From: naskya Date: Sun, 3 Mar 2024 18:57:56 +0900 Subject: [PATCH 02/55] fix (dev): fix dev:{up,down,init} scripts --- ...docker-compose-onlydb.yml => docker-compose-dbonly.yml} | 0 scripts/dev-down.mjs | 6 +++++- scripts/dev-up.mjs | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) rename dev/{docker-compose-onlydb.yml => docker-compose-dbonly.yml} (100%) diff --git a/dev/docker-compose-onlydb.yml b/dev/docker-compose-dbonly.yml similarity index 100% rename from dev/docker-compose-onlydb.yml rename to dev/docker-compose-dbonly.yml diff --git a/scripts/dev-down.mjs b/scripts/dev-down.mjs index 97d9cd3515..8c7a83435a 100644 --- a/scripts/dev-down.mjs +++ b/scripts/dev-down.mjs @@ -5,7 +5,11 @@ import { execa } from "execa"; (async () => { const __dirname = path.dirname(fileURLToPath(import.meta.url)); - execa("podman-compose", ["down"], { + execa("podman-compose", [ + "--file", + "docker-compose-dbonly.yml", + "down", + ], { cwd: join(__dirname, "/../dev"), stdio: "inherit", }); diff --git a/scripts/dev-up.mjs b/scripts/dev-up.mjs index c2de8717a3..166c8dbad3 100644 --- a/scripts/dev-up.mjs +++ b/scripts/dev-up.mjs @@ -5,7 +5,12 @@ import { execa } from "execa"; (async () => { const __dirname = path.dirname(fileURLToPath(import.meta.url)); - execa("podman-compose", ["up", "--detach"], { + execa("podman-compose", [ + "--file", + "docker-compose-dbonly.yml", + "up", + "--detach", + ], { cwd: join(__dirname, "/../dev"), stdio: "inherit", }); From d139b0dd1f7a59758188c20d60c66e482e6dc7f7 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 00:36:46 +0900 Subject: [PATCH 03/55] chore (dev): minor refactor in dev/docker-entrypoint.sh --- dev/docker-entrypoint.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) mode change 100644 => 100755 dev/docker-entrypoint.sh diff --git a/dev/docker-entrypoint.sh b/dev/docker-entrypoint.sh old mode 100644 new mode 100755 index 11f6f0b51a..2f2e6b38f0 --- a/dev/docker-entrypoint.sh +++ b/dev/docker-entrypoint.sh @@ -1,10 +1,10 @@ -#!/bin/bash +#!/bin/sh -set -xe -node -v +set -xeu +node --version # Check Environment Initialized Flag -if [ ! -f "/initialized_flag.txt" ];then +if [ ! -f '/.firefish_env_initialized' ]; then # Install compilation dependencies apt-get update @@ -14,7 +14,7 @@ if [ ! -f "/initialized_flag.txt" ];then # Add Cargo PATH PATH="/root/.cargo/bin:${PATH}" - if [ ! -f "/firefish/README.md" ];then + if [ ! -f '/firefish/README.md' ]; then # Download Firefish and decompress curl -vvv -O --proto '=https' --tlsv1.2 --show-error --fail https://firefish.dev/firefish/firefish/-/archive/develop/firefish-develop.tar.bz2 @@ -23,31 +23,32 @@ if [ ! -f "/initialized_flag.txt" ];then # Configuring a new server cd /firefish cp .config/devenv.yml .config/default.yml - URL=${URL//\//\\\/} - sed -i "s/http:\/\/localhost:3000/${URL}/g" .config/default.yml + URL="$(echo "${URL}" | sed 's#/#\\/#g')" + sed -i'.bak' "s/http:\/\/localhost:3000/${URL}/g" .config/default.yml + rm .config/defaut.yml.bak fi # Configure postgres, add pgroonga search - psql -U firefish -p 25432 -h db -c "CREATE EXTENSION pgroonga IF NOT EXISTS;" + psql -U firefish -p 25432 -h db -c 'CREATE EXTENSION pgroonga IF NOT EXISTS;' # Configure pnpm, and install dev mode dependencies for compilation cd /firefish corepack enable corepack prepare pnpm@latest --activate - pnpm install --prod false + pnpm install fi # Add Environment Initialized Flag -touch /initialized_flag.txt +touch /.firefish_env_initialized # Add Cargo PATH PATH="/root/.cargo/bin:${PATH}" # Start a new server cd /firefish -pnpm install --prod false -pnpm run build +pnpm install +pnpm run build:debug pnpm run migrate pnpm run start From 90a33b23711cf30628cbdcc178687c5fbf848d55 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 00:59:00 +0900 Subject: [PATCH 04/55] chore (dev): check if URL has been set in dev/docker-entrypoint.sh --- dev/docker-entrypoint.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dev/docker-entrypoint.sh b/dev/docker-entrypoint.sh index 2f2e6b38f0..5d083cf728 100755 --- a/dev/docker-entrypoint.sh +++ b/dev/docker-entrypoint.sh @@ -23,9 +23,12 @@ if [ ! -f '/.firefish_env_initialized' ]; then # Configuring a new server cd /firefish cp .config/devenv.yml .config/default.yml - URL="$(echo "${URL}" | sed 's#/#\\/#g')" - sed -i'.bak' "s/http:\/\/localhost:3000/${URL}/g" .config/default.yml - rm .config/defaut.yml.bak + + if [ -n "${URL-}" ]; then + URL="$(echo "${URL}" | sed 's#/#\\/#g')" + sed -i'.bak' "s/http:\/\/localhost:3000/${URL}/g" .config/default.yml + rm .config/defaut.yml.bak + fi fi From 421d51b34dc09e2058243b5a928015963f11417d Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 01:35:31 +0900 Subject: [PATCH 05/55] chore (dev): update docs about containerized environment --- dev/docker-entrypoint.sh | 10 +++++----- docs/development.md | 36 +++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/dev/docker-entrypoint.sh b/dev/docker-entrypoint.sh index 5d083cf728..1b278c18ec 100755 --- a/dev/docker-entrypoint.sh +++ b/dev/docker-entrypoint.sh @@ -3,6 +3,8 @@ set -xeu node --version +FIREFISH_URL='http://localhost:3000' + # Check Environment Initialized Flag if [ ! -f '/.firefish_env_initialized' ]; then @@ -24,11 +26,9 @@ if [ ! -f '/.firefish_env_initialized' ]; then cd /firefish cp .config/devenv.yml .config/default.yml - if [ -n "${URL-}" ]; then - URL="$(echo "${URL}" | sed 's#/#\\/#g')" - sed -i'.bak' "s/http:\/\/localhost:3000/${URL}/g" .config/default.yml - rm .config/defaut.yml.bak - fi + URL="$(echo "${FIREFISH_URL}" | sed 's#/#\\/#g')" + sed -i'.bak' "s/http:\/\/localhost:3000/${URL}/g" .config/default.yml + rm .config/defaut.yml.bak fi diff --git a/docs/development.md b/docs/development.md index f55a817f1e..e9e1e1abd3 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1,24 +1,30 @@ # Firefish Developer Docs -## Docker-based Environment +## Containerized Environment -The Firefish repo comes with a new Docker-based environment to help make development as easy as possible! +The Firefish repo comes with a new containerized environment to help make development! ### Prerequisites -- Installed [Docker](https://docs.docker.com/get-docker/) (use the comman on their website) . -- If your Docker version is older, you may also need to manually install Docker Compose, and in the following instructions -`docker compose` should be replaced with `docker-compose` . -- It is necessary to confirm that port 3000, 25432 and 26379 are not used by other programs or services. +- Latest [Docker](https://docs.docker.com/get-docker/) installation + - Alternatively, you can use [Podman](https://podman.io/docs/installation) and [Podman Compose](https://github.com/containers/podman-compose). +- The following ports are not in use + - 3000 + - 25432 + - 26379 -Once Docker is installed to your computer, follow these next few steps to running: +### Start up the environment -- Download `docker-compose.yml` and `docker-entrypoint.sh` in dev folder to the new folder on your computer. -- If you are not running on your PC, open `docker-compose.yml`, set `URL` and save. -- Run `chmod 777 docker-entrypoint.sh`, for initialization script can be execute. -- Run `docker compose up`, This will build the environment, dependencies and prepare the needed config files. -- Once you see the Firefish banner printed in your screen, means initialization finished. -- Open http://localhost:3000 or `URL` on `docker-compose.yml` in your web browser. -- You should now see the admin user creation screen! +1. Run `git clone https://firefish.dev/firefish/firefish.git && cd firefish` to fetch needed files. + - If you don't want to clone the entire repository, you can just download the [`dev` directory](https://firefish.dev/firefish/firefish/-/tree/develop/dev) and execute `chmod +x dev/docker-entrypoint.sh`. +1. Open `dev/docker-compose.yml` and set `FIREFISH_URL` to the URL you want to use (or leave it to `http://localhost:3000`). +1. Run `docker compose --file dev/docker-compose.yml up`. This will build the environment, dependencies and prepare the needed config files. + - If you use Podman, you should run `podman-compose --file dev/docker-compose.yml up` instead. +1. Wait until the following message shows up. + ``` + DONE * [core boot] All workers started + DONE * [core boot] Now listening on port 3000 on https://your_firefish_url.example.com + ``` +1. A fresh Firefish environment is created on the URL you have set! -Note: When you want to restart a dev server, all you need to do is press `Ctrl+C` and run `docker compose up`, no other steps are necessary. +When you want to restart the dev server, you just need to terminate the process (a.k.a. press `Ctrl+C`) and run `docker compose up` again. From 05fa00b58656091dba87e9ca4157957af3283066 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 01:43:59 +0900 Subject: [PATCH 06/55] chore (dev): change web port from 3000 to an uncommon port to avoid collisions --- .config/devenv.yml | 4 ++-- dev/docker-compose.yml | 4 ++-- dev/docker-entrypoint.sh | 4 ++-- docs/development.md | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.config/devenv.yml b/.config/devenv.yml index ee8ab2b17b..2b9301fcfc 100644 --- a/.config/devenv.yml +++ b/.config/devenv.yml @@ -1,5 +1,5 @@ -url: http://localhost:3000 -port: 3000 +url: http://localhost:3030 +port: 3030 db: host: db diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml index b07352e60e..1a255caa7a 100644 --- a/dev/docker-compose.yml +++ b/dev/docker-compose.yml @@ -9,14 +9,14 @@ services: - db - redis ports: - - "3000:3000" + - "3030:3030" networks: - firefishnet environment: # Currently bug in the development env and it cannot run. NODE_ENV: production PGPASSWORD: password - URL: http://localhost:3000 + URL: http://localhost:3030 volumes: - ./firefish:/firefish:rw - ./docker-entrypoint.sh:/docker-entrypoint.sh:rw diff --git a/dev/docker-entrypoint.sh b/dev/docker-entrypoint.sh index 1b278c18ec..c498dd3297 100755 --- a/dev/docker-entrypoint.sh +++ b/dev/docker-entrypoint.sh @@ -3,7 +3,7 @@ set -xeu node --version -FIREFISH_URL='http://localhost:3000' +FIREFISH_URL='http://localhost:3030' # Check Environment Initialized Flag if [ ! -f '/.firefish_env_initialized' ]; then @@ -27,7 +27,7 @@ if [ ! -f '/.firefish_env_initialized' ]; then cp .config/devenv.yml .config/default.yml URL="$(echo "${FIREFISH_URL}" | sed 's#/#\\/#g')" - sed -i'.bak' "s/http:\/\/localhost:3000/${URL}/g" .config/default.yml + sed -i'.bak' "s/http:\/\/localhost:3030/${URL}/g" .config/default.yml rm .config/defaut.yml.bak fi diff --git a/docs/development.md b/docs/development.md index e9e1e1abd3..b87e0e1e70 100644 --- a/docs/development.md +++ b/docs/development.md @@ -9,7 +9,7 @@ The Firefish repo comes with a new containerized environment to help make develo - Latest [Docker](https://docs.docker.com/get-docker/) installation - Alternatively, you can use [Podman](https://podman.io/docs/installation) and [Podman Compose](https://github.com/containers/podman-compose). - The following ports are not in use - - 3000 + - 3030 - 25432 - 26379 @@ -17,13 +17,13 @@ The Firefish repo comes with a new containerized environment to help make develo 1. Run `git clone https://firefish.dev/firefish/firefish.git && cd firefish` to fetch needed files. - If you don't want to clone the entire repository, you can just download the [`dev` directory](https://firefish.dev/firefish/firefish/-/tree/develop/dev) and execute `chmod +x dev/docker-entrypoint.sh`. -1. Open `dev/docker-compose.yml` and set `FIREFISH_URL` to the URL you want to use (or leave it to `http://localhost:3000`). +1. Open `dev/docker-compose.yml` and set `FIREFISH_URL` to the URL you want to use (or leave it to `http://localhost:3030`). 1. Run `docker compose --file dev/docker-compose.yml up`. This will build the environment, dependencies and prepare the needed config files. - If you use Podman, you should run `podman-compose --file dev/docker-compose.yml up` instead. 1. Wait until the following message shows up. ``` DONE * [core boot] All workers started - DONE * [core boot] Now listening on port 3000 on https://your_firefish_url.example.com + 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! From 95baffff63ce5d80bfbcef0dde4e47f1b950681a Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 01:45:25 +0900 Subject: [PATCH 07/55] fix (dev): FIREFISH_URL is a redundant variable --- dev/docker-entrypoint.sh | 4 +--- docs/development.md | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dev/docker-entrypoint.sh b/dev/docker-entrypoint.sh index c498dd3297..bc979a60ae 100755 --- a/dev/docker-entrypoint.sh +++ b/dev/docker-entrypoint.sh @@ -3,8 +3,6 @@ set -xeu node --version -FIREFISH_URL='http://localhost:3030' - # Check Environment Initialized Flag if [ ! -f '/.firefish_env_initialized' ]; then @@ -26,7 +24,7 @@ if [ ! -f '/.firefish_env_initialized' ]; then cd /firefish cp .config/devenv.yml .config/default.yml - URL="$(echo "${FIREFISH_URL}" | sed 's#/#\\/#g')" + URL="$(echo "${URL}" | sed 's#/#\\/#g')" sed -i'.bak' "s/http:\/\/localhost:3030/${URL}/g" .config/default.yml rm .config/defaut.yml.bak diff --git a/docs/development.md b/docs/development.md index b87e0e1e70..1c8dd85cfd 100644 --- a/docs/development.md +++ b/docs/development.md @@ -17,7 +17,7 @@ The Firefish repo comes with a new containerized environment to help make develo 1. Run `git clone https://firefish.dev/firefish/firefish.git && cd firefish` to fetch needed files. - If you don't want to clone the entire repository, you can just download the [`dev` directory](https://firefish.dev/firefish/firefish/-/tree/develop/dev) and execute `chmod +x dev/docker-entrypoint.sh`. -1. Open `dev/docker-compose.yml` and set `FIREFISH_URL` to the URL you want to use (or leave it to `http://localhost:3030`). +1. Open `dev/docker-compose.yml` and set `URL` to the URL you want to use (or leave it to `http://localhost:3030`). 1. Run `docker compose --file dev/docker-compose.yml up`. This will build the environment, dependencies and prepare the needed config files. - If you use Podman, you should run `podman-compose --file dev/docker-compose.yml up` instead. 1. Wait until the following message shows up. From 3043d94f7f555b775610c58e160d8bfc8bd0b8b4 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 01:50:17 +0900 Subject: [PATCH 08/55] chore (dev): gitignore dev/firefish --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 746aff57c6..6919e197ee 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,8 @@ packages/backend/assets/LICENSE packages/megalodon/lib packages/megalodon/.idea +dev/firefish + # blender backups *.blend1 *.blend2 From fd1e18d01bd7d0d2424a55236b2be653feceae20 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 02:13:13 +0900 Subject: [PATCH 09/55] fix (dev): fix SQL syntax, add back --prod false --- dev/docker-entrypoint.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dev/docker-entrypoint.sh b/dev/docker-entrypoint.sh index bc979a60ae..541c304ea6 100755 --- a/dev/docker-entrypoint.sh +++ b/dev/docker-entrypoint.sh @@ -25,19 +25,18 @@ if [ ! -f '/.firefish_env_initialized' ]; then cp .config/devenv.yml .config/default.yml URL="$(echo "${URL}" | sed 's#/#\\/#g')" - sed -i'.bak' "s/http:\/\/localhost:3030/${URL}/g" .config/default.yml - rm .config/defaut.yml.bak + sed -i'.bak' "s/http:\/\/localhost:3030/${URL}/" .config/default.yml fi # Configure postgres, add pgroonga search - psql -U firefish -p 25432 -h db -c 'CREATE EXTENSION pgroonga IF NOT EXISTS;' + psql --user=firefish --host=firefish_db --dbname=firefish_db --command='CREATE EXTENSION IF NOT EXISTS pgroonga;' # Configure pnpm, and install dev mode dependencies for compilation cd /firefish corepack enable corepack prepare pnpm@latest --activate - pnpm install + pnpm install --prod false fi @@ -49,7 +48,7 @@ PATH="/root/.cargo/bin:${PATH}" # Start a new server cd /firefish -pnpm install +pnpm install --prod false pnpm run build:debug pnpm run migrate pnpm run start From f90712d62444289f7be6458f6a8cb9d1d8b2d2d6 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 02:16:28 +0900 Subject: [PATCH 10/55] fix (dev): fix hostname, minimize devenv config --- .config/devenv.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.config/devenv.yml b/.config/devenv.yml index 2b9301fcfc..b3bbf7b27c 100644 --- a/.config/devenv.yml +++ b/.config/devenv.yml @@ -2,28 +2,19 @@ url: http://localhost:3030 port: 3030 db: - host: db + host: firefish_db port: 25432 db: firefish_db - user: firefish pass: password redis: - host: redis + host: firefish_redis port: 26379 - family: 4 id: 'aid' -reservedUsernames: - - root - - admin - - administrator - - me - - system - logLevel: [ 'error', 'success', From 83056f46edbd858ade541adcd6d4f44791a547db Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 02:31:18 +0900 Subject: [PATCH 11/55] chore (dev): make sure to use same PostgreSQL image version with postgresql-client --- dev/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml index 1a255caa7a..037ed4f8ff 100644 --- a/dev/docker-compose.yml +++ b/dev/docker-compose.yml @@ -35,7 +35,7 @@ services: db: restart: unless-stopped - image: docker.io/groonga/pgroonga:latest-alpine-16-slim + image: docker.io/groonga/pgroonga:latest-alpine-15-slim container_name: firefish_db networks: - firefishnet From 7edef25b4746d5cd092125b048e74fce6fe14448 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 02:33:46 +0900 Subject: [PATCH 12/55] chore (dev): update development.md --- docs/development.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/development.md b/docs/development.md index 1c8dd85cfd..64fe517b39 100644 --- a/docs/development.md +++ b/docs/development.md @@ -15,8 +15,8 @@ The Firefish repo comes with a new containerized environment to help make develo ### Start up the environment -1. Run `git clone https://firefish.dev/firefish/firefish.git && cd firefish` to fetch needed files. - - If you don't want to clone the entire repository, you can just download the [`dev` directory](https://firefish.dev/firefish/firefish/-/tree/develop/dev) and execute `chmod +x dev/docker-entrypoint.sh`. +1. Download the [`dev` directory](https://firefish.dev/firefish/firefish/-/tree/develop/dev) and execute `chmod +x dev/docker-entrypoint.sh`. + - Alternatively, you can just run `git clone https://firefish.dev/firefish/firefish.git && cd firefish` to fetch needed files (it clones the entire repository, though). 1. Open `dev/docker-compose.yml` and set `URL` to the URL you want to use (or leave it to `http://localhost:3030`). 1. Run `docker compose --file dev/docker-compose.yml up`. This will build the environment, dependencies and prepare the needed config files. - If you use Podman, you should run `podman-compose --file dev/docker-compose.yml up` instead. From 218a875b8be5a9601470eccd4fd52d6c138c401f Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 4 Mar 2024 13:06:05 +0900 Subject: [PATCH 13/55] dev: fix port numbers in devenv.yml --- .config/devenv.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/devenv.yml b/.config/devenv.yml index b3bbf7b27c..e7c0c699b3 100644 --- a/.config/devenv.yml +++ b/.config/devenv.yml @@ -3,7 +3,7 @@ port: 3030 db: host: firefish_db - port: 25432 + port: 5432 db: firefish_db user: firefish @@ -11,7 +11,7 @@ db: redis: host: firefish_redis - port: 26379 + port: 6379 id: 'aid' From ab1c674fb86016d5e1bbe6ce309278ed2ed614a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Mon, 4 Mar 2024 17:09:59 +0800 Subject: [PATCH 14/55] change dir structure, add docs, download by git --- dev/docker-dbonly/README.md | 13 +++++++++ .../docker-compose.yml} | 0 dev/{ => docker-dbonly}/install.sql | 0 dev/docker/README.md | 28 ++++++++++++++++++ dev/{ => docker}/docker-compose.yml | 0 dev/{ => docker}/docker-entrypoint.sh | 11 +++---- docs/development.md | 29 ++++--------------- scripts/dev-down.mjs | 6 +--- scripts/dev-up.mjs | 7 +---- 9 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 dev/docker-dbonly/README.md rename dev/{docker-compose-dbonly.yml => docker-dbonly/docker-compose.yml} (100%) rename dev/{ => docker-dbonly}/install.sql (100%) create mode 100644 dev/docker/README.md rename dev/{ => docker}/docker-compose.yml (100%) rename dev/{ => docker}/docker-entrypoint.sh (82%) diff --git a/dev/docker-dbonly/README.md b/dev/docker-dbonly/README.md new file mode 100644 index 0000000000..46802e639f --- /dev/null +++ b/dev/docker-dbonly/README.md @@ -0,0 +1,13 @@ +## Containerized Database Environment + +The Firefish repo comes with containerized database environment to help make development! + +## Prerequisites + +- Latest [Docker](https://docs.docker.com/get-docker/) installation + - Alternatively, you can use [Podman](https://podman.io/docs/installation) and [Podman Compose](https://github.com/containers/podman-compose). + +## Start up the environment + +1. Run `git clone https://firefish.dev/firefish/firefish.git && cd firefish` to fetch needed files. +1. Using the scripts located in scripts folder to make the development environment running. diff --git a/dev/docker-compose-dbonly.yml b/dev/docker-dbonly/docker-compose.yml similarity index 100% rename from dev/docker-compose-dbonly.yml rename to dev/docker-dbonly/docker-compose.yml diff --git a/dev/install.sql b/dev/docker-dbonly/install.sql similarity index 100% rename from dev/install.sql rename to dev/docker-dbonly/install.sql diff --git a/dev/docker/README.md b/dev/docker/README.md new file mode 100644 index 0000000000..79288c12b2 --- /dev/null +++ b/dev/docker/README.md @@ -0,0 +1,28 @@ +# Containerized Environment + +The Firefish repo comes with a new containerized environment to help make development! + +## Prerequisites + +- Latest [Docker](https://docs.docker.com/get-docker/) installation + - Alternatively, you can use [Podman](https://podman.io/docs/installation) and [Podman Compose](https://github.com/containers/podman-compose). +- The following ports are not in use + - 3030 + - 25432 + - 26379 + +## Start up the environment + +1. Download the [`dev/docker` directory](https://firefish.dev/firefish/firefish/-/tree/develop/dev/docker) and execute `chmod +x docker-entrypoint.sh`. + - Alternatively, you can manually run `git clone https://firefish.dev/firefish/firefish.git && cd firefish` to fetch needed files, or let the script take care of itself. +1. Open `docker-compose.yml` and set `URL` to the URL you want to use (or leave it to `http://localhost:3030`). +1. Run `docker compose up`. This will build the environment, dependencies and prepare the needed config files. + - If you use Podman, you should run `podman-compose up` instead. +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! + +When you want to restart the dev server, you just need to terminate the process (a.k.a. press `Ctrl+C`) and run `docker compose up` again. diff --git a/dev/docker-compose.yml b/dev/docker/docker-compose.yml similarity index 100% rename from dev/docker-compose.yml rename to dev/docker/docker-compose.yml diff --git a/dev/docker-entrypoint.sh b/dev/docker/docker-entrypoint.sh similarity index 82% rename from dev/docker-entrypoint.sh rename to dev/docker/docker-entrypoint.sh index 541c304ea6..2a5303cb48 100755 --- a/dev/docker-entrypoint.sh +++ b/dev/docker/docker-entrypoint.sh @@ -8,24 +8,25 @@ if [ ! -f '/.firefish_env_initialized' ]; then # Install compilation dependencies apt-get update - DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends curl build-essential ca-certificates python3 postgresql-client-15 + DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends curl build-essential ca-certificates python3 postgresql-client-15 git curl -vvv --proto '=https' --tlsv1.2 --show-error --fail https://sh.rustup.rs | sh -s -- -y # Add Cargo PATH PATH="/root/.cargo/bin:${PATH}" + # If Firefish not exist if [ ! -f '/firefish/README.md' ]; then - # Download Firefish and decompress - curl -vvv -O --proto '=https' --tlsv1.2 --show-error --fail https://firefish.dev/firefish/firefish/-/archive/develop/firefish-develop.tar.bz2 - tar -xjvf firefish-develop.tar.bz2 --strip-components 1 -C /firefish + # Clone Firefish + cd / + git clone -v https://firefish.dev/firefish/firefish.git # Configuring a new server cd /firefish cp .config/devenv.yml .config/default.yml URL="$(echo "${URL}" | sed 's#/#\\/#g')" - sed -i'.bak' "s/http:\/\/localhost:3030/${URL}/" .config/default.yml + sed -i'.bak' "s/http:\/\/localhost:3030/${URL}/" .config/default.yml fi diff --git a/docs/development.md b/docs/development.md index 64fe517b39..0ff66c4970 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1,30 +1,11 @@ # Firefish Developer Docs +We support multiple methods to build a development environment, and you can choose the method you like. + ## Containerized Environment -The Firefish repo comes with a new containerized environment to help make development! +You can find documentation at [Here](../dev/docker/README.md). -### Prerequisites +## Containerized Database Environment -- Latest [Docker](https://docs.docker.com/get-docker/) installation - - Alternatively, you can use [Podman](https://podman.io/docs/installation) and [Podman Compose](https://github.com/containers/podman-compose). -- The following ports are not in use - - 3030 - - 25432 - - 26379 - -### Start up the environment - -1. Download the [`dev` directory](https://firefish.dev/firefish/firefish/-/tree/develop/dev) and execute `chmod +x dev/docker-entrypoint.sh`. - - Alternatively, you can just run `git clone https://firefish.dev/firefish/firefish.git && cd firefish` to fetch needed files (it clones the entire repository, though). -1. Open `dev/docker-compose.yml` and set `URL` to the URL you want to use (or leave it to `http://localhost:3030`). -1. Run `docker compose --file dev/docker-compose.yml up`. This will build the environment, dependencies and prepare the needed config files. - - If you use Podman, you should run `podman-compose --file dev/docker-compose.yml up` instead. -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! - -When you want to restart the dev server, you just need to terminate the process (a.k.a. press `Ctrl+C`) and run `docker compose up` again. +You can find documentation at [Here](../dev/docker-dbonly/README.md). diff --git a/scripts/dev-down.mjs b/scripts/dev-down.mjs index 8c7a83435a..73573a2151 100644 --- a/scripts/dev-down.mjs +++ b/scripts/dev-down.mjs @@ -5,11 +5,7 @@ import { execa } from "execa"; (async () => { const __dirname = path.dirname(fileURLToPath(import.meta.url)); - execa("podman-compose", [ - "--file", - "docker-compose-dbonly.yml", - "down", - ], { + execa("podman-compose", { cwd: join(__dirname, "/../dev"), stdio: "inherit", }); diff --git a/scripts/dev-up.mjs b/scripts/dev-up.mjs index 166c8dbad3..73573a2151 100644 --- a/scripts/dev-up.mjs +++ b/scripts/dev-up.mjs @@ -5,12 +5,7 @@ import { execa } from "execa"; (async () => { const __dirname = path.dirname(fileURLToPath(import.meta.url)); - execa("podman-compose", [ - "--file", - "docker-compose-dbonly.yml", - "up", - "--detach", - ], { + execa("podman-compose", { cwd: join(__dirname, "/../dev"), stdio: "inherit", }); From 90a39b9027017d648b9ecbe4b905dc798967983b Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 5 Mar 2024 08:59:24 +0900 Subject: [PATCH 15/55] dev: rename scripts dev:{init, up, down} -> db:{init, up, down} --- package.json | 6 +++--- scripts/{dev-down.mjs => db-down.mjs} | 2 +- scripts/{dev-up.mjs => db-up.mjs} | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename scripts/{dev-down.mjs => db-down.mjs} (83%) rename scripts/{dev-up.mjs => db-up.mjs} (83%) diff --git a/package.json b/package.json index 2965992ada..8039ad4e48 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,10 @@ "gulp": "gulp build", "watch": "pnpm run dev", "dev": "pnpm node ./scripts/dev.mjs", - "dev:up": "pnpm node ./scripts/dev-up.mjs", - "dev:down": "pnpm node ./scripts/dev-down.mjs", - "dev:init": "pnpm run dev:down && pnpm run dev:up", "dev:staging": "NODE_OPTIONS=--max_old_space_size=3072 NODE_ENV=development pnpm run build && pnpm run start", + "db:up": "pnpm node ./scripts/db-up.mjs", + "db:down": "pnpm node ./scripts/db-down.mjs", + "db:init": "pnpm run dev:down && pnpm run dev:up", "lint": "pnpm -r --parallel run lint", "debug": "pnpm run build:debug && pnpm run start", "build:debug": "pnpm run clean && pnpm node ./scripts/dev-build.mjs && pnpm run gulp", diff --git a/scripts/dev-down.mjs b/scripts/db-down.mjs similarity index 83% rename from scripts/dev-down.mjs rename to scripts/db-down.mjs index 73573a2151..727fd063b0 100644 --- a/scripts/dev-down.mjs +++ b/scripts/db-down.mjs @@ -6,7 +6,7 @@ import { execa } from "execa"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); execa("podman-compose", { - cwd: join(__dirname, "/../dev"), + cwd: join(__dirname, "/../dev/docker-dbonly"), stdio: "inherit", }); })(); diff --git a/scripts/dev-up.mjs b/scripts/db-up.mjs similarity index 83% rename from scripts/dev-up.mjs rename to scripts/db-up.mjs index 73573a2151..727fd063b0 100644 --- a/scripts/dev-up.mjs +++ b/scripts/db-up.mjs @@ -6,7 +6,7 @@ import { execa } from "execa"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); execa("podman-compose", { - cwd: join(__dirname, "/../dev"), + cwd: join(__dirname, "/../dev/docker-dbonly"), stdio: "inherit", }); })(); From 6344aa29aa20f255249a13344c942f30373a5dce Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 5 Mar 2024 18:37:24 +0900 Subject: [PATCH 16/55] dev: add back needed arguments to db:{up, down} --- scripts/db-down.mjs | 2 +- scripts/db-up.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/db-down.mjs b/scripts/db-down.mjs index 727fd063b0..bb972b262b 100644 --- a/scripts/db-down.mjs +++ b/scripts/db-down.mjs @@ -5,7 +5,7 @@ import { execa } from "execa"; (async () => { const __dirname = path.dirname(fileURLToPath(import.meta.url)); - execa("podman-compose", { + execa("podman-compose", ["down"], { cwd: join(__dirname, "/../dev/docker-dbonly"), stdio: "inherit", }); diff --git a/scripts/db-up.mjs b/scripts/db-up.mjs index 727fd063b0..08842c2eb9 100644 --- a/scripts/db-up.mjs +++ b/scripts/db-up.mjs @@ -5,7 +5,7 @@ import { execa } from "execa"; (async () => { const __dirname = path.dirname(fileURLToPath(import.meta.url)); - execa("podman-compose", { + execa("podman-compose", ["up", "--detach"], { cwd: join(__dirname, "/../dev/docker-dbonly"), stdio: "inherit", }); From 0b0edaa95878ca9ac829220609fb99ef6df4e4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Tue, 5 Mar 2024 18:04:42 +0800 Subject: [PATCH 17/55] doc: new env init docs for dev and prod, clear docs, update dependencies --- .config/example.yml | 13 +- README.md | 168 +++--------------------- dev/README.md | 27 ++++ dev/docker/README.md | 2 +- dev/manually/README.md | 184 +++++++++++++++++++++++++++ docs/development.md | 11 -- docs/docker.md | 55 +++++++- docs/install.md | 282 +++++++++++++++++++++++++++++++++++++++++ firefish.apache.conf | 13 -- 9 files changed, 563 insertions(+), 192 deletions(-) create mode 100644 dev/README.md create mode 100644 dev/manually/README.md delete mode 100644 docs/development.md create mode 100644 docs/install.md delete mode 100644 firefish.apache.conf diff --git a/.config/example.yml b/.config/example.yml index 43f6d7e923..678f9641c9 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -44,8 +44,8 @@ db: db: firefish # Auth - user: example-firefish-user - pass: example-firefish-pass + user: firefish + pass: password # Whether disable Caching queries #disableCache: true @@ -77,9 +77,9 @@ redis: # A Redis-compatible server (DragonflyDB, Keydb, Redis) for caching # If left blank, it will use the Redis server from above -#cacheServer: - #host: localhost - #port: 6379 +cacheServer: + host: localhost + port: 6380 #family: 0 # 0=Both, 4=IPv4, 6=IPv6 #pass: example-pass #prefix: example-prefix @@ -181,9 +181,6 @@ logLevel: [ # Proxy remote files (default: false) #proxyRemoteFiles: true -# Use authorized fetch for outgoing requests -signToActivityPubGet: true - #allowedPrivateNetworks: [ # '127.0.0.1/32' #] diff --git a/README.md b/README.md index 6edbd5efbd..af2d77be1e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,14 @@ Firefish is based off of Misskey, a powerful microblogging server on ActivityPub - Official account: `@firefish@info.firefish.dev` - Weblate: +# Release cycle + +We use a rolling release cycle now. Small updates will be frequently merged into the main branch, so please upgrade regularly at your convenience. We will use the commit date (e.g., 20240206) as the version number. + +Any special operations required for an upgrade (e.g., installing new dependencies, editing docker-compose.yml) will be noted on [docs/notice-for-admins.md](docs/notice-for-admins.md) , so please check it before upgrading. + +**As always, please take a backup first before starting update.** Whether it is a server snapshot backup or a complete database and file backup, it will be of great help to your recovery process. + # Getting started This guide will work for both **starting from scratch** and **migrating from Misskey**. @@ -46,14 +54,18 @@ If you have access to a server that supports one of the sources below, I recomme - [How to run Firefish with Docker](https://firefish.dev/firefish/firefish/-/blob/develop/docs/docker.md) - [How to run Firefish with Kubernetes/Helm](https://firefish.dev/firefish/firefish/-/blob/develop/docs/kubernetes.md) -## Dependencies +## Install Production Environment + +For install production environment details, read [this document](https://firefish.dev/firefish/firefish/-/blob/develop/docs/install.md). + +## Software Dependencies - At least [NodeJS](https://nodejs.org/en/) v18.16.0 (v20/v21 recommended) -- At least [PostgreSQL](https://www.postgresql.org/) v12 (v16 recommended) +- At least [PostgreSQL](https://www.postgresql.org/) v12 (v16 recommended) with [PGroonga](https://pgroonga.github.io/) extension - At least [Redis](https://redis.io/) v7 - Web Proxy (one of the following) + - Caddy (recommended for new users) - Nginx (recommended) - - Caddy (recommended) - Apache ### Optional dependencies @@ -72,156 +84,6 @@ If you have access to a server that supports one of the sources below, I recomme - `base-devel` on Arch Linux - [Python 3](https://www.python.org/) -## Get folder ready - -```sh -git clone https://firefish.dev/firefish/firefish.git -cd firefish/ -``` - -> **Note** -> By default, you're on the develop branch. Run `git checkout main` to switch to the Main branch. - -## Install dependencies - -```sh -# nvm install 19 && nvm use 19 -sudo corepack enable -corepack prepare pnpm@latest --activate -pnpm install --frozen-lockfile -``` - -### pm2 - -To install pm2 run: - -``` -npm i -g pm2 -pm2 install pm2-logrotate -``` - -> **Note** -> [`pm2-logrotate`](https://github.com/keymetrics/pm2-logrotate/blob/master/README.md) ensures that log files don't infinitely gather size, as Firefish produces a lot of logs. - -## Create database - -In PostgreSQL (`psql`), run the following command: - -```sql -CREATE DATABASE firefish WITH encoding = 'UTF8'; -``` - -or run the following from the command line: - -```sh -psql postgres -c "create database firefish with encoding = 'UTF8';" -``` - -In Firefish's directory, fill out the `db` section of `.config/default.yml` with the correct information, where the `db` key is `firefish`. - -## Caching server - -If you experience a lot of traffic, it's a good idea to set up another Redis-compatible caching server. If you don't set one one up, it'll fall back to the mandatory Redis server. DragonflyDB is the recommended option due to its unrivaled performance and ease of use. - -## Set up search - -### Sonic - -Sonic is better suited for self hosters with smaller deployments. It uses almost no resources, barely any any disk space, and is relatively fast. - -Follow sonic's [installation guide](https://github.com/valeriansaliou/sonic#installation) - -> **Note** -> If you use IPv4: in Sonic's directory, edit the `config.cfg` file to change `inet` to `"0.0.0.0:1491"`. - -In Firefish's directory, fill out the `sonic` section of `.config/default.yml` with the correct information. - -### Meilisearch - -Meilisearch is better suited for larger deployments. It's faster but uses far more resources and disk space. - -Follow Meilisearch's [quick start guide](https://www.meilisearch.com/docs/learn/getting_started/quick_start) - -In Firefish's directory, fill out the `meilisearch` section of `.config/default.yml` with the correct information. - -### ElasticSearch - -Please don't use ElasticSearch unless you already have an ElasticSearch setup and want to continue using it for Firefish. ElasticSearch is slow, heavy, and offers very few benefits over Sonic/Meilisearch. - -## Customize - -- To add custom CSS for all users, edit `./custom/assets/instance.css`. -- To add static assets (such as images for the splash screen), place them in the `./custom/assets/` directory. They'll then be available on `https://yourserver.tld/static-assets/filename.ext`. -- To add custom locales, place them in the `./custom/locales/` directory. If you name your custom locale the same as an existing locale, it will overwrite it. If you give it a unique name, it will be added to the list. Also make sure that the first part of the filename matches the locale you're basing it on. (Example: `en-FOO.yml`) -- To add custom error images, place them in the `./custom/assets/badges` directory, replacing the files already there. -- To add custom sounds, place only mp3 files in the `./custom/assets/sounds` directory. -- To update custom assets without rebuilding, just run `pnpm run gulp`. -- To block ChatGPT, CommonCrawl, or other crawlers from indexing your instance, uncomment the respective rules in `./custom/robots.txt`. - -## Configuring a new server - -- Run `cp .config/example.yml .config/default.yml` -- Edit `.config/default.yml`, making sure to fill out required fields. -- Also copy and edit `.config/docker_example.env` to `.config/docker.env` if you're using Docker. - ## Migrating from Misskey/FoundKey to Firefish For migrating from Misskey v13, Misskey v12, and FoundKey, read [this document](https://firefish.dev/firefish/firefish/-/blob/develop/docs/migrate.md). - -## Web proxy - -### Nginx (recommended) - -- Run `sudo cp ./firefish.nginx.conf /etc/nginx/sites-available/ && cd /etc/nginx/sites-available/` -- Edit `firefish.nginx.conf` to reflect your server properly -- Run `sudo ln -s ./firefish.nginx.conf ../sites-enabled/firefish.nginx.conf` -- Run `sudo nginx -t` to validate that the config is valid, then restart the NGINX service. - -### Caddy (recommended) - -- Add the following block to your `Caddyfile`, replacing `example.tld` with your own domain: -```caddy -example.tld { - reverse_proxy http://127.0.0.1:3000 -} -``` -- Reload your caddy configuration - -### Apache - -> **Warning** -> Apache has some known problems with Firefish. Only use it if you have to. - -- Run `sudo cp ./firefish.apache.conf /etc/apache2/sites-available/ && cd /etc/apache2/sites-available/` -- Edit `firefish.apache.conf` to reflect your server properly -- Run `sudo a2ensite firefish.apache` to enable the site -- Run `sudo service apache2 restart` to reload apache2 configuration - -## Build and launch! - -### NodeJS + pm2 - -#### `git pull` and run these steps to update Firefish in the future! - -```sh -# git pull -pnpm install -NODE_ENV=production pnpm run build && pnpm run migrate -pm2 start "NODE_ENV=production pnpm run start" --name Firefish -``` - -## Tips & Tricks - -- When editing the config file, please don't fill out the settings at the bottom. They're designed *only* for managed hosting, not self hosting. Those settings are much better off being set in Firefish's control panel. -- Port 3000 (used in the default config) might be already used on your server for something else. To find an open port for Firefish, run `for p in {3000..4000}; do ss -tlnH | tr -s ' ' | cut -d" " -sf4 | grep -q "${p}$" || echo "${p}"; done | head -n 1`. Replace 3000 with the minimum port and 4000 with the maximum port if you need it. -- I'd recommend you use a S3 Bucket/CDN for Object Storage, especially if you use Docker. -- When using object storage, setting a proper `Access-Control-Allow-Origin` response header is highly recommended. -- I'd ***strongly*** recommend against using CloudFlare, but if you do, make sure to turn code minification off. -- For push notifications, run `npx web-push generate-vapid-keys`, then put the public and private keys into Control Panel > General > ServiceWorker. -- For translations, make a [DeepL](https://deepl.com) account and generate an API key, then put it into Control Panel > General > DeepL Translation. -- To add another admin account: - - Go to the user's page > 3 Dots > About > Moderation > turn on "Moderator" - - Go back to Overview > click the clipboard icon next to the ID - - Run `psql -d firefish` (or whatever the database name is) - - Run `UPDATE "user" SET "isAdmin" = true WHERE id='999999';` (replace `999999` with the copied ID) - - Restart your Firefish server diff --git a/dev/README.md b/dev/README.md new file mode 100644 index 0000000000..9da0fc0946 --- /dev/null +++ b/dev/README.md @@ -0,0 +1,27 @@ +# Firefish Developers' Corner + +## Changelog + +You can find more about software change [here](../docs/changelog.md), and API change [here](../docs/api-change.md). + +## API documentation + +You can find interactive API documentation at any Firefish instance /api-doc endpoint. By the way, API console can be found at /api-console endpoint. + +You can also find more about firefish-js [here](../packages/firefish-js/README.md). + +## Environment build + +We support multiple methods to build a development environment, and you can choose the method you like. + +### Containerized Environment + +You can find documentation at [Here](docker/README.md). + +### Containerized Database Environment + +You can find documentation at [Here](docker-dbonly/README.md). + +### Manually Make Development Environment + +You can find documentation at [Here](manually/README.md). diff --git a/dev/docker/README.md b/dev/docker/README.md index 79288c12b2..4a7f15822d 100644 --- a/dev/docker/README.md +++ b/dev/docker/README.md @@ -19,7 +19,7 @@ The Firefish repo comes with a new containerized environment to help make develo 1. Run `docker compose up`. This will build the environment, dependencies and prepare the needed config files. - If you use Podman, you should run `podman-compose up` instead. 1. Wait until the following message shows up. - ``` + ```log DONE * [core boot] All workers started DONE * [core boot] Now listening on port 3030 on https://your_firefish_url.example.com ``` diff --git a/dev/manually/README.md b/dev/manually/README.md new file mode 100644 index 0000000000..8a5fe70f82 --- /dev/null +++ b/dev/manually/README.md @@ -0,0 +1,184 @@ +# 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 + +```sh +su - +apt install -y -V sudo +# user is your username +usermod -aG sudo user +reboot +``` + +## Install Base Requirements + +```sh +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](https://nodejs.org) . + +1. Download and extract. + +```sh +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 +``` + +2. Open your `.profile` and `/root/.profile` files. + +```sh +nano ~/.profile +sudo nano /root/.profile +``` + +3. Add below content at below of this two file to set the environment variable. + +```sh +# Nodejs +VERSION=v21.6.2 +DISTRO=linux-x64 +export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH +``` + +4. Refresh `PATH` and test. + +```sh +. ~/.profile +node -v +# Switching to root +sudo -i +. ~/.profile +node -v +exit +``` + +## Install Rust + +1. Running this script and choose "Proceed with installation" option. + +```sh +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +. ~/.profile +cargo -V +``` + +## Install PostgreSQL with PGroonga extension + +```sh +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. + +```sh +sudo -u postgres psql +``` + +2. Create Firefish database, user and PGroonga extension. **Please change the password.** + +```sql +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; +``` + +3. Run `exit` to return. + +## Install Redis, Python 3 and build-essential + +```sh +sudo apt update +sudo apt install -y -V redis python3 build-essential +``` + +## Download and configuration Firefish + +1. Download Firefish and Copy example configuration file. + +```sh +# 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 +``` + +2. Open your `default.yml` files and make changes like `URL`, `db/host` `redis/host`. + +```sh +nano .config/default.yml +``` + +## Install package + +1. Let corepack enable. + +```sh +# Switching to root +sudo -i +# cd /path/to/your/firefish +cd /home/user/firefish +corepack enable +exit +``` + +2. Install dependency. + +```sh +corepack prepare pnpm@latest --activate +pnpm install --frozen-lockfile --prod false +``` + +## Start + +1. Build and migrate + +```sh +pnpm install --prod false +NODE_ENV=production +pnpm run build:debug +pnpm run migrate +``` + +2. Start Firefish + +```sh +pnpm run start +``` + +2. Wait until the following message shows up. + +```log +DONE * [core boot] All workers started +DONE * [core boot] Now listening on port 3030 on https://your_firefish_url.example.com +``` + +3. A fresh Firefish environment is created on the URL you have set! diff --git a/docs/development.md b/docs/development.md deleted file mode 100644 index 0ff66c4970..0000000000 --- a/docs/development.md +++ /dev/null @@ -1,11 +0,0 @@ -# Firefish Developer Docs - -We support multiple methods to build a development environment, and you can choose the method you like. - -## Containerized Environment - -You can find documentation at [Here](../dev/docker/README.md). - -## Containerized Database Environment - -You can find documentation at [Here](../dev/docker-dbonly/README.md). diff --git a/docs/docker.md b/docs/docker.md index 2b8667d1e1..569c6a6c7c 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -1,15 +1,27 @@ # Running a Firefish server with Docker +## Prerequisites + +- Latest [Docker](https://docs.docker.com/get-docker/) installation + - Alternatively, you can use [Podman](https://podman.io/docs/installation) and [Podman Compose](https://github.com/containers/podman-compose). +- The following ports are not in use + - 80 + - 443 + - 3000 + - 5432 + - 6379 + ## Pre-built docker container + [registry.firefish.dev/firefish/firefish](https://firefish.dev/firefish/firefish/container_registry) -## `docker-compose` +## Config files There are example config files that you can use to build the container from source - docker-compose.example.yml (**compose file**) - .config/docker_example.env (**db config settings**) -- .config/default.yml (**firefish server settings**) +- .config/default.yml (**Firefish server settings**) ## Configuring @@ -23,20 +35,51 @@ cp .config/docker_example.env .config/docker.env then edit them according to your environment. You can configure `docker.env` with anything you like, but you will have to pay attention to the `default.yml` file: + - `url` should be set to the URL you will be hosting the web interface for the server at. - `host`, `db`, `user`, `pass` will have to be configured in the `PostgreSQL configuration` section - `host` is the name of the postgres container (eg: *firefish_db_1*), and the others should match your `docker.env`. - `host`will need to be configured in the *Redis configuration* section - it is the name of the redis container (eg: *firefish_redis_1*) -- `auth` will need to be configured in the *Sonic* section - cannot be the default `SecretPassword` Everything else can be left as-is. -## Running docker-compose +## Running The [prebuilt container for firefish](https://firefish.dev/firefish/firefish/container_registry) is fairly large, and may take a few minutes to download and extract using docker. -Copy `docker-compose.yml` and the `config/` to a directory, then run the **docker-compose** command: -`docker-compose up -d`. +Copy `docker-compose.yml` and the `config/` to a directory, then run the **docker compose** command: `docker compose up -d` . + - If you use Podman, you should run `podman-compose up` instead. NOTE: This will take some time to come fully online, even after download and extracting the container images, and it may emit some error messages before completing successfully. Specifically, the `db` container needs to initialize and so isn't available to the `web` container right away. Only once the `db` container comes online does the `web` container start building and initializing the firefish tables. Once the server is up you can use a web browser to access the web interface at `http://serverip:3000` (where `serverip` is the IP of the server you are running the firefish server on). + +## Install reverse proxy + +### Caddy (recommended for new users) + +- Add the following block to your `Caddyfile`, replacing `example.tld` with your own domain: + +```caddy +example.tld { + reverse_proxy http://127.0.0.1:3000 +} +``` + +- Reload your caddy configuration + +### Nginx (recommended) + +- Run `sudo cp ./firefish.nginx.conf /etc/nginx/sites-available/ && cd /etc/nginx/sites-available/` +- Edit `firefish.nginx.conf` to reflect your server properly +- Run `sudo ln -s ./firefish.nginx.conf ../sites-enabled/firefish.nginx.conf` +- Run `sudo nginx -t` to validate that the config is valid, then restart the NGINX service. + +### Apache + +> **Warning** +> Apache has some known problems with Firefish. Only use it if you have to. + +- Run `sudo cp ./firefish.apache.conf /etc/apache2/sites-available/ && cd /etc/apache2/sites-available/` +- Edit `firefish.apache.conf` to reflect your server properly +- Run `sudo a2ensite firefish.apache` to enable the site +- Run `sudo service apache2 restart` to reload apache2 configuration diff --git a/docs/install.md b/docs/install.md new file mode 100644 index 0000000000..c4cbdf7801 --- /dev/null +++ b/docs/install.md @@ -0,0 +1,282 @@ +# Install Production Environment + +Hope this article can help you about install production environment. + +## 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 that come with Debian Bookworm are low, 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 + +```sh +su - +apt install -y -V sudo +# user is your username +usermod -aG sudo user +reboot +``` + +## Install Base Requirements + +```sh +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](https://nodejs.org) . + +1. Download and extract. + +```sh +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 +``` + +2. Open your `.profile` and `/root/.profile` files. + +```sh +nano ~/.profile +sudo nano /root/.profile +``` + +3. Add below content at below of this two file to set the environment variable. + +```sh +# Nodejs +VERSION=v21.6.2 +DISTRO=linux-x64 +export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH +``` + +4. Refresh `PATH` and test. + +```sh +. ~/.profile +node -v +# Switching to root +sudo -i +. ~/.profile +node -v +exit +``` + +## Install Rust + +1. Running this script and choose "Proceed with installation" option. + +```sh +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +. ~/.profile +cargo -V +``` + +## Install PostgreSQL with PGroonga extension + +```sh +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. + +```sh +sudo -u postgres psql +``` + +2. Create Firefish database, user and PGroonga extension. **Please change the password.** + +```sql +CREATE DATABASE firefish WITH ENCODING = 'UTF8'; +\connect firefish +CREATE EXTENSION IF NOT EXISTS pgroonga; +CREATE USER firefish WITH PASSWORD 'password'; +ALTER USER firefish WITH SUPERUSER; +GRANT ALL ON DATABASE firefish TO firefish; +``` + +3. Run `exit` to return. + +## Install DragonflyDB (Cache) + +```sh +wget https://dragonflydb.gateway.scarf.sh/latest/dragonfly_amd64.deb +sudo dpkg -i dragonfly_amd64.deb +``` + +## Configuration DragonflyDB + +If you experience a lot of traffic, it's a good idea to set up another Redis-compatible caching server. If you don't set one one up, it'll fall back to the mandatory Redis server. DragonflyDB is the recommended option due to its unrivaled performance and ease of use. + +1. Open your `dragonfly.conf` files. + +```sh +sudo nano /etc/dragonfly/dragonfly.conf +``` + +2. Add content at below of this file to set the different port variable because default port is 6379. + +```conf +--port=6380 +``` + +3. Run `sudo systemctl restart dragonfly` to restart it. + +## Install Caddy, Redis, Python 3 and build-essential + +If you already have experience using nginx, you can consider replacing caddy with nginx here. + +```sh +sudo apt update +sudo apt install -y -V caddy redis python3 build-essential +``` + +## Configuration Caddy + +If you replaced nginx in the previous step, please refer to the "Other reverse proxy server" chapter in the document for configuration. + +1. Run this to modify caddy configuration. + +```sh +sudo nano /etc/caddy/Caddyfile +``` + +2. Add this below, should change `example.tld` to your domain. + +```conf +example.tld { + reverse_proxy http://127.0.0.1:3000 +} +``` + +3. Running `sudo ystemctl restart caddy` to apply. + +## Download and configuration Firefish + +1. Download Firefish and Copy example configuration file. + +```sh +# cd /path/to/your/firefish +git clone https://firefish.dev/firefish/firefish.git +cd firefish/ +git checkout main +cp .config/example.yml .config/default.yml +``` + +> **Note** +> By default, you're on the develop branch. Run `git checkout main` to switch to the Main branch. + +2. Open your `default.yml` files and make changes like `URL`, `db` and `reservedUsernames`. + +```sh +nano .config/default.yml +``` + +## Install Firefish + +**run these steps to update Firefish in the future!** + +1. Let corepack enable. + +```sh +# Switching to root +sudo -i +# cd /path/to/your/firefish +cd /home/user/firefish +npm i -g pm2 +corepack enable +exit +``` + +2. Install dependency. + +```sh +corepack prepare pnpm@latest --activate +pnpm install --frozen-lockfile --prod false +pm2 install pm2-logrotate +``` + +> **Note** +> [`pm2-logrotate`](https://github.com/keymetrics/pm2-logrotate/blob/master/README.md) ensures that log files don't infinitely gather size, as Firefish produces a lot of logs. + +3. Build and migrate + +```sh +pnpm install --prod false +NODE_ENV=production pnpm run build && pnpm run migrate +``` + +4. Start Firefish + +```sh +pm2 start "NODE_ENV=production pnpm run start" --name Firefish +pm2 logs Firefish +``` + +5. Wait until the following message shows up. + +```log +1|Firefish | DONE * [core boot] All workers started +1|Firefish | DONE * [core boot] Now listening on port 3000 on https://your_firefish_url.example.com (default value: https://localhost:3000) +``` + +6. A fresh Firefish environment is created on the URL you have set! + +7. By the way, Please use content at below to generate vapid keys to enable Push-Notifications. + +```sh +# Switching to root +sudo -i +npm install -g web-push +web-push generate-vapid-keys +exit +``` + +## Customize + +- To add custom CSS for all users, edit `./custom/assets/instance.css`. +- To add static assets (such as images for the splash screen), place them in the `./custom/assets/` directory. They'll then be available on `https://yourserver.tld/static-assets/filename.ext`. +- To add custom locales, place them in the `./custom/locales/` directory. If you name your custom locale the same as an existing locale, it will overwrite it. If you give it a unique name, it will be added to the list. Also make sure that the first part of the filename matches the locale you're basing it on. (Example: `en-FOO.yml`) +- To add custom error images, place them in the `./custom/assets/badges` directory, replacing the files already there. +- To add custom sounds, place only mp3 files in the `./custom/assets/sounds` directory. +- To update custom assets without rebuilding, just run `pnpm run gulp`. +- To block ChatGPT, CommonCrawl, or other crawlers from indexing your instance, uncomment the respective rules in `./custom/robots.txt`. + +## Other reverse proxy server + +### Nginx + +- Run `sudo cp ./firefish.nginx.conf /etc/nginx/sites-available/ && cd /etc/nginx/sites-available/` . +- Edit `firefish.nginx.conf` to reflect your server properly. +- Run `sudo ln -s ./firefish.nginx.conf ../sites-enabled/firefish.nginx.conf` . +- Run `sudo nginx -t` to validate that the config is valid, then restart the NGINX service. + +## Tips & Tricks + +- When editing the config file, please don't fill out the settings at the bottom. They're designed *only* for managed hosting, not self hosting. Those settings are much better off being set in Firefish's control panel. +- Port 3000 (used in the default config) might be already used on your server for something else. To find an open port for Firefish, run `for p in {3000..4000}; do ss -tlnH | tr -s ' ' | cut -d" " -sf4 | grep -q "${p}$" || echo "${p}"; done | head -n 1`. Replace 3000 with the minimum port and 4000 with the maximum port if you need it. +- I'd recommend you use a S3 Bucket/CDN for Object Storage, especially if you use Docker. +- When using object storage, setting a proper `Access-Control-Allow-Origin` response header is highly recommended. +- I'd ***strongly*** recommend against using CloudFlare, but if you do, make sure to turn code minification off. +- For push notifications, run `npx web-push generate-vapid-keys`, then put the public and private keys into Control Panel > General > ServiceWorker. +- For translations, make a [DeepL](https://deepl.com) account and generate an API key, then put it into Control Panel > General > DeepL Translation. +- To add another admin account: + - Go to the user's page > 3 Dots > About > Moderation > turn on "Moderator" + - Go back to Overview > click the clipboard icon next to the ID + - Run `psql -d firefish` (or whatever the database name is) + - Run `UPDATE "user" SET "isAdmin" = true WHERE id='999999';` (replace `999999` with the copied ID) + - Restart your Firefish server diff --git a/firefish.apache.conf b/firefish.apache.conf deleted file mode 100644 index b0c69d51df..0000000000 --- a/firefish.apache.conf +++ /dev/null @@ -1,13 +0,0 @@ -# Replace example.tld with your domain - - - ServerName example.tld - # For WebSocket - ProxyPass "/streaming" "ws://127.0.0.1:3000/streaming/" - # Proxy to Node - ProxyPass "/" "http://127.0.0.1:3000/" - ProxyPassReverse "/" "http://127.0.0.1:3000/" - ProxyPreserveHost On - # For files proxy - AllowEncodedSlashes On - \ No newline at end of file From 616c52eff95bfc732c84d7c16809001aa018a15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Tue, 5 Mar 2024 18:27:12 +0800 Subject: [PATCH 18/55] fix small bug --- .gitignore | 2 +- README.md | 2 +- dev/README.md | 6 +++--- docs/docker.md | 10 ---------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 6919e197ee..291fd025c0 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,7 @@ packages/backend/assets/LICENSE packages/megalodon/lib packages/megalodon/.idea -dev/firefish +dev/docker/firefish # blender backups *.blend1 diff --git a/README.md b/README.md index af2d77be1e..db8cf97c4a 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ If you have access to a server that supports one of the sources below, I recomme For install production environment details, read [this document](https://firefish.dev/firefish/firefish/-/blob/develop/docs/install.md). -## Software Dependencies +## Dependencies - At least [NodeJS](https://nodejs.org/en/) v18.16.0 (v20/v21 recommended) - At least [PostgreSQL](https://www.postgresql.org/) v12 (v16 recommended) with [PGroonga](https://pgroonga.github.io/) extension diff --git a/dev/README.md b/dev/README.md index 9da0fc0946..111e6039ea 100644 --- a/dev/README.md +++ b/dev/README.md @@ -16,12 +16,12 @@ We support multiple methods to build a development environment, and you can choo ### Containerized Environment -You can find documentation at [Here](docker/README.md). +You can find documentation at [here](docker/README.md). ### Containerized Database Environment -You can find documentation at [Here](docker-dbonly/README.md). +You can find documentation at [here](docker-dbonly/README.md). ### Manually Make Development Environment -You can find documentation at [Here](manually/README.md). +You can find documentation at [here](manually/README.md). diff --git a/docs/docker.md b/docs/docker.md index 569c6a6c7c..ee224e05aa 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -73,13 +73,3 @@ example.tld { - Edit `firefish.nginx.conf` to reflect your server properly - Run `sudo ln -s ./firefish.nginx.conf ../sites-enabled/firefish.nginx.conf` - Run `sudo nginx -t` to validate that the config is valid, then restart the NGINX service. - -### Apache - -> **Warning** -> Apache has some known problems with Firefish. Only use it if you have to. - -- Run `sudo cp ./firefish.apache.conf /etc/apache2/sites-available/ && cd /etc/apache2/sites-available/` -- Edit `firefish.apache.conf` to reflect your server properly -- Run `sudo a2ensite firefish.apache` to enable the site -- Run `sudo service apache2 restart` to reload apache2 configuration From 5f0df9fbef11e77a50f8e96c11d6da35edc28c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Tue, 5 Mar 2024 18:33:28 +0800 Subject: [PATCH 19/55] add links to developers corner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index db8cf97c4a..efade01629 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Firefish is based off of Misskey, a powerful microblogging server on ActivityPub ### Want to get involved? Great! - If you have the means to, [donations](https://opencollective.com/Firefish) are a great way to keep us going. -- If you know how to program in TypeScript, Vue, or Rust, read the [contributing](./CONTRIBUTING.md) document. +- If you know how to program in TypeScript, Vue, or Rust, read the [contributing](./CONTRIBUTING.md) document and our [Developers' Corner](./dev/README.md) . - If you know a non-English language, translating Firefish on [Weblate](https://hosted.weblate.org/engage/firefish/) help bring Firefish to more people. No technical experience needed! ### Links From aace0a058c3c0815d8042bac999583c2ae0133d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Tue, 5 Mar 2024 21:34:43 +0800 Subject: [PATCH 20/55] fix bug --- docs/install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install.md b/docs/install.md index c4cbdf7801..2850febcb8 100644 --- a/docs/install.md +++ b/docs/install.md @@ -163,7 +163,7 @@ example.tld { } ``` -3. Running `sudo ystemctl restart caddy` to apply. +3. Running `sudo systemctl restart caddy` to apply. ## Download and configuration Firefish From 7fe7a520de9a9e0faf35e15ffe11a0f0d7d39663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Tue, 5 Mar 2024 22:23:24 +0800 Subject: [PATCH 21/55] feat: install pm2 on dev --- dev/manually/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dev/manually/README.md b/dev/manually/README.md index 8a5fe70f82..5da28d68b9 100644 --- a/dev/manually/README.md +++ b/dev/manually/README.md @@ -146,6 +146,7 @@ nano .config/default.yml sudo -i # cd /path/to/your/firefish cd /home/user/firefish +npm i -g pm2 corepack enable exit ``` @@ -154,9 +155,13 @@ exit ```sh corepack prepare pnpm@latest --activate +pm2 install pm2-logrotate pnpm install --frozen-lockfile --prod false ``` +> **Note** +> [`pm2-logrotate`](https://github.com/keymetrics/pm2-logrotate/blob/master/README.md) ensures that log files don't infinitely gather size, as Firefish produces a lot of logs. + ## Start 1. Build and migrate @@ -182,3 +187,11 @@ DONE * [core boot] Now listening on port 3030 on https://your_firefish_url. ``` 3. A fresh Firefish environment is created on the URL you have set! + +4. If you want Firefish to run in the background, start it with this command. + +```sh +pm2 start "NODE_ENV=production pnpm run start" --name Firefish +# When you want display log +pm2 logs Firefish +``` From c74acdfc4343e747cd583d4e9724078840734485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Tue, 5 Mar 2024 23:46:47 +0800 Subject: [PATCH 22/55] fix bug --- .config/devenv.yml | 4 ++++ dev/manually/README.md | 2 +- docs/install.md | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.config/devenv.yml b/.config/devenv.yml index e7c0c699b3..77d4ce66b6 100644 --- a/.config/devenv.yml +++ b/.config/devenv.yml @@ -15,6 +15,10 @@ redis: id: 'aid' +#allowedPrivateNetworks: [ +# '10.69.1.0/24' +#] + logLevel: [ 'error', 'success', diff --git a/dev/manually/README.md b/dev/manually/README.md index 5da28d68b9..df3359847e 100644 --- a/dev/manually/README.md +++ b/dev/manually/README.md @@ -6,7 +6,7 @@ For scenarios with special needs, you may want to manually create a development 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. +The versions of Node.js, Rust, PostgreSQL that come with Debian Bookworm are low, 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 diff --git a/docs/install.md b/docs/install.md index 2850febcb8..92886a1f1a 100644 --- a/docs/install.md +++ b/docs/install.md @@ -6,7 +6,7 @@ Hope this article can help you about install production environment. 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 that come with Debian Bookworm are low, 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. +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 From 4615bbeb4ddd34e79ea826ee0761e03edf394b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Tue, 5 Mar 2024 23:49:38 +0800 Subject: [PATCH 23/55] docs: new init db --- dev/manually/README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/dev/manually/README.md b/dev/manually/README.md index df3359847e..47e150e124 100644 --- a/dev/manually/README.md +++ b/dev/manually/README.md @@ -98,15 +98,12 @@ sudo apt install -y -V postgresql-16-pgdg-pgroonga sudo -u postgres psql ``` -2. Create Firefish database, user and PGroonga extension. **Please change the password.** +2. Create Firefish database, user and PGroonga extension. -```sql -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; +```sh +sudo --user=postgres createuser --no-createdb --no-createrole --no-superuser --encrypted --pwprompt firefish +sudo --user=postgres createdb --encoding='UTF8' --owner=firefish firefish_db +sudo --user=postgres psql --command='CREATE EXTENSION pgroonga;' --dbname=firefish_db ``` 3. Run `exit` to return. From ddd7ee5f7c7fc4421e9d9f4351cb5198fec0ef07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Tue, 5 Mar 2024 23:51:21 +0800 Subject: [PATCH 24/55] docs: extension not catch error --- docs/install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install.md b/docs/install.md index 92886a1f1a..3af96f9a2e 100644 --- a/docs/install.md +++ b/docs/install.md @@ -103,7 +103,7 @@ sudo -u postgres psql ```sql CREATE DATABASE firefish WITH ENCODING = 'UTF8'; \connect firefish -CREATE EXTENSION IF NOT EXISTS pgroonga; +CREATE EXTENSION pgroonga; CREATE USER firefish WITH PASSWORD 'password'; ALTER USER firefish WITH SUPERUSER; GRANT ALL ON DATABASE firefish TO firefish; From e9bc3f2d2c03e386e525ac26afd5a676bf6ccfa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Tue, 5 Mar 2024 23:53:04 +0800 Subject: [PATCH 25/55] fix bug --- dev/manually/README.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/dev/manually/README.md b/dev/manually/README.md index 47e150e124..a37b5c5d7d 100644 --- a/dev/manually/README.md +++ b/dev/manually/README.md @@ -92,13 +92,7 @@ sudo apt install -y -V postgresql-16-pgdg-pgroonga ## Configuration PostgreSQL -1. Execute this to running `psql` as `postgres` user. - -```sh -sudo -u postgres psql -``` - -2. Create Firefish database, user and PGroonga extension. +Create Firefish database, user and PGroonga extension. ```sh sudo --user=postgres createuser --no-createdb --no-createrole --no-superuser --encrypted --pwprompt firefish @@ -106,8 +100,6 @@ sudo --user=postgres createdb --encoding='UTF8' --owner=firefish firefish_db sudo --user=postgres psql --command='CREATE EXTENSION pgroonga;' --dbname=firefish_db ``` -3. Run `exit` to return. - ## Install Redis, Python 3 and build-essential ```sh From 6e6105cf8bc48ecddaa318a7bd55d454748bd6d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Wed, 6 Mar 2024 00:05:40 +0800 Subject: [PATCH 26/55] docs: more md update --- CONTRIBUTING.md | 8 ++++++-- dev/README.md | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index af4e7b08db..5f414ae0b6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,6 +69,12 @@ Be willing to comment on the good points and not just the things you want fixed - Are there any omissions or gaps? - Does it check for anomalies? +## More info + +**For more technical details, please visit the Firefish Developers' Corner at [here](dev/README.md) .** + +# THE FOLLOWING IS OUTDATED: + ## Preparing the development environment 1. Install the following software @@ -112,8 +118,6 @@ The `/deploy` command by issue comment can be used to deploy the contents of a M ``` An actual domain will be assigned so you can test the federation. -# THE FOLLOWING IS OUTDATED: - ## Merge ## Release diff --git a/dev/README.md b/dev/README.md index 111e6039ea..96ee6c74e8 100644 --- a/dev/README.md +++ b/dev/README.md @@ -1,5 +1,9 @@ # Firefish Developers' Corner +## Contribution guide and code of conduct + +You can also find contribution guide [here](../CONTRIBUTING.md) and code of conduct guide [here](../CODE_OF_CONDUCT.md). + ## Changelog You can find more about software change [here](../docs/changelog.md), and API change [here](../docs/api-change.md). From 8b8de8abba995ca196bdf982136293da05bfb0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Wed, 6 Mar 2024 18:11:40 +0800 Subject: [PATCH 27/55] fix bug --- docs/docker.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docker.md b/docs/docker.md index ee224e05aa..d8469ab906 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -5,8 +5,8 @@ - Latest [Docker](https://docs.docker.com/get-docker/) installation - Alternatively, you can use [Podman](https://podman.io/docs/installation) and [Podman Compose](https://github.com/containers/podman-compose). - The following ports are not in use - - 80 - - 443 + - 80 + - 443 - 3000 - 5432 - 6379 From 0344c518c9ce2c1b2499a8080bb6279d43e3a68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Thu, 7 Mar 2024 19:07:38 +0800 Subject: [PATCH 28/55] add tips for pgsql --- dev/manually/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dev/manually/README.md b/dev/manually/README.md index a37b5c5d7d..088f48c966 100644 --- a/dev/manually/README.md +++ b/dev/manually/README.md @@ -94,12 +94,16 @@ sudo apt install -y -V postgresql-16-pgdg-pgroonga Create Firefish database, user and PGroonga extension. +Please not forget prompt database password in console. + ```sh sudo --user=postgres createuser --no-createdb --no-createrole --no-superuser --encrypted --pwprompt firefish sudo --user=postgres createdb --encoding='UTF8' --owner=firefish firefish_db sudo --user=postgres psql --command='CREATE EXTENSION pgroonga;' --dbname=firefish_db ``` +If you forgot it, run `sudo -u postgres psql -c "ALTER USER firefish PASSWORD 'password';"` to set a password for firefish. + ## Install Redis, Python 3 and build-essential ```sh From ab8299f8f48992f7c5fbeed6651d4d90b3708c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Fri, 8 Mar 2024 21:56:17 +0800 Subject: [PATCH 29/55] docs: install optional ffmpeg dependencies --- dev/manually/README.md | 7 +++++++ docs/install.md | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/dev/manually/README.md b/dev/manually/README.md index 088f48c966..e0c3bf6aee 100644 --- a/dev/manually/README.md +++ b/dev/manually/README.md @@ -111,6 +111,13 @@ sudo apt update sudo apt install -y -V redis python3 build-essential ``` +## Install optional ffmpeg dependencies + +```sh +sudo apt update +sudo apt install -y -V ffmpeg +``` + ## Download and configuration Firefish 1. Download Firefish and Copy example configuration file. diff --git a/docs/install.md b/docs/install.md index 3af96f9a2e..a603046b99 100644 --- a/docs/install.md +++ b/docs/install.md @@ -165,6 +165,13 @@ example.tld { 3. Running `sudo systemctl restart caddy` to apply. +## Install optional ffmpeg dependencies + +```sh +sudo apt update +sudo apt install -y -V ffmpeg +``` + ## Download and configuration Firefish 1. Download Firefish and Copy example configuration file. From e68386605474bfc343352401ca95daa4bbd5cffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Fri, 8 Mar 2024 22:16:43 +0800 Subject: [PATCH 30/55] docs: add firefish's activitypub extensions link --- dev/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dev/README.md b/dev/README.md index 96ee6c74e8..439db35aca 100644 --- a/dev/README.md +++ b/dev/README.md @@ -14,6 +14,10 @@ You can find interactive API documentation at any Firefish instance /api-doc end You can also find more about firefish-js [here](../packages/firefish-js/README.md). +## Firefish's ActivityPub extensions + +You can also find more about Firefish's ActivityPub extensions [here](../docs/activitypub-extensions.md). + ## Environment build We support multiple methods to build a development environment, and you can choose the method you like. From 851b3fba1d7a17ebada97454a1a21a870132b870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Fri, 8 Mar 2024 22:30:24 +0800 Subject: [PATCH 31/55] feat: dev container use node-alpine image --- dev/docker/docker-compose.yml | 4 ++-- dev/docker/docker-entrypoint.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/docker/docker-compose.yml b/dev/docker/docker-compose.yml index 037ed4f8ff..c572f284c0 100644 --- a/dev/docker/docker-compose.yml +++ b/dev/docker/docker-compose.yml @@ -2,7 +2,7 @@ version: "3" services: web: - image: docker.io/node:21-slim + image: docker.io/node:21-alpine container_name: firefish_web restart: unless-stopped depends_on: @@ -35,7 +35,7 @@ services: db: restart: unless-stopped - image: docker.io/groonga/pgroonga:latest-alpine-15-slim + image: docker.io/groonga/pgroonga:latest-alpine-16-slim container_name: firefish_db networks: - firefishnet diff --git a/dev/docker/docker-entrypoint.sh b/dev/docker/docker-entrypoint.sh index 2a5303cb48..4f8341853e 100755 --- a/dev/docker/docker-entrypoint.sh +++ b/dev/docker/docker-entrypoint.sh @@ -7,8 +7,8 @@ node --version if [ ! -f '/.firefish_env_initialized' ]; then # Install compilation dependencies - apt-get update - DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends curl build-essential ca-certificates python3 postgresql-client-15 git + apk update + apk add --no-cache build-base linux-headers curl ca-certificates python3 git postgresql16-client zip unzip ffmpeg curl -vvv --proto '=https' --tlsv1.2 --show-error --fail https://sh.rustup.rs | sh -s -- -y # Add Cargo PATH From 1e013bffbc91abab07b954b3edd9742204e70274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Sat, 9 Mar 2024 00:24:22 +0800 Subject: [PATCH 32/55] Revert "feat: dev container use node-alpine image" This reverts commit 851b3fba1d7a17ebada97454a1a21a870132b870. --- dev/docker/docker-compose.yml | 4 ++-- dev/docker/docker-entrypoint.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/docker/docker-compose.yml b/dev/docker/docker-compose.yml index c572f284c0..037ed4f8ff 100644 --- a/dev/docker/docker-compose.yml +++ b/dev/docker/docker-compose.yml @@ -2,7 +2,7 @@ version: "3" services: web: - image: docker.io/node:21-alpine + image: docker.io/node:21-slim container_name: firefish_web restart: unless-stopped depends_on: @@ -35,7 +35,7 @@ services: db: restart: unless-stopped - image: docker.io/groonga/pgroonga:latest-alpine-16-slim + image: docker.io/groonga/pgroonga:latest-alpine-15-slim container_name: firefish_db networks: - firefishnet diff --git a/dev/docker/docker-entrypoint.sh b/dev/docker/docker-entrypoint.sh index 4f8341853e..2a5303cb48 100755 --- a/dev/docker/docker-entrypoint.sh +++ b/dev/docker/docker-entrypoint.sh @@ -7,8 +7,8 @@ node --version if [ ! -f '/.firefish_env_initialized' ]; then # Install compilation dependencies - apk update - apk add --no-cache build-base linux-headers curl ca-certificates python3 git postgresql16-client zip unzip ffmpeg + apt-get update + DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends curl build-essential ca-certificates python3 postgresql-client-15 git curl -vvv --proto '=https' --tlsv1.2 --show-error --fail https://sh.rustup.rs | sh -s -- -y # Add Cargo PATH From bd37b419df48138fef096ee84013d9344fcc2dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Mon, 11 Mar 2024 21:12:50 +0800 Subject: [PATCH 33/55] feat: dev container use postgres 16 and ffmpeg --- dev/docker/docker-compose.yml | 2 +- dev/docker/docker-entrypoint.sh | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dev/docker/docker-compose.yml b/dev/docker/docker-compose.yml index 037ed4f8ff..1a255caa7a 100644 --- a/dev/docker/docker-compose.yml +++ b/dev/docker/docker-compose.yml @@ -35,7 +35,7 @@ services: db: restart: unless-stopped - image: docker.io/groonga/pgroonga:latest-alpine-15-slim + image: docker.io/groonga/pgroonga:latest-alpine-16-slim container_name: firefish_db networks: - firefishnet diff --git a/dev/docker/docker-entrypoint.sh b/dev/docker/docker-entrypoint.sh index 2a5303cb48..ab82ff2d58 100755 --- a/dev/docker/docker-entrypoint.sh +++ b/dev/docker/docker-entrypoint.sh @@ -6,9 +6,19 @@ node --version # Check Environment Initialized Flag if [ ! -f '/.firefish_env_initialized' ]; then + # 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 - + # Install compilation dependencies apt-get update - DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends curl build-essential ca-certificates python3 postgresql-client-15 git + DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends build-essential python3 ffmpeg git postgresql-client-16 curl -vvv --proto '=https' --tlsv1.2 --show-error --fail https://sh.rustup.rs | sh -s -- -y # Add Cargo PATH From 308c3ff719b00c1985a0301706d17a8eeef421f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Mon, 11 Mar 2024 21:14:44 +0800 Subject: [PATCH 34/55] fix: not enough for minimum install --- dev/manually/README.md | 2 +- docs/install.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/manually/README.md b/dev/manually/README.md index e0c3bf6aee..b454b9de1d 100644 --- a/dev/manually/README.md +++ b/dev/manually/README.md @@ -22,7 +22,7 @@ reboot ```sh sudo apt update -sudo apt install -y -V wget curl git ca-certificates +sudo apt install -y -V wget curl git ca-certificates lsb-release gnupg ``` ## Install Node.js diff --git a/docs/install.md b/docs/install.md index a603046b99..5e6fba3a43 100644 --- a/docs/install.md +++ b/docs/install.md @@ -22,7 +22,7 @@ reboot ```sh sudo apt update -sudo apt install -y -V wget curl git ca-certificates +sudo apt install -y -V wget curl git ca-certificates lsb-release gnupg ``` ## Install Node.js From e4a72bbfe5bc2257bc1f85bbb6e8c8edd4892072 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 18 Mar 2024 03:29:17 +0900 Subject: [PATCH 35/55] Revert "backend: improve removeMentionedRemoteUsersColumn revert query (#403)" This reverts commit 347344287540a663d2ea4e7414a6e6e9bc8e6501. --- .../1710688552234-remove-mentioned-users-column.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/backend/src/migration/1710688552234-remove-mentioned-users-column.ts b/packages/backend/src/migration/1710688552234-remove-mentioned-users-column.ts index e2b1eed950..f2730f3cde 100644 --- a/packages/backend/src/migration/1710688552234-remove-mentioned-users-column.ts +++ b/packages/backend/src/migration/1710688552234-remove-mentioned-users-column.ts @@ -13,16 +13,8 @@ export class RemoveMentionedUsersColumn1710688552234 await queryRunner.query( `ALTER TABLE "note" ADD "mentionedRemoteUsers" TEXT NOT NULL DEFAULT '[]'::text`, ); - await queryRunner.query(`CREATE TEMP TABLE IF NOT EXISTS "temp_mentions" AS - SELECT "id", "url", "uri", "username", "host" - FROM "user" - JOIN "user_profile" ON "user"."id" = "user_profile". "userId" WHERE "user"."host" IS NOT NULL`); await queryRunner.query( - `CREATE UNIQUE INDEX "temp_mentions_id" ON "temp_mentions"("id")`, + `UPDATE "note" SET "mentionedRemoteUsers" = (SELECT COALESCE(json_agg(row_to_json("data"))::text, '[]') FROM (SELECT "url", "uri", "username", "host" FROM "user" JOIN "user_profile" ON "user"."id" = "user_profile". "userId" WHERE "user"."host" IS NOT NULL AND "user"."id" = ANY("note"."mentions")) AS "data")`, ); - await queryRunner.query(`UPDATE "note" SET "mentionedRemoteUsers" = ( - SELECT COALESCE(json_agg(row_to_json("data")::jsonb - 'id')::text, '[]') FROM "temp_mentions" AS "data" - WHERE "data"."id" = ANY("note"."mentions") - )`); } } From f7a8a58cb2fe1abf198b1acacfabf7f0ddcfdadf Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 18 Mar 2024 03:29:19 +0900 Subject: [PATCH 36/55] Revert "refactor: remove note.mentionedRemoteUsers column" This reverts commit 65797a934ac02bd7ad31ec6060f070196d19e2c4. --- ...688552234-remove-mentioned-users-column.ts | 20 ------------ packages/backend/src/models/entities/note.ts | 13 ++++++++ .../src/remote/activitypub/renderer/note.ts | 31 +++++++++---------- .../backend/src/services/messages/create.ts | 7 +++++ packages/backend/src/services/note/create.ts | 16 ++++++++++ packages/backend/src/services/note/delete.ts | 15 +++++---- 6 files changed, 58 insertions(+), 44 deletions(-) delete mode 100644 packages/backend/src/migration/1710688552234-remove-mentioned-users-column.ts diff --git a/packages/backend/src/migration/1710688552234-remove-mentioned-users-column.ts b/packages/backend/src/migration/1710688552234-remove-mentioned-users-column.ts deleted file mode 100644 index f2730f3cde..0000000000 --- a/packages/backend/src/migration/1710688552234-remove-mentioned-users-column.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class RemoveMentionedUsersColumn1710688552234 - implements MigrationInterface -{ - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "note" DROP COLUMN "mentionedRemoteUsers"`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "note" ADD "mentionedRemoteUsers" TEXT NOT NULL DEFAULT '[]'::text`, - ); - await queryRunner.query( - `UPDATE "note" SET "mentionedRemoteUsers" = (SELECT COALESCE(json_agg(row_to_json("data"))::text, '[]') FROM (SELECT "url", "uri", "username", "host" FROM "user" JOIN "user_profile" ON "user"."id" = "user_profile". "userId" WHERE "user"."host" IS NOT NULL AND "user"."id" = ANY("note"."mentions")) AS "data")`, - ); - } -} diff --git a/packages/backend/src/models/entities/note.ts b/packages/backend/src/models/entities/note.ts index e6fd892af3..a31dd7dd46 100644 --- a/packages/backend/src/models/entities/note.ts +++ b/packages/backend/src/models/entities/note.ts @@ -172,6 +172,12 @@ export class Note { }) public mentions: User["id"][]; + // FIXME: WHAT IS THIS + @Column("text", { + default: "[]", + }) + public mentionedRemoteUsers: string; + @Column("varchar", { length: 128, array: true, @@ -301,3 +307,10 @@ export class Note { } } } + +export type IMentionedRemoteUsers = { + uri: string; + url?: string; + username: string; + host: string; +}[]; diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts index bfa424242a..f3bce41aa7 100644 --- a/packages/backend/src/remote/activitypub/renderer/note.ts +++ b/packages/backend/src/remote/activitypub/renderer/note.ts @@ -1,6 +1,6 @@ import { In, IsNull } from "typeorm"; import config from "@/config/index.js"; -import type { Note } from "@/models/entities/note.js"; +import type { Note, IMentionedRemoteUsers } from "@/models/entities/note.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; import { DriveFiles, Notes, Users, Emojis, Polls } from "@/models/index.js"; import type { Emoji } from "@/models/entities/emoji.js"; @@ -61,34 +61,33 @@ export default async function renderNote( const attributedTo = `${config.url}/users/${note.userId}`; - const mentionedUsers = - note.mentions.length > 0 - ? await Users.findBy({ - id: In(note.mentions), - }) - : []; - - const mentionUris = mentionedUsers - // only remote users - .filter((user) => Users.isRemoteUser(user)) - .map((user) => user.uri); + const mentions = ( + JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers + ).map((x) => x.uri); let to: string[] = []; let cc: string[] = []; if (note.visibility === "public") { to = ["https://www.w3.org/ns/activitystreams#Public"]; - cc = [`${attributedTo}/followers`].concat(mentionUris); + cc = [`${attributedTo}/followers`].concat(mentions); } else if (note.visibility === "home") { to = [`${attributedTo}/followers`]; - cc = ["https://www.w3.org/ns/activitystreams#Public"].concat(mentionUris); + cc = ["https://www.w3.org/ns/activitystreams#Public"].concat(mentions); } else if (note.visibility === "followers") { to = [`${attributedTo}/followers`]; - cc = mentionUris; + cc = mentions; } else { - to = mentionUris; + to = mentions; } + const mentionedUsers = + note.mentions.length > 0 + ? await Users.findBy({ + id: In(note.mentions), + }) + : []; + const hashtagTags = (note.tags || []).map((tag) => renderHashtag(tag)); const mentionTags = mentionedUsers.map((u) => renderMention(u)); diff --git a/packages/backend/src/services/messages/create.ts b/packages/backend/src/services/messages/create.ts index 81d1614cb0..0b3f8eded9 100644 --- a/packages/backend/src/services/messages/create.ts +++ b/packages/backend/src/services/messages/create.ts @@ -134,6 +134,13 @@ export async function createMessage( userId: message.userId, visibility: "specified", mentions: [recipientUser].map((u) => u.id), + mentionedRemoteUsers: JSON.stringify( + [recipientUser].map((u) => ({ + uri: u.uri, + username: u.username, + host: u.host, + })), + ), } as Note; let renderedNote: Record = await renderNote( diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 16b2c1deed..fc9913e985 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -18,6 +18,7 @@ import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instanc import { extractMentions } from "@/misc/extract-mentions.js"; import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; import { extractHashtags } from "@/misc/extract-hashtags.js"; +import type { IMentionedRemoteUsers } from "@/models/entities/note.js"; import { Note } from "@/models/entities/note.js"; import { Mutings, @@ -750,6 +751,21 @@ async function insertNote( // Append mentions data if (mentionedUsers.length > 0) { insert.mentions = mentionedUsers.map((u) => u.id); + const profiles = await UserProfiles.findBy({ userId: In(insert.mentions) }); + insert.mentionedRemoteUsers = JSON.stringify( + mentionedUsers + .filter((u) => Users.isRemoteUser(u)) + .map((u) => { + const profile = profiles.find((p) => p.userId === u.id); + const url = profile != null ? profile.url : null; + return { + uri: u.uri, + url: url == null ? undefined : url, + username: u.username, + host: u.host, + } as IMentionedRemoteUsers[0]; + }), + ); } // 投稿を作成 diff --git a/packages/backend/src/services/note/delete.ts b/packages/backend/src/services/note/delete.ts index 8a42ddf2ae..988e1c8c48 100644 --- a/packages/backend/src/services/note/delete.ts +++ b/packages/backend/src/services/note/delete.ts @@ -1,4 +1,4 @@ -import { Brackets, In, IsNull, Not } from "typeorm"; +import { Brackets, In } from "typeorm"; import { publishNoteStream } from "@/services/stream.js"; import renderDelete from "@/remote/activitypub/renderer/delete.js"; import renderAnnounce from "@/remote/activitypub/renderer/announce.js"; @@ -7,7 +7,7 @@ import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderTombstone from "@/remote/activitypub/renderer/tombstone.js"; import config from "@/config/index.js"; import type { User, ILocalUser, IRemoteUser } from "@/models/entities/user.js"; -import type { Note } from "@/models/entities/note.js"; +import type { Note, IMentionedRemoteUsers } from "@/models/entities/note.js"; import { Notes, Users, Instances } from "@/models/index.js"; import { deliverToFollowers, @@ -147,12 +147,11 @@ async function getMentionedRemoteUsers(note: Note) { const where = [] as any[]; // mention / reply / dm - if (note.mentions.length > 0) { - where.push({ - id: In(note.mentions), - // only remote users, local users are on the server and do not need to be notified - host: Not(IsNull()), - }); + const uris = ( + JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers + ).map((x) => x.uri); + if (uris.length > 0) { + where.push({ uri: In(uris) }); } // renote / quote From af800833b4218eccf88e6c0e8ae3b73efa6aefe0 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 18 Mar 2024 03:47:57 +0900 Subject: [PATCH 37/55] fix: reflect revert to downgrade.sql --- docs/downgrade.sql | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/docs/downgrade.sql b/docs/downgrade.sql index a96d8c49db..1d26a6fa3b 100644 --- a/docs/downgrade.sql +++ b/docs/downgrade.sql @@ -2,7 +2,6 @@ BEGIN; DELETE FROM "migrations" WHERE name IN ( 'FixMutingIndices1710690239308', - 'RemoveMentionedUsersColumn1710688552234', 'NoteFile1710304584214', 'RenameMetaColumns1705944717480', 'SeparateHardMuteWordsAndPatterns1706413792769', @@ -30,19 +29,6 @@ CREATE INDEX "IDX_renote_muting_createdAt" ON "muting" ("createdAt"); CREATE INDEX "IDX_renote_muting_muteeId" ON "muting" ("muteeId"); CREATE INDEX "IDX_renote_muting_muterId" ON "muting" ("muterId"); --- remove-mentioned-users-column -ALTER TABLE "note" ADD "mentionedRemoteUsers" text NOT NULL DEFAULT '[]'::text; -CREATE TABLE "temp_mentions_1710688552234" AS - SELECT "id", "url", "uri", "username", "host" - FROM "user" - JOIN "user_profile" ON "user"."id" = "user_profile". "userId" WHERE "user"."host" IS NOT NULL; -CREATE UNIQUE INDEX "temp_mentions_id" ON "temp_mentions_1710688552234" ("id"); -UPDATE "note" SET "mentionedRemoteUsers" = ( - SELECT COALESCE(json_agg(row_to_json("data")::jsonb - 'id')::text, '[]') FROM "temp_mentions_1710688552234" AS "data" - WHERE "data"."id" = ANY("note"."mentions") -); -DROP TABLE "temp_mentions_1710688552234"; - -- note-file DROP TABLE "note_file"; From e6ba786b596d3379be0aa931f9412725ad892313 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 18 Mar 2024 19:54:42 +0900 Subject: [PATCH 38/55] fix (client): missing import --- packages/client/src/components/MkNotePreview.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/client/src/components/MkNotePreview.vue b/packages/client/src/components/MkNotePreview.vue index de24d46a90..454936dfbe 100644 --- a/packages/client/src/components/MkNotePreview.vue +++ b/packages/client/src/components/MkNotePreview.vue @@ -22,6 +22,7 @@ diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts index cf7ccf516e..35b54b20ec 100644 --- a/packages/client/src/router.ts +++ b/packages/client/src/router.ts @@ -320,6 +320,11 @@ export const routes = [ component: page(() => import("./pages/follow.vue")), loginRequired: true, }, + { + path: "/authorize_interaction", + component: page(() => import("./pages/authorize_interaction.vue")), + loginRequired: true, + }, { path: "/share", component: page(() => import("./pages/share.vue")), From bab5baba2a939e25000fc9bd2bc428e3601477e0 Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 00:49:37 +0900 Subject: [PATCH 41/55] docs: add links to other docs in changelog --- docs/changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 46241b97d3..9b909d0818 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,9 @@ Critical security updates are indicated by the :warning: icon. +- Server administrators should check [notice-for-admins.md](./notice-for-admins.md) as well. +- Third-party client/bot developers may want to check [api-change.md](./api-change.md) as well. + ## Unreleased - Introduce new full-text search engine and post search filters From 43b247ccd33a562866a256dbe3d7c96491d8e3d1 Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 00:51:12 +0900 Subject: [PATCH 42/55] docs: fix link to the container registry in install-container.md --- docs/install-container.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install-container.md b/docs/install-container.md index 6b304f772e..38852e6ebd 100644 --- a/docs/install-container.md +++ b/docs/install-container.md @@ -26,7 +26,7 @@ Everything else can be left as-is. ## Pull the container image -The image tag is [`registry.firefish.dev/firefish/firefish:latest`](https://firefish.dev/firefish/firefish/container_registry). +The image tag is [`registry.firefish.dev/firefish/firefish:latest`](https://firefish.dev/firefish/firefish/container_registry/1). ```sh docker pull registry.firefish.dev/firefish/firefish:latest From a5c4b8b56d4a75b07e95652402dbee93eef5567e Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 00:53:32 +0900 Subject: [PATCH 43/55] locale (minor): update en-US.yml --- locales/en-US.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 77564ec7bd..f5b597e3c9 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1193,7 +1193,7 @@ releaseToReload: "Release to reload" reloading: "Reloading" enableTimelineStreaming: "Update timelines automatically" searchWords: "Words to search / ID or URL to lookup" -searchWordsDescription: "To search for posts, enter the search term. Separate words +searchWordsDescription: "Enter the search term here to search for posts. Separate words with a space for an AND search, or 'OR' (without quotes) between words for an OR search.\nFor example, 'morning night' will find posts that contain both 'morning' and 'night', and 'morning OR night' will find posts that contain either 'morning' From 09d51cf838b1eef3ed5e4e3e6c82e2d1588f70eb Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 01:21:01 +0900 Subject: [PATCH 44/55] container: use fixed PGroonga version --- docker-compose.example.yml | 2 +- docs/notice-for-admins.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.example.yml b/docker-compose.example.yml index aaad55a158..fc6c0268a2 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -52,7 +52,7 @@ services: db: restart: unless-stopped - image: docker.io/groonga/pgroonga:latest-alpine-16-slim + image: docker.io/groonga/pgroonga:3.1.8-alpine-16-slim container_name: firefish_db networks: - calcnet diff --git a/docs/notice-for-admins.md b/docs/notice-for-admins.md index f763bf02ae..ff83668779 100644 --- a/docs/notice-for-admins.md +++ b/docs/notice-for-admins.md @@ -74,14 +74,14 @@ db: Please edit your `docker-compose.yml` to replace the database container image from `docker.io/postgres` to `docker.io/groonga/pgroonga`. -Please make sure to use the same PostgreSQL version. If you are using `docker.io/postgres:16-alpine` (PostgreSQL v16), the corresponding image tag is `docker.io/groonga/pgroonga:latest-alpine-16` (or `docker.io/groonga/pgroonga:latest-alpine-16-slim`). +The list of tags can be found on . Tags are named as `{PGroonga version}-{alpine or debian}-{PostgreSQL major version}`. -The list of tags can be found on . +Please make sure to use the same PostgreSQL version. If you are using `docker.io/postgres:16-alpine` (PostgreSQL v16), the corresponding image is `docker.io/groonga/pgroonga:3.1.8-alpine-16` (or `docker.io/groonga/pgroonga:3.1.8-alpine-16-slim`). There are also tags called `latest-alpine-16` and `latest-alpine-16-slim`, but please be careful if you use these tags since [PGroonga may introduce breaking changes](https://pgroonga.github.io/upgrade/), similar to PostgreSQL. ```yaml db: restart: unless-stopped - image: docker.io/groonga/pgroonga:latest-alpine-16-slim # change here + image: docker.io/groonga/pgroonga:3.1.8-alpine-16-slim # change here container_name: firefish_db ``` From 7359cf2fa95ccea4329c7b2515e2e6c0f771d608 Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 01:25:48 +0900 Subject: [PATCH 45/55] docs: add PGroonga install procedure for Fedora --- docs/notice-for-admins.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/docs/notice-for-admins.md b/docs/notice-for-admins.md index ff83668779..1255310abc 100644 --- a/docs/notice-for-admins.md +++ b/docs/notice-for-admins.md @@ -21,7 +21,7 @@ psql (PostgreSQL) 16.1 In this case, your PostgreSQL major version is `16`. -There are official installation instructions for many operating systems on , so please follow the instructions on this page. However, since many users are using Ubuntu, and there are no instructions for Arch Linux, we explicitly list the instructions for Ubuntu and Arch Linux here. Please keep in mind that this is not official information and the procedures may change. +There are official installation instructions for many operating systems on , so please follow the instructions on this page. However, since many users are using Ubuntu, and there are no instructions for Arch Linux and Fedora, we explicitly list the instructions for Ubuntu, Arch Linux and Fedora here. Please keep in mind that this is not official information and the procedures may change. ##### Ubuntu @@ -53,6 +53,39 @@ git clone https://aur.archlinux.org/pgroonga.git && cd pgroonga && makepkg -si # or yay -S pgroonga ``` +##### Fedora + +You need to build PGroonga from source and create a policy package. + +```sh +sudo dnf install make groonga-devel postgresql-server-devel redhat-rpm-config +wget https://packages.groonga.org/source/pgroonga/pgroonga-3.1.8.tar.gz +tar xvf pgroonga-3.1.8.tar.gz +cd pgroonga-3.1.8 +make +sudo make install +``` + +```sh +cat > pgroonga.te << EOF +module pgroonga 1.0; + +require { + type postgresql_t; + type postgresql_db_t; + class file map; +} + +allow postgresql_t postgresql_db_t:file map; +EOF +``` + +```sh +checkmodule -M -m -o pgroonga.mod pgroonga.te +semodule_package -o pgroonga.pp -m pgroonga.mod +sudo semodule -i pgroonga.pp +``` + #### 2. Enable PGroonga After the instllation, please execute this command to enable PGroonga: From 4ce20c52bd6528429a4d0de9781910b29aac9dbb Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 01:58:07 +0900 Subject: [PATCH 46/55] docs: remove outdated documents --- chart/.helmignore | 23 -- chart/Chart.yaml | 38 --- chart/README.md | 89 ------ chart/templates/NOTES.txt | 22 -- chart/templates/_helpers.tpl | 327 --------------------- chart/templates/deployment.yaml | 82 ------ chart/templates/hpa.yaml | 28 -- chart/templates/ingress.yaml | 61 ---- chart/templates/job-db-migrate.yaml | 59 ---- chart/templates/secret-config.yaml | 9 - chart/templates/service.yaml | 15 - chart/templates/serviceaccount.yaml | 12 - chart/templates/tests/test-connection.yaml | 15 - chart/values.yaml | 168 ----------- docs/fk.patch | 41 --- docs/kubernetes.md | 45 --- docs/migrate.md | 106 ------- docs/mkv13.patch | 45 --- docs/mkv13_restore.patch | 127 -------- docs/renote_muting.patch | 23 -- 20 files changed, 1335 deletions(-) delete mode 100644 chart/.helmignore delete mode 100644 chart/Chart.yaml delete mode 100644 chart/README.md delete mode 100644 chart/templates/NOTES.txt delete mode 100644 chart/templates/_helpers.tpl delete mode 100644 chart/templates/deployment.yaml delete mode 100644 chart/templates/hpa.yaml delete mode 100644 chart/templates/ingress.yaml delete mode 100644 chart/templates/job-db-migrate.yaml delete mode 100644 chart/templates/secret-config.yaml delete mode 100644 chart/templates/service.yaml delete mode 100644 chart/templates/serviceaccount.yaml delete mode 100644 chart/templates/tests/test-connection.yaml delete mode 100644 chart/values.yaml delete mode 100644 docs/fk.patch delete mode 100644 docs/kubernetes.md delete mode 100644 docs/migrate.md delete mode 100644 docs/mkv13.patch delete mode 100644 docs/mkv13_restore.patch delete mode 100644 docs/renote_muting.patch diff --git a/chart/.helmignore b/chart/.helmignore deleted file mode 100644 index 0e8a0eb36f..0000000000 --- a/chart/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/chart/Chart.yaml b/chart/Chart.yaml deleted file mode 100644 index 32a0c28446..0000000000 --- a/chart/Chart.yaml +++ /dev/null @@ -1,38 +0,0 @@ -apiVersion: v2 -name: firefish -description: A fun, new, open way to experience social media https://joinfirefish.org - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.2 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: 'v1.0.4-beta31' - -dependencies: - - name: elasticsearch - version: 19.0.1 - repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami - condition: elasticsearch.enabled - - name: postgresql - version: 11.1.3 - repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami - condition: postgresql.enabled - - name: redis - version: 16.13.2 - repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami - condition: redis.enabled diff --git a/chart/README.md b/chart/README.md deleted file mode 100644 index 1b80e11812..0000000000 --- a/chart/README.md +++ /dev/null @@ -1,89 +0,0 @@ -# firefish - -![Version: 0.1.2](https://img.shields.io/badge/Version-0.1.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: rc](https://img.shields.io/badge/AppVersion-rc-informational?style=flat-square) - -A fun, new, open way to experience social media https://joinfirefish.org - -## Requirements - -| Repository | Name | Version | -|------------|------|---------| -| https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | elasticsearch | 19.0.1 | -| https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | postgresql | 11.1.3 | -| https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | redis | 16.13.2 | - -## Values - -| Key | Type | Default | Description | -|-----|------|---------|-------------| -| affinity | object | `{}` | | -| autoscaling.enabled | bool | `false` | | -| autoscaling.maxReplicas | int | `100` | | -| autoscaling.minReplicas | int | `1` | | -| autoscaling.targetCPUUtilizationPercentage | int | `80` | | -| firefish.allowedPrivateNetworks | list | `[]` | If you want to allow firefish to connect to private ips, enter the cidrs here. | -| firefish.deepl.authKey | string | `""` | | -| firefish.deepl.isPro | bool | `false` | | -| firefish.deepl.managed | bool | `false` | | -| firefish.domain | string | `"firefish.local"` | | -| firefish.isManagedHosting | bool | `true` | | -| firefish.libreTranslate.apiKey | string | `""` | | -| firefish.libreTranslate.apiUrl | string | `""` | | -| firefish.libreTranslate.managed | bool | `false` | | -| firefish.objectStorage.access_key | string | `""` | | -| firefish.objectStorage.access_secret | string | `""` | | -| firefish.objectStorage.baseUrl | string | `""` | | -| firefish.objectStorage.bucket | string | `""` | | -| firefish.objectStorage.endpoint | string | `""` | | -| firefish.objectStorage.managed | bool | `true` | | -| firefish.objectStorage.prefix | string | `"files"` | | -| firefish.objectStorage.region | string | `""` | | -| firefish.reservedUsernames[0] | string | `"root"` | | -| firefish.reservedUsernames[1] | string | `"admin"` | | -| firefish.reservedUsernames[2] | string | `"administrator"` | | -| firefish.reservedUsernames[3] | string | `"me"` | | -| firefish.reservedUsernames[4] | string | `"system"` | | -| firefish.smtp.from_address | string | `"notifications@example.com"` | | -| firefish.smtp.login | string | `""` | | -| firefish.smtp.managed | bool | `true` | | -| firefish.smtp.password | string | `""` | | -| firefish.smtp.port | int | `587` | | -| firefish.smtp.server | string | `"smtp.mailgun.org"` | | -| firefish.smtp.useImplicitSslTls | bool | `false` | | -| elasticsearch | object | `{"auth":{},"enabled":false,"hostname":"","port":9200,"ssl":false}` | https://github.com/bitnami/charts/tree/master/bitnami/elasticsearch#parameters | -| fullnameOverride | string | `""` | | -| image.pullPolicy | string | `"IfNotPresent"` | | -| image.repository | string | `"registry.firefish.dev/firefish/firefish"` | | -| image.tag | string | `""` | | -| imagePullSecrets | list | `[]` | | -| ingress.annotations | object | `{}` | | -| ingress.className | string | `""` | | -| ingress.enabled | bool | `false` | | -| ingress.hosts[0].host | string | `"chart-example.local"` | | -| ingress.hosts[0].paths[0].path | string | `"/"` | | -| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | | -| ingress.tls | list | `[]` | | -| nameOverride | string | `""` | | -| nodeSelector | object | `{}` | | -| podAnnotations | object | `{}` | | -| podSecurityContext | object | `{}` | | -| postgresql.auth.database | string | `"firefish_production"` | | -| postgresql.auth.password | string | `""` | | -| postgresql.auth.username | string | `"firefish"` | | -| postgresql.enabled | bool | `true` | disable if you want to use an existing db; in which case the values below must match those of that external postgres instance | -| redis.auth.password | string | `""` | you must set a password; the password generated by the redis chart will be rotated on each upgrade: | -| redis.enabled | bool | `true` | | -| redis.hostname | string | `""` | | -| redis.port | int | `6379` | | -| replicaCount | int | `1` | | -| resources | object | `{}` | | -| securityContext | object | `{}` | | -| service.port | int | `80` | | -| service.type | string | `"ClusterIP"` | | -| serviceAccount.annotations | object | `{}` | | -| serviceAccount.create | bool | `true` | | -| serviceAccount.name | string | `""` | | -| tolerations | list | `[]` | | - ----------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/chart/templates/NOTES.txt b/chart/templates/NOTES.txt deleted file mode 100644 index e84ee93cf4..0000000000 --- a/chart/templates/NOTES.txt +++ /dev/null @@ -1,22 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "firefish.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "firefish.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "firefish.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "firefish.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl deleted file mode 100644 index 215d209eef..0000000000 --- a/chart/templates/_helpers.tpl +++ /dev/null @@ -1,327 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "firefish.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "firefish.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "firefish.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "firefish.labels" -}} -helm.sh/chart: {{ include "firefish.chart" . }} -{{ include "firefish.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "firefish.selectorLabels" -}} -app.kubernetes.io/name: {{ include "firefish.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "firefish.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "firefish.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} - -{{/* -Create a default fully qualified name for dependent services. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -*/}} -{{- define "firefish.elasticsearch.fullname" -}} -{{- printf "%s-%s" .Release.Name "elasticsearch" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{- define "firefish.redis.fullname" -}} -{{- printf "%s-%s" .Release.Name "redis" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{- define "firefish.postgresql.fullname" -}} -{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -config/default.yml content -*/}} -{{- define "firefish.configDir.default.yml" -}} -#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -# Firefish configuration -#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -# ┌─────┐ -#───┘ URL └───────────────────────────────────────────────────── - -# Final accessible URL seen by a user. -url: "https://{{ .Values.firefish.domain }}/" - -# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE -# URL SETTINGS AFTER THAT! - -# ┌───────────────────────┐ -#───┘ Port and TLS settings └─────────────────────────────────── - -# -# Firefish requires a reverse proxy to support HTTPS connections. -# -# +----- https://example.tld/ ------------+ -# +------+ |+-------------+ +----------------+| -# | User | ---> || Proxy (443) | ---> | Firefish (3000) || -# +------+ |+-------------+ +----------------+| -# +---------------------------------------+ -# -# You need to set up a reverse proxy. (e.g. nginx) -# An encrypted connection with HTTPS is highly recommended -# because tokens may be transferred in GET requests. - -# The port that your Firefish server should listen on. -port: 3000 - -# ┌──────────────────────────┐ -#───┘ PostgreSQL configuration └──────────────────────────────── - -db: - {{- if .Values.postgresql.enabled }} - host: {{ template "firefish.postgresql.fullname" . }} - port: 5432 - {{- else }} - host: {{ .Values.postgresql.postgresqlHostname }} - port: {{ .Values.postgresql.postgresqlPort | default 5432 }} - {{- end }} - - # Database name - db: {{ .Values.postgresql.auth.database }} - - # Auth - user: {{ .Values.postgresql.auth.username }} - pass: "{{ .Values.postgresql.auth.password }}" - - # Whether disable Caching queries - #disableCache: true - - # Extra Connection options - #extra: - # ssl: - # host: localhost - # rejectUnauthorized: false - -# ┌─────────────────────┐ -#───┘ Redis configuration └───────────────────────────────────── - -redis: - {{- if .Values.redis.enabled }} - host: {{ template "firefish.redis.fullname" . }}-master - {{- else }} - host: {{ required "When the redis chart is disabled .Values.redis.hostname is required" .Values.redis.hostname }} - {{- end }} - port: {{ .Values.redis.port | default 6379 }} - #family: 0 # 0=Both, 4=IPv4, 6=IPv6 - pass: {{ .Values.redis.auth.password | quote }} - #prefix: example-prefix - #db: 1 - #user: default - #tls: - # host: localhost - # rejectUnauthorized: false - -# ┌─────────────────────┐ -#───┘ Sonic configuration └───────────────────────────────────── - -#sonic: -# host: localhost -# port: 1491 -# auth: SecretPassword -# collection: notes -# bucket: default - -# ┌─────────────────────────────┐ -#───┘ Elasticsearch configuration └───────────────────────────── - -{{- if .Values.elasticsearch.enabled }} -elasticsearch: - host: {{ template "mastodon.elasticsearch.fullname" . }}-master-hl - port: 9200 - ssl: false -{{- else if .Values.elasticsearch.hostname }} -elasticsearch: - host: {{ .Values.elasticsearch.hostname | quote }} - port: {{ .Values.elasticsearch.port }} - ssl: {{ .Values.elasticsearch.ssl }} - {{- if .Values.elasticsearch.auth }} - user: {{ .Values.elasticsearch.auth.username | quote }} - pass: {{ .Values.elasticsearch.auth.password | quote }} - {{- end }} -{{- end }} - -# ┌───────────────┐ -#───┘ ID generation └─────────────────────────────────────────── - -# You can select the ID generation method. -# You don't usually need to change this setting, but you can -# change it according to your preferences. - -# Available methods: -# aid ... Short, Millisecond accuracy -# meid ... Similar to ObjectID, Millisecond accuracy -# ulid ... Millisecond accuracy -# objectid ... This is left for backward compatibility - -# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE -# ID SETTINGS AFTER THAT! - -id: 'aid' - -# ┌─────────────────────┐ -#───┘ Other configuration └───────────────────────────────────── - -# Max note length, should be < 8000. -#maxNoteLength: 3000 - -# Maximum lenght of an image caption or file comment (default 1500, max 8192) -#maxCaptionLength: 1500 - -# Reserved usernames that only the administrator can register with -reservedUsernames: {{ .Values.firefish.reservedUsernames | toJson }} - -# Whether disable HSTS -#disableHsts: true - -# Number of worker processes -#clusterLimit: 1 - -# Job concurrency per worker -# deliverJobConcurrency: 128 -# inboxJobConcurrency: 16 - -# Job rate limiter -# deliverJobPerSec: 128 -# inboxJobPerSec: 16 - -# Job attempts -# deliverJobMaxAttempts: 12 -# inboxJobMaxAttempts: 8 - -# IP address family used for outgoing request (ipv4, ipv6 or dual) -#outgoingAddressFamily: ipv4 - -# Syslog option -#syslog: -# host: localhost -# port: 514 - -# Proxy for HTTP/HTTPS -#proxy: http://127.0.0.1:3128 - -#proxyBypassHosts: [ -# 'example.com', -# '192.0.2.8' -#] - -# Proxy for SMTP/SMTPS -#proxySmtp: http://127.0.0.1:3128 # use HTTP/1.1 CONNECT -#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4 -#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5 - -# Media Proxy -#mediaProxy: https://example.com/proxy - -# Proxy remote files (default: false) -#proxyRemoteFiles: true - -allowedPrivateNetworks: {{ .Values.firefish.allowedPrivateNetworks | toJson }} - -# TWA -#twa: -# nameSpace: android_app -# packageName: tld.domain.twa -# sha256CertFingerprints: ['AB:CD:EF'] - -# Upload or download file size limits (bytes) -#maxFileSize: 262144000 - -# Managed hosting settings -# !!!!!!!!!! -# >>>>>> NORMAL SELF-HOSTERS, STAY AWAY! <<<<<< -# >>>>>> YOU DON'T NEED THIS! <<<<<< -# !!!!!!!!!! -# Each category is optional, but if each item in each category is mandatory! -# If you mess this up, that's on you, you've been warned... - -#maxUserSignups: 100 -isManagedHosting: {{ .Values.firefish.isManagedHosting }} -deepl: - managed: {{ .Values.firefish.deepl.managed }} - authKey: {{ .Values.firefish.deepl.authKey | quote}} - isPro: {{ .Values.firefish.deepl.isPro }} - -libreTranslate: - managed: {{ .Values.firefish.libreTranslate.managed }} - apiUrl: {{ .Values.firefish.libreTranslate.apiUrl | quote }} - apiKey: {{ .Values.firefish.libreTranslate.apiKey | quote }} - -email: - managed: {{ .Values.firefish.smtp.managed }} - address: {{ .Values.firefish.smtp.from_address | quote }} - host: {{ .Values.firefish.smtp.server | quote }} - port: {{ .Values.firefish.smtp.port }} - user: {{ .Values.firefish.smtp.login | quote }} - pass: {{ .Values.firefish.smtp.password | quote }} - useImplicitSslTls: {{ .Values.firefish.smtp.useImplicitSslTls }} -objectStorage: - managed: {{ .Values.firefish.objectStorage.managed }} - baseUrl: {{ .Values.firefish.objectStorage.baseUrl | quote }} - bucket: {{ .Values.firefish.objectStorage.bucket | quote }} - prefix: {{ .Values.firefish.objectStorage.prefix | quote }} - endpoint: {{ .Values.firefish.objectStorage.endpoint | quote }} - region: {{ .Values.firefish.objectStorage.region | quote }} - accessKey: {{ .Values.firefish.objectStorage.access_key | quote }} - secretKey: {{ .Values.firefish.objectStorage.access_secret | quote }} - useSsl: true - connnectOverProxy: false - setPublicReadOnUpload: true - s3ForcePathStyle: true - -# !!!!!!!!!! -# >>>>>> AGAIN, NORMAL SELF-HOSTERS, STAY AWAY! <<<<<< -# >>>>>> YOU DON'T NEED THIS, ABOVE SETTINGS ARE FOR MANAGED HOSTING ONLY! <<<<<< -# !!!!!!!!!! - -# Seriously. Do NOT fill out the above settings if you're self-hosting. -# They're much better off being set from the control panel. -{{- end }} diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml deleted file mode 100644 index ca63167632..0000000000 --- a/chart/templates/deployment.yaml +++ /dev/null @@ -1,82 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "firefish.fullname" . }} - labels: - {{- include "firefish.labels" . | nindent 4 }} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "firefish.selectorLabels" . | nindent 6 }} - template: - metadata: - annotations: - checksum/secret-config: {{ include ( print $.Template.BasePath "/secret-config.yaml" ) . | sha256sum | quote }} - {{- with .Values.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "firefish.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "firefish.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - volumes: - - name: config-volume - secret: - secretName: {{ template "firefish.fullname" . }}-config - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - command: - - pnpm - - run - - start - env: - - name: "NODE_ENV" - value: "production" - volumeMounts: - - name: config-volume - mountPath: /firefish/.config - ports: - - name: http - containerPort: 3000 - protocol: TCP - startupProbe: - httpGet: - path: / - port: http - failureThreshold: 30 - periodSeconds: 10 - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/chart/templates/hpa.yaml b/chart/templates/hpa.yaml deleted file mode 100644 index db19534a87..0000000000 --- a/chart/templates/hpa.yaml +++ /dev/null @@ -1,28 +0,0 @@ -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "firefish.fullname" . }} - labels: - {{- include "firefish.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "firefish.fullname" . }} - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} diff --git a/chart/templates/ingress.yaml b/chart/templates/ingress.yaml deleted file mode 100644 index 65caa43e89..0000000000 --- a/chart/templates/ingress.yaml +++ /dev/null @@ -1,61 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "firefish.fullname" . -}} -{{- $svcPort := .Values.service.port -}} -{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} - {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} - {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} - {{- end }} -{{- end }} -{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1 -{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - {{- include "firefish.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} - ingressClassName: {{ .Values.ingress.className }} - {{- end }} - {{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} - {{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ .path }} - {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} - pathType: {{ .pathType }} - {{- end }} - backend: - {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} - service: - name: {{ $fullName }} - port: - number: {{ $svcPort }} - {{- else }} - serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} diff --git a/chart/templates/job-db-migrate.yaml b/chart/templates/job-db-migrate.yaml deleted file mode 100644 index 1aedeab5b1..0000000000 --- a/chart/templates/job-db-migrate.yaml +++ /dev/null @@ -1,59 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ include "firefish.fullname" . }}-db-migrate - labels: - {{- include "firefish.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": post-install,pre-upgrade - "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded - "helm.sh/hook-weight": "-2" -spec: - template: - metadata: - name: {{ include "firefish.fullname" . }}-db-migrate - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - spec: - restartPolicy: Never - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "firefish.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - volumes: - - name: config-volume - secret: - secretName: {{ template "firefish.fullname" . }}-config - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - command: - - pnpm - - run - - migrate - env: - - name: "NODE_ENV" - value: "production" - volumeMounts: - - name: config-volume - mountPath: /firefish/.config - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/chart/templates/secret-config.yaml b/chart/templates/secret-config.yaml deleted file mode 100644 index 9f683cfcd8..0000000000 --- a/chart/templates/secret-config.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: {{ template "firefish.fullname" . }}-config - labels: - {{- include "firefish.labels" . | nindent 4 }} -type: Opaque -data: - default.yml: {{ include "firefish.configDir.default.yml" . | b64enc }} diff --git a/chart/templates/service.yaml b/chart/templates/service.yaml deleted file mode 100644 index f49d9cd5d7..0000000000 --- a/chart/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "firefish.fullname" . }} - labels: - {{- include "firefish.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "firefish.selectorLabels" . | nindent 4 }} diff --git a/chart/templates/serviceaccount.yaml b/chart/templates/serviceaccount.yaml deleted file mode 100644 index d8db3a3ae2..0000000000 --- a/chart/templates/serviceaccount.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "firefish.serviceAccountName" . }} - labels: - {{- include "firefish.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/chart/templates/tests/test-connection.yaml b/chart/templates/tests/test-connection.yaml deleted file mode 100644 index 7abe03611a..0000000000 --- a/chart/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "firefish.fullname" . }}-test-connection" - labels: - {{- include "firefish.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "firefish.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/chart/values.yaml b/chart/values.yaml deleted file mode 100644 index d8c6b7175b..0000000000 --- a/chart/values.yaml +++ /dev/null @@ -1,168 +0,0 @@ -# Default values for firefish. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: registry.firefish.dev/firefish/firefish - pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "" - -firefish: - isManagedHosting: true - domain: firefish.local - - deepl: - managed: false - authKey: "" - isPro: false - - libreTranslate: - managed: false - apiUrl: "" - apiKey: "" - - smtp: - managed: true - from_address: notifications@example.com - port: 587 - server: smtp.mailgun.org - useImplicitSslTls: false - login: "" - password: "" - - objectStorage: - managed: true - access_key: "" - access_secret: "" - baseUrl: "" # e.g. "https://my-bucket.nyc3.cdn.digitaloceanspaces.com" - bucket: "" # e.g. "my-bucket" - prefix: files - endpoint: "" # e.g. "nyc3.digitaloceanspaces.com:443" - region: "" # e.g. "nyc3" - - # -- If you want to allow firefish to connect to private ips, enter the cidrs here. - allowedPrivateNetworks: [] - # - "10.0.0.0/8" - - reservedUsernames: - - root - - admin - - administrator - - me - - system - -# https://github.com/bitnami/charts/tree/master/bitnami/postgresql#parameters -postgresql: - # -- disable if you want to use an existing db; in which case the values below - # must match those of that external postgres instance - enabled: true - # postgresqlHostname: preexisting-postgresql - # postgresqlPort: 5432 - auth: - database: firefish_production - username: firefish - # you must set a password; the password generated by the postgresql chart will - # be rotated on each upgrade: - # https://github.com/bitnami/charts/tree/master/bitnami/postgresql#upgrade - password: "" - -# https://github.com/bitnami/charts/tree/master/bitnami/redis#parameters -redis: - # disable if you want to use an existing redis instance; in which case the - # values below must match those of that external redis instance - enabled: true - hostname: "" - port: 6379 - auth: - # -- you must set a password; the password generated by the redis chart will be - # rotated on each upgrade: - password: "" - -# -- https://github.com/bitnami/charts/tree/master/bitnami/elasticsearch#parameters -elasticsearch: - # disable if you want to use an existing redis instance; in which case the - # values below must match those of that external elasticsearch instance - enabled: false - hostname: "" - port: 9200 - ssl: false - auth: {} - # username: "" - # password: "" - # @ignored - image: - tag: 7 - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: true - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" - -podAnnotations: {} - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - className: "" - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: chart-example.local - paths: - - path: / - pathType: ImplementationSpecific - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -nodeSelector: {} - -tolerations: [] - -affinity: {} diff --git a/docs/fk.patch b/docs/fk.patch deleted file mode 100644 index 2d51512c96..0000000000 --- a/docs/fk.patch +++ /dev/null @@ -1,41 +0,0 @@ -diff --git a/packages/backend/migration/1661376843000-remove-mentioned-remote-users-column.js b/packages/backend/migration/1661376843000-remove-mentioned-remote-users-column.js -index 42d79b5b5..1fd5e0f10 100644 ---- a/packages/backend/migration/1661376843000-remove-mentioned-remote-users-column.js -+++ b/packages/backend/migration/1661376843000-remove-mentioned-remote-users-column.js -@@ -7,6 +7,22 @@ export class removeMentionedRemoteUsersColumn1661376843000 { - - async down(queryRunner) { - await queryRunner.query(`ALTER TABLE "note" ADD "mentionedRemoteUsers" TEXT NOT NULL DEFAULT '[]'::text`); -- await queryRunner.query(`UPDATE "note" SET "mentionedRemoteUsers" = (SELECT COALESCE(json_agg(row_to_json("data"))::text, '[]') FROM (SELECT "url", "uri", "username", "host" FROM "user" JOIN "user_profile" ON "user"."id" = "user_profile". "userId" WHERE "user"."host" IS NOT NULL AND "user"."id" = ANY("note"."mentions")) AS "data")`); -+ await queryRunner.query(` -+ CREATE TEMP TABLE IF NOT EXISTS "temp_mentions" AS -+ SELECT "id", "url", "uri", "username", "host" -+ FROM "user" -+ JOIN "user_profile" ON "user"."id" = "user_profile"."userId" WHERE "user"."host" IS NOT NULL -+ `); -+ -+ await queryRunner.query(` -+ CREATE UNIQUE INDEX "temp_mentions_id" ON "temp_mentions"("id") -+ `); -+ -+ await queryRunner.query(` -+ UPDATE "note" SET "mentionedRemoteUsers" = ( -+ SELECT COALESCE(json_agg(row_to_json("data")::jsonb - 'id')::text, '[]') FROM "temp_mentions" AS "data" -+ WHERE "data"."id" = ANY("note"."mentions") -+ ) -+ `); - } - } -diff --git a/packages/backend/migration/1663399074403-resize-comments-drive-file.js b/packages/backend/migration/1663399074403-resize-comments-drive-file.js -index a037f1655..0873aec9b 100644 ---- a/packages/backend/migration/1663399074403-resize-comments-drive-file.js -+++ b/packages/backend/migration/1663399074403-resize-comments-drive-file.js -@@ -9,6 +9,6 @@ export class resizeCommentsDriveFile1663399074403 { - } - - async down(queryRunner) { -- await queryRunner.query(`ALTER TABLE "drive_file" ALTER COLUMN "comment" TYPE character varying(512)`); -- } -+ console.log('This migration cannot be reverted, skipping...'); -+ } - } diff --git a/docs/kubernetes.md b/docs/kubernetes.md deleted file mode 100644 index 5ec6b46ad2..0000000000 --- a/docs/kubernetes.md +++ /dev/null @@ -1,45 +0,0 @@ -# Running a Firefish server with Kubernetes and Helm - -This is a [Helm](https://helm.sh/) chart directory in the root of the project -that you can use to deploy firefish to a Kubernetes cluster - -## Deployment - -1. Copy the example helm values and make your changes: -```shell -cp .config/helm_values_example.yml .config/helm_values.yml -``` - -2. Update helm dependencies: -```shell -cd chart -helm dependency list $dir 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done; -cd ../ -``` - -3. Create the firefish helm release (also used to update existing deployment): -```shell -helm upgrade \ - --install \ - --namespace firefish \ - --create-namespace \ - firefish chart/ \ - -f .config/helm_values.yml -``` - -4. Watch your firefish server spin up: -```shell -kubectl -n firefish get po -w -``` - -5. Initial the admin user and managed config: -```shell -export firefish_USERNAME="my_desired_admin_handle" && \ -export firefish_PASSWORD="myDesiredInitialPassword" && \ -export firefish_HOST="firefish.example.com" && \ -export firefish_TOKEN=$(curl -X POST https://$firefish_HOST/api/admin/accounts/create -H "Content-Type: application/json" -d "{ \"username\":\"$firefish_USERNAME\", \"password\":\"$firefish_PASSWORD\" }" | jq -r '.token') && \ -echo "Save this token: ${firefish_TOKEN}" && \ -curl -X POST -H "Authorization: Bearer $firefish_TOKEN" https://$firefish_HOST/api/admin/accounts/hosted -``` - -6. Enjoy! diff --git a/docs/migrate.md b/docs/migrate.md deleted file mode 100644 index 77c7377f7a..0000000000 --- a/docs/migrate.md +++ /dev/null @@ -1,106 +0,0 @@ -# Migrating from Misskey/FoundKey to Firefish - -All the guides below assume you're starting in the root of the repo directory. - -### Before proceeding - -- **Ensure you have stopped all master and worker processes of Misskey.** -- **Ensure you have backups of the database before performing any commands.** - -## Misskey v13 and above - -Tested with Misskey v13.11.3. - -If your Misskey v13 is older, we recommend updating your Misskey to v13.11.3. - -```sh -wget -O mkv13.patch https://firefish.dev/firefish/firefish/-/raw/develop/docs/mkv13.patch -wget -O mkv13_restore.patch https://firefish.dev/firefish/firefish/-/raw/develop/docs/mkv13_restore.patch -git apply mkv13.patch mkv13_restore.patch - -cd packages/backend - -LINE_NUM="$(pnpm typeorm migration:show -d ormconfig.js | grep -n activeEmailValidation1657346559800 | cut -d ':' -f 1)" -NUM_MIGRATIONS="$(pnpm typeorm migration:show -d ormconfig.js | tail -n+"$LINE_NUM" | grep '\[X\]' | wc -l)" - -for i in $(seq 1 $NUM_MIGRATIONS); do pnpm typeorm migration:revert -d ormconfig.js; done - -cd ../../ - -git remote set-url origin https://firefish.dev/firefish/firefish.git -git fetch origin -git stash push -rm -rf fluent-emojis misskey-assets -git switch main # or beta or develop -git pull --ff -wget -O renote_muting.patch https://firefish.dev/firefish/firefish/-/raw/develop/docs/renote_muting.patch -git apply renote_muting.patch - -pnpm install -NODE_ENV=production pnpm run build -pnpm run migrate -git stash push -``` - -Depending on the version you're migrating from, you may have to open Postgres with `psql -d your_database` and run the following commands: - -```sql -ALTER TABLE "meta" ADD COLUMN "disableLocalTimeline" boolean DEFAULT false; -ALTER TABLE "meta" ADD COLUMN "disableGlobalTimeline" boolean DEFAULT false; -ALTER TABLE "meta" ADD COLUMN "localDriveCapacityMb" integer DEFAULT 512; -ALTER TABLE "meta" ADD COLUMN "remoteDriveCapacityMb" integer DEFAULT 128; -ALTER TABLE "user" ADD COLUMN "isSilenced" boolean DEFAULT false; -ALTER TABLE "user" ADD COLUMN "isAdmin" boolean DEFAULT false; -ALTER TABLE "user" ADD COLUMN "isModerator" boolean DEFAULT false; -ALTER TABLE "user" ADD COLUMN "remoteDriveCapacityMb" integer DEFAULT 128; -ALTER TABLE "user" ADD COLUMN "driveCapacityOverrideMb" integer DEFAULT 128; -ALTER TABLE "instance" ADD COLUMN "caughtAt" date; -ALTER TABLE "instance" ADD COLUMN "latestRequestSentAt" date; -ALTER TABLE "instance" ADD COLUMN "latestStatus" character varying(512); -ALTER TABLE "instance" ADD COLUMN "lastCommunicatedAt" date; -``` - -then quit with `\q`, and restart Firefish. - -Note: Ignore errors of `column "xxx" of relation "xxx" already exists`. - -If no other errors happened, your Firefish is ready to launch! - -## Misskey v12.119 and before - -```sh -git remote set-url origin https://firefish.dev/firefish/firefish.git -git fetch -git checkout main # or beta or develop -git pull --ff - -NODE_ENV=production pnpm run migrate -# build using prefered method -``` - -## FoundKey - -```sh -wget -O fk.patch https://firefish.dev/firefish/firefish/-/raw/develop/docs/fk.patch -git apply fk.patch -cd packages/backend - -LINE_NUM="$(npx typeorm migration:show -d ormconfig.js | grep -n uniformThemecolor1652859567549 | cut -d ':' -f 1)" -NUM_MIGRATIONS="$(npx typeorm migration:show -d ormconfig.js | tail -n+"$LINE_NUM" | grep '\[X\]' | wc -l)" - -for i in $(seq 1 $NUM_MIGRATIONS); do - npx typeorm migration:revert -d ormconfig.js -done - -git remote set-url origin https://firefish.dev/firefish/firefish.git -git fetch -git checkout main # or beta or develop -git pull --ff - -NODE_ENV=production pnpm run migrate -# build using prefered method -``` - -## Reverse - -You ***cannot*** migrate back to Misskey from Firefish due to re-hashing passwords on signin with argon2. You can migrate to [Sharkey](https://github.com/transfem-org/Sharkey), a soft fork of Misskey that uses argon2 though. You can also migrate from Firefish to FoundKey, although this is not recommended due to FoundKey being end-of-life, and may have some problems with alt-text. diff --git a/docs/mkv13.patch b/docs/mkv13.patch deleted file mode 100644 index e6106b16f2..0000000000 --- a/docs/mkv13.patch +++ /dev/null @@ -1,45 +0,0 @@ -diff --git a/packages/backend/migration/1672704017999-remove-lastCommunicatedAt.js b/packages/backend/migration/1672704017999-remove-lastCommunicatedAt.js -index 38a676985..c4ae690e0 100644 ---- a/packages/backend/migration/1672704017999-remove-lastCommunicatedAt.js -+++ b/packages/backend/migration/1672704017999-remove-lastCommunicatedAt.js -@@ -6,6 +6,8 @@ export class removeLastCommunicatedAt1672704017999 { - } - - async down(queryRunner) { -- await queryRunner.query(`ALTER TABLE "instance" ADD "lastCommunicatedAt" TIMESTAMP WITH TIME ZONE NOT NULL`); -+ await queryRunner.query(`ALTER TABLE "instance" ADD "lastCommunicatedAt" TIMESTAMP WITH TIME ZONE`); -+ await queryRunner.query(`UPDATE "instance" SET "lastCommunicatedAt" = COALESCE("infoUpdatedAt", "caughtAt")`); -+ await queryRunner.query(`ALTER TABLE "instance" ALTER COLUMN "lastCommunicatedAt" SET NOT NULL`); - } - } -diff --git a/packages/backend/migration/1673336077243-PollChoiceLength.js b/packages/backend/migration/1673336077243-PollChoiceLength.js -index 810c626e0..5809528cb 100644 ---- a/packages/backend/migration/1673336077243-PollChoiceLength.js -+++ b/packages/backend/migration/1673336077243-PollChoiceLength.js -@@ -6,6 +6,6 @@ export class PollChoiceLength1673336077243 { - } - - async down(queryRunner) { -- await queryRunner.query(`ALTER TABLE "poll" ALTER COLUMN "choices" TYPE character varying(128) array`); -+ //await queryRunner.query(`ALTER TABLE "poll" ALTER COLUMN "choices" TYPE character varying(128) array`); - } - } -diff --git a/packages/backend/migration/1674118260469-achievement.js b/packages/backend/migration/1674118260469-achievement.js -index 131ab96f8..57a922f83 100644 ---- a/packages/backend/migration/1674118260469-achievement.js -+++ b/packages/backend/migration/1674118260469-achievement.js -@@ -18,12 +18,13 @@ export class achievement1674118260469 { - - async down(queryRunner) { - await queryRunner.query(`CREATE TYPE "public"."user_profile_mutingnotificationtypes_enum_old" AS ENUM('follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app', 'pollEnded')`); -+ await queryRunner.query(`CREATE TYPE "public"."notification_type_enum_old" AS ENUM('follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app')`); - await queryRunner.query(`ALTER TABLE "user_profile" ALTER COLUMN "mutingNotificationTypes" DROP DEFAULT`); - await queryRunner.query(`ALTER TABLE "user_profile" ALTER COLUMN "mutingNotificationTypes" TYPE "public"."user_profile_mutingnotificationtypes_enum_old"[] USING "mutingNotificationTypes"::"text"::"public"."user_profile_mutingnotificationtypes_enum_old"[]`); - await queryRunner.query(`ALTER TABLE "user_profile" ALTER COLUMN "mutingNotificationTypes" SET DEFAULT '{}'`); - await queryRunner.query(`DROP TYPE "public"."user_profile_mutingnotificationtypes_enum"`); - await queryRunner.query(`ALTER TYPE "public"."user_profile_mutingnotificationtypes_enum_old" RENAME TO "user_profile_mutingnotificationtypes_enum"`); -- await queryRunner.query(`CREATE TYPE "public"."notification_type_enum_old" AS ENUM('follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app')`); -+ await queryRunner.query(`DELETE FROM "public"."notification" WHERE "type" = 'achievementEarned'`); - await queryRunner.query(`ALTER TABLE "notification" ALTER COLUMN "type" TYPE "public"."notification_type_enum_old" USING "type"::"text"::"public"."notification_type_enum_old"`); - await queryRunner.query(`DROP TYPE "public"."notification_type_enum"`); - await queryRunner.query(`ALTER TYPE "public"."notification_type_enum_old" RENAME TO "notification_type_enum"`); diff --git a/docs/mkv13_restore.patch b/docs/mkv13_restore.patch deleted file mode 100644 index 9ef9934edc..0000000000 --- a/docs/mkv13_restore.patch +++ /dev/null @@ -1,127 +0,0 @@ -diff --git a/packages/backend/migration/1680491187535-cleanup.js b/packages/backend/migration/1680491187535-cleanup.js -index 1e609ca06..0e6accf3e 100644 ---- a/packages/backend/migration/1680491187535-cleanup.js -+++ b/packages/backend/migration/1680491187535-cleanup.js -@@ -1,10 +1,40 @@ - export class cleanup1680491187535 { -- name = 'cleanup1680491187535' -+ name = "cleanup1680491187535"; - -- async up(queryRunner) { -- await queryRunner.query(`DROP TABLE "antenna_note" `); -- } -+ async up(queryRunner) { -+ await queryRunner.query(`DROP TABLE "antenna_note" `); -+ } - -- async down(queryRunner) { -- } -+ async down(queryRunner) { -+ await queryRunner.query( -+ `CREATE TABLE antenna_note ( id character varying(32) NOT NULL, "noteId" character varying(32) NOT NULL, "antennaId" character varying(32) NOT NULL, read boolean DEFAULT false NOT NULL)`, -+ ); -+ await queryRunner.query( -+ `COMMENT ON COLUMN antenna_note."noteId" IS 'The note ID.'`, -+ ); -+ await queryRunner.query( -+ `COMMENT ON COLUMN antenna_note."antennaId" IS 'The antenna ID.'`, -+ ); -+ await queryRunner.query( -+ `ALTER TABLE ONLY antenna_note ADD CONSTRAINT "PK_fb28d94d0989a3872df19fd6ef8" PRIMARY KEY (id)`, -+ ); -+ await queryRunner.query( -+ `CREATE INDEX "IDX_0d775946662d2575dfd2068a5f" ON antenna_note USING btree ("antennaId")`, -+ ); -+ await queryRunner.query( -+ `CREATE UNIQUE INDEX "IDX_335a0bf3f904406f9ef3dd51c2" ON antenna_note USING btree ("noteId", "antennaId")`, -+ ); -+ await queryRunner.query( -+ `CREATE INDEX "IDX_9937ea48d7ae97ffb4f3f063a4" ON antenna_note USING btree (read)`, -+ ); -+ await queryRunner.query( -+ `CREATE INDEX "IDX_bd0397be22147e17210940e125" ON antenna_note USING btree ("noteId")`, -+ ); -+ await queryRunner.query( -+ `ALTER TABLE ONLY antenna_note ADD CONSTRAINT "FK_0d775946662d2575dfd2068a5f5" FOREIGN KEY ("antennaId") REFERENCES antenna(id) ON DELETE CASCADE`, -+ ); -+ await queryRunner.query( -+ `ALTER TABLE ONLY antenna_note ADD CONSTRAINT "FK_bd0397be22147e17210940e125b" FOREIGN KEY ("noteId") REFERENCES note(id) ON DELETE CASCADE`, -+ ); -+ } - } -diff --git a/packages/backend/migration/1680582195041-cleanup.js b/packages/backend/migration/1680582195041-cleanup.js -index c587e456a..a91d6ff3c 100644 ---- a/packages/backend/migration/1680582195041-cleanup.js -+++ b/packages/backend/migration/1680582195041-cleanup.js -@@ -1,11 +1,64 @@ - export class cleanup1680582195041 { -- name = 'cleanup1680582195041' -+ name = "cleanup1680582195041"; - -- async up(queryRunner) { -- await queryRunner.query(`DROP TABLE "notification" `); -- } -+ async up(queryRunner) { -+ await queryRunner.query(`DROP TABLE "notification"`); -+ } - -- async down(queryRunner) { -- -- } -+ async down(queryRunner) { -+ await queryRunner.query( -+ `CREATE TABLE notification ( id character varying(32) NOT NULL, "createdAt" timestamp with time zone NOT NULL, "notifieeId" character varying(32) NOT NULL, "notifierId" character varying(32), "isRead" boolean DEFAULT false NOT NULL, "noteId" character varying(32), reaction character varying(128), choice integer, "followRequestId" character varying(32), type notification_type_enum NOT NULL, "customBody" character varying(2048), "customHeader" character varying(256), "customIcon" character varying(1024), "appAccessTokenId" character varying(32), achievement character varying(128))`, -+ ); -+ await queryRunner.query( -+ `COMMENT ON COLUMN notification."createdAt" IS 'The created date of the Notification.'`, -+ ); -+ await queryRunner.query( -+ `COMMENT ON COLUMN notification."notifieeId" IS 'The ID of recipient user of the Notification.'`, -+ ); -+ await queryRunner.query( -+ `COMMENT ON COLUMN notification."notifierId" IS 'The ID of sender user of the Notification.'`, -+ ); -+ await queryRunner.query( -+ `COMMENT ON COLUMN notification."isRead" IS 'Whether the Notification is read.'`, -+ ); -+ await queryRunner.query( -+ `COMMENT ON COLUMN notification.type IS 'The type of the Notification.'`, -+ ); -+ await queryRunner.query( -+ `ALTER TABLE ONLY notification ADD CONSTRAINT "PK_705b6c7cdf9b2c2ff7ac7872cb7" PRIMARY KEY (id)`, -+ ); -+ await queryRunner.query( -+ `CREATE INDEX "IDX_080ab397c379af09b9d2169e5b" ON notification USING btree ("isRead")`, -+ ); -+ await queryRunner.query( -+ `CREATE INDEX "IDX_33f33cc8ef29d805a97ff4628b" ON notification USING btree (type)`, -+ ); -+ await queryRunner.query( -+ `CREATE INDEX "IDX_3b4e96eec8d36a8bbb9d02aa71" ON notification USING btree ("notifierId")`, -+ ); -+ await queryRunner.query( -+ `CREATE INDEX "IDX_3c601b70a1066d2c8b517094cb" ON notification USING btree ("notifieeId")`, -+ ); -+ await queryRunner.query( -+ `CREATE INDEX "IDX_b11a5e627c41d4dc3170f1d370" ON notification USING btree ("createdAt")`, -+ ); -+ await queryRunner.query( -+ `CREATE INDEX "IDX_e22bf6bda77b6adc1fd9e75c8c" ON notification USING btree ("appAccessTokenId")`, -+ ); -+ await queryRunner.query( -+ `ALTER TABLE ONLY notification ADD CONSTRAINT "FK_3b4e96eec8d36a8bbb9d02aa710" FOREIGN KEY ("notifierId") REFERENCES "user"(id) ON DELETE CASCADE`, -+ ); -+ await queryRunner.query( -+ `ALTER TABLE ONLY notification ADD CONSTRAINT "FK_3c601b70a1066d2c8b517094cb9" FOREIGN KEY ("notifieeId") REFERENCES "user"(id) ON DELETE CASCADE`, -+ ); -+ await queryRunner.query( -+ `ALTER TABLE ONLY notification ADD CONSTRAINT "FK_769cb6b73a1efe22ddf733ac453" FOREIGN KEY ("noteId") REFERENCES note(id) ON DELETE CASCADE`, -+ ); -+ await queryRunner.query( -+ `ALTER TABLE ONLY notification ADD CONSTRAINT "FK_bd7fab507621e635b32cd31892c" FOREIGN KEY ("followRequestId") REFERENCES follow_request(id) ON DELETE CASCADE`, -+ ); -+ await queryRunner.query( -+ `ALTER TABLE ONLY notification ADD CONSTRAINT "FK_e22bf6bda77b6adc1fd9e75c8c9" FOREIGN KEY ("appAccessTokenId") REFERENCES access_token(id) ON DELETE CASCADE`, -+ ); -+ } - } diff --git a/docs/renote_muting.patch b/docs/renote_muting.patch deleted file mode 100644 index c5bd2818c6..0000000000 --- a/docs/renote_muting.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/packages/backend/migration/1665091090561-add-renote-muting.js b/packages/backend/migration/1665091090561-add-renote-muting.js -index 2c76aaff5..f8541c818 100644 ---- a/packages/backend/migration/1665091090561-add-renote-muting.js -+++ b/packages/backend/migration/1665091090561-add-renote-muting.js -@@ -4,18 +4,6 @@ export class addRenoteMuting1665091090561 { - } - - async up(queryRunner) { -- await queryRunner.query( -- `CREATE TABLE "renote_muting" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "muteeId" character varying(32) NOT NULL, "muterId" character varying(32) NOT NULL, CONSTRAINT "PK_renoteMuting_id" PRIMARY KEY ("id"))`, -- ); -- await queryRunner.query( -- `CREATE INDEX "IDX_renote_muting_createdAt" ON "muting" ("createdAt") `, -- ); -- await queryRunner.query( -- `CREATE INDEX "IDX_renote_muting_muteeId" ON "muting" ("muteeId") `, -- ); -- await queryRunner.query( -- `CREATE INDEX "IDX_renote_muting_muterId" ON "muting" ("muterId") `, -- ); - } - - async down(queryRunner) {} From 975598c91df5efd0c465220bd998e0c30df105ad Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 02:00:53 +0900 Subject: [PATCH 47/55] fix: remove incorrect license field --- packages/backend-rs/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/backend-rs/package.json b/packages/backend-rs/package.json index 25a330593a..94f1517448 100644 --- a/packages/backend-rs/package.json +++ b/packages/backend-rs/package.json @@ -21,7 +21,6 @@ ] } }, - "license": "MIT", "devDependencies": { "@napi-rs/cli": "2.18.0", "ava": "6.1.2" From 7220cce8bc9f59decdd1a131e83bb79bda0b5791 Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 02:11:11 +0900 Subject: [PATCH 48/55] docs: update SECURITY.md --- SECURITY.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 2f26af6b64..415d9cadd2 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,16 +1,5 @@ # Reporting Security Issues -## Minor Security Issues - -If you discover a minor security issue in Firefish, please report it by sending an -email to [kainoa@t1c.dev](mailto:kainoa@t1c.dev). - -## High Security Issues - -If you discover a security issue, which is so high risk, that too much is affected by it, please dont send it over unencrypted communication. You can share your PGP keys with us using kainoa@t1c.dev and after we established a secure communication, send it over E-Mail, or message us using matrix' encrypted private messages at @t1c:matrix.fedibird.com or @cleo:tchncs.de - - -This will allow us to assess the risk, and make a fix available before we add a -bug report to the Codeberg repository. +If you discover a security issue, please report it as a confidential issue. You can create a confidential issue by checking the "This issue is confidential and should only be visible to team members with at least Reporter access." checkbox in . Thanks for helping make Firefish safe for everyone. From 2a93e94dffb8f1938349a112a7c1c013e823eb12 Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 02:13:38 +0900 Subject: [PATCH 49/55] v20240319 --- docs/api-change.md | 2 +- docs/changelog.md | 2 +- docs/notice-for-admins.md | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api-change.md b/docs/api-change.md index 7bab3af1b3..fdda2e78b4 100644 --- a/docs/api-change.md +++ b/docs/api-change.md @@ -2,7 +2,7 @@ Breaking changes are indicated by the :warning: icon. -## Unreleased +## v20240319 - :warning: `followingCount` and `followersCount` in `users/show` will be `null` (instead of 0) if these values are unavailable. - :warning: `admin/search/index-all` is removed since posts are now indexed automatically. diff --git a/docs/changelog.md b/docs/changelog.md index 9b909d0818..4fc46cfc76 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,7 +5,7 @@ Critical security updates are indicated by the :warning: icon. - Server administrators should check [notice-for-admins.md](./notice-for-admins.md) as well. - Third-party client/bot developers may want to check [api-change.md](./api-change.md) as well. -## Unreleased +## [v20240319](https://firefish.dev/firefish/firefish/-/compare/v20240301...v20240319?from_project_id=7&straight=false) - Introduce new full-text search engine and post search filters - Refactoring diff --git a/docs/notice-for-admins.md b/docs/notice-for-admins.md index 1255310abc..12076730e7 100644 --- a/docs/notice-for-admins.md +++ b/docs/notice-for-admins.md @@ -2,7 +2,7 @@ You can skip intermediate versions when upgrading from an old version, but please read the notices and follow the instructions for each intermediate version before [upgrading](./upgrade.md). -## Unreleased +## v20240319 The full-text search engine used in Firefish has been changed to [PGroonga](https://pgroonga.github.io/). This is no longer an optional feature, so please enable PGroonga on your system. If you are using Sonic, Meilisearch, or Elasticsearch, you can also uninstall it from your system and remove the settings from `.config/default.yml`. diff --git a/package.json b/package.json index fd823ed053..226b90fe98 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "firefish", - "version": "20240301", + "version": "20240319", "repository": { "type": "git", "url": "https://firefish.dev/firefish/firefish.git" From f00c59f387202b5e7772f7e67f003888b835415d Mon Sep 17 00:00:00 2001 From: jolupa Date: Sun, 17 Mar 2024 18:54:44 +0000 Subject: [PATCH 50/55] locale: update translations (Catalan) Currently translated at 100.0% (1915 of 1915 strings) Translation: Firefish/locales Translate-URL: https://hosted.weblate.org/projects/firefish/locales/ca/ --- locales/ca-ES.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/locales/ca-ES.yml b/locales/ca-ES.yml index 9eb758a74d..7c0b80c3f2 100644 --- a/locales/ca-ES.yml +++ b/locales/ca-ES.yml @@ -2246,10 +2246,12 @@ replyUnmute: Treu el silencia de les respostes a les línies de temps searchWordsDescription: "Per cercar publicacions, escriu el terme a buscar. Separa les paraules amb espais per fer condicions AND o escriules dins de cometes per fer una cerca OR.\nPer exemple, 'dia nit' trobarà publicacions que continguin tan 'dia' - com 'nit', i 'dia OR nit' trobaran publicacions que continguin tan 'dia' com 'nit' - o ambdues.\nPots combinar condicions AND/OR per exemple '(dia OR nit) endormiscar'.\n - \nSi vols anar a una pàgina d'usuari o publicació en concret, escriu la adreça URL - o la ID en aquest camp i fes clic al botó 'Trobar'. Fent clic a 'Cercar' trobarà + com 'nit', i 'dia OR nit' trobara publicacions que continguin tant 'dia' com 'nit' + (o ambdues).\nPots combinar condicions AND/OR per exemple '(dia OR nit) endormiscar'.\n + Si vols cercar per una seqüencia de paraules (per exemple una frase) has d'escriure-les + entre cometes dobles, per no fer una cerca amb condicionant AND: \"Avui he aprés\"\ + \n \nSi vols anar a una pàgina d'usuari o publicació en concret, escriu la adreça + URL o la ID en aquest camp i fes clic al botó 'Trobar'. Fent clic a 'Cercar' trobarà publicacions que, literalment , continguin la ID/adreça URL." searchPostsWithFiles: Només publicacions amb fitxers searchCwAndAlt: Inclou avisos de contingut i arxius amb descripcions @@ -2275,7 +2277,7 @@ messagingUnencryptedInfo: Els xats a Firefish no són encriptats d'extrem a extr No comparteixis dades sensibles fent servir Firefish. searchRangeDescription: "Si vols filtrar per un període de temps, has de fer servir aquest format: 20220615-20231031\n\nSi no escrius l'any (per exemple 0105-0106 o - 20231105-0110), serà interpretat com l'any en curs.\n\nInclús pots morir la data + 20231105-0110), serà interpretat com l'any en curs.\n\nInclús pots ometre la data de començament o de finalització. Per exemple, -0102 filtrarà els resultats per mostrar només publicacions fetes abans del 2 de gener d'aquest any, i 20231026- filtrarà els resultats per mostrar publicacions fetes després del 26 d'octubre del From 128bada4dd88f3752551e1d7b78731ce8c64fcc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Mon, 18 Mar 2024 11:51:53 +0000 Subject: [PATCH 51/55] locale: update translations (Chinese (Simplified)) Currently translated at 100.0% (1915 of 1915 strings) Translation: Firefish/locales Translate-URL: https://hosted.weblate.org/projects/firefish/locales/zh_Hans/ --- locales/zh-CN.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index 2e220950d8..085fbeb435 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -31,12 +31,12 @@ uploading: "正在上传..." save: "保存" users: "用户" addUser: "添加用户" -favorite: "添加到书签" -favorites: "书签" +favorite: "添加到收藏" +favorites: "收藏" unfavorite: "取消收藏" -favorited: "已添加到书签。" -alreadyFavorited: "书签中已存在。" -cantFavorite: "无法添加到书签。" +favorited: "已添加到收藏。" +alreadyFavorited: "收藏中已存在。" +cantFavorite: "无法添加到收藏。" pin: "置顶" unpin: "取消置顶" copyContent: "复制内容" @@ -689,7 +689,7 @@ disableShowingAnimatedImages: "不播放动画" verificationEmailSent: "已发送确认电子邮件。请访问电子邮件中的链接以完成验证。" notSet: "未设置" emailVerified: "电子邮件地址已验证" -noteFavoritesCount: "加入书签的帖子数" +noteFavoritesCount: "加入收藏的帖子数" pageLikesCount: "页面点赞次数" pageLikedCount: "页面被点赞次数" contact: "联系人" @@ -1281,8 +1281,8 @@ _permissions: "write:blocks": "编辑屏蔽名单" "read:drive": "查看网盘" "write:drive": "管理网盘文件" - "read:favorites": "查看收藏夹" - "write:favorites": "编辑收藏夹" + "read:favorites": "查看收藏" + "write:favorites": "编辑收藏" "read:following": "查看关注信息" "write:following": "关注/取消关注其它账号" "read:messaging": "查看聊天消息" From 293bbe544948af08015e0503f8986a6ba87206a5 Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 22:54:09 +0900 Subject: [PATCH 52/55] dev: do not gitignore compose file for development environments --- .gitignore | 2 +- dev/container/docker-compose.yml | 51 +++++++++++++++++++++++++++++ dev/db-container/docker-compose.yml | 17 ++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 dev/container/docker-compose.yml create mode 100644 dev/db-container/docker-compose.yml diff --git a/.gitignore b/.gitignore index 6ed87e24a6..93870c7ffc 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,7 @@ coverage !/.config/docker_ci.env !/.config/helm_values_example.yml !/.config/LICENSE -docker-compose.yml +/docker-compose.yml /custom # ESLint diff --git a/dev/container/docker-compose.yml b/dev/container/docker-compose.yml new file mode 100644 index 0000000000..965666c544 --- /dev/null +++ b/dev/container/docker-compose.yml @@ -0,0 +1,51 @@ +version: "3" + +services: + web: + image: docker.io/node:18.17.0-bookworm + container_name: firefish_web + restart: unless-stopped + depends_on: + - db + - redis + ports: + - "3030:3030" + networks: + - firefishnet + environment: + NODE_ENV: production + PGPASSWORD: password + URL: http://localhost:3030 + volumes: + - ./firefish:/firefish:rw + - ./docker-entrypoint.sh:/docker-entrypoint.sh:ro + entrypoint: /docker-entrypoint.sh + + redis: + restart: unless-stopped + image: docker.io/redis:7.0-alpine + container_name: firefish_redis + networks: + - firefishnet + ports: + - "26379:6379" + volumes: + - ./redis:/data + + db: + restart: unless-stopped + image: docker.io/groonga/pgroonga:3.1.8-alpine-12 + container_name: firefish_db + networks: + - firefishnet + environment: + - "POSTGRES_PASSWORD=password" + - "POSTGRES_USER=firefish" + - "POSTGRES_DB=firefish_db" + ports: + - "25432:5432" + volumes: + - ./db:/var/lib/postgresql/data + +networks: + firefishnet: diff --git a/dev/db-container/docker-compose.yml b/dev/db-container/docker-compose.yml new file mode 100644 index 0000000000..0c9a6fd617 --- /dev/null +++ b/dev/db-container/docker-compose.yml @@ -0,0 +1,17 @@ +version: "3" + +services: + redis: + image: docker.io/redis:7-alpine + ports: + - "26379:6379" + db: + image: docker.io/groonga/pgroonga:3.1.8-alpine-12 + environment: + - "POSTGRES_PASSWORD=password" + - "POSTGRES_USER=firefish" + - "POSTGRES_DB=firefish_db" + ports: + - "25432:5432" + volumes: + - "./install.sql:/docker-entrypoint-initdb.d/install.sql:ro" From c4fadc8bf1c051474598804bf9c67452f5a0782c Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 23:06:52 +0900 Subject: [PATCH 53/55] docs (minor): fix missing newline --- docs/install.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/install.md b/docs/install.md index cab441db1f..af698360b8 100644 --- a/docs/install.md +++ b/docs/install.md @@ -116,6 +116,7 @@ sudo apt install ffmpeg pwd ``` 1. Install Rust toolchain + Instructions can be found at [this page](https://www.rust-lang.org/tools/install). ```sh From 605e97181b7e0d7ef67fd508f841dbdccfffb663 Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 19 Mar 2024 23:08:38 +0900 Subject: [PATCH 54/55] docs: fix comments about upgrading --- docs/install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install.md b/docs/install.md index af698360b8..061000fa32 100644 --- a/docs/install.md +++ b/docs/install.md @@ -283,7 +283,7 @@ In this instruction, we use [Caddy](https://caddyserver.com/) to make the Firefi ## Upgrading -Please refer to the [upgrade instruction](./upgrade.md). Be sure to switch to `firefish` user and go to the Firefish directory before performing `pnpm install --frozen-lockfile`: +Please refer to the [upgrade instruction](./upgrade.md). Be sure to switch to `firefish` user and go to the Firefish directory before executing the `git` command: ```sh sudo su --login firefish From 60e2d1bd55324397aec3695103f28f377abad972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Tue, 19 Mar 2024 00:55:23 +0000 Subject: [PATCH 55/55] locale: update translations (Chinese (Simplified)) Currently translated at 100.0% (1915 of 1915 strings) Translation: Firefish/locales Translate-URL: https://hosted.weblate.org/projects/firefish/locales/zh_Hans/ --- locales/zh-CN.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index 085fbeb435..11ef5d7303 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -2045,8 +2045,8 @@ searchPostsWithFiles: 只带有文件的帖子 searchCwAndAlt: 包括内容警告和文件描述 publishTimelines: 为访客发布时间线 publishTimelinesDescription: 如果启用,在用户登出时本地和全局时间线也会显示在 {url} 上。 -searchWordsDescription: "要搜索帖子,请输入关键词。交集搜索关键词之间使用空格进行区分,并集搜索关键词之间使用 OR 进行区分。\n例如 '早上 - 晚上' 将查找包含 '早上' 和 '晚上' 的帖子,而 '早上 OR 晚上' 将查找包含 '早上' 或 '晚上' (以及同时包含两者)的帖子。\n您还可以组合交集/并集条件,例如 +searchWordsDescription: "在此处输入搜索词以搜索帖子。交集搜索关键词之间使用空格进行区分,并集搜索关键词之间使用 OR 进行区分。\n例如 + '早上 晚上' 将查找包含 '早上' 和 '晚上' 的帖子,而 '早上 OR 晚上' 将查找包含 '早上' 或 '晚上' (以及同时包含两者)的帖子。\n您还可以组合交集/并集条件,例如 '(早上 OR 晚上) 困了' 。\n如果您想搜索单词序列(例如一个英语句子),您必须将其放在双引号中,例如 \"Today I learned\" 以区分于交集搜索。\n \n如果您想转到特定的用户页面或帖子页面,请在此字段中输入用户 ID 或 URL,然后单击 “查询” 按钮。 单击 “搜索” 将搜索字面包含用户 ID/URL 的帖子。"