Preface#
Recently, I saw some friends trying to set up their own instances, such as this one. So I thought about setting up a Sharkey to play with, which led to a long period of tinkering. This article attempts to consolidate the recent tinkering content for reference for those with similar ideas.
Why Sharkey?#
First, the Misskey system interface suits my taste; secondly, the Firefish I previously tried to tinker with is entering maintenance mode and is about to stop updates (otherwise, this article's recommendation would have changed to Firefish); furthermore, Sharkey should have the most new features added among the Misskey branches besides Firefish, which is very fun; finally, I have enough memory.
Currently, I am using Sharkey-stelpolva, a fork from the site owner of 無名星屑, which adds a bunch of features on top of the original Sharkey. However, this fork does not provide a pre-built Docker image, so to reduce the pressure of compiling the image every time I update the server, I created a workflow to periodically pull the source code, build the image, and upload it to DockerHub. You can check the image information here.
Deployment#
First, create a directory mkdir Sharkey && mkdir Sharkey/.config
to store the configuration files.
Next, grab the configuration examples and enter the directory: (If using the original Sharkey, copy the commands with the hash symbol)
wget -O Sharkey/docker-compose.yml https://raw.githubusercontent.com/Lhcfl/sharkey-stelpolva/refs/heads/stelpolva/compose_example.yml
# wget -O Sharkey/docker-compose.yml https://activitypub.software/TransFem-org/Sharkey/-/raw/stable/compose_example.yml
wget -O Sharkey/.config/default.yml https://raw.githubusercontent.com/Lhcfl/sharkey-stelpolva/refs/heads/stelpolva/.config/docker_example.yml
# wget -O Sharkey/.config/default.yml https://activitypub.software/TransFem-org/Sharkey/-/raw/stable/.config/docker_example.yml
wget -O Sharkey/.config/docker.env https://raw.githubusercontent.com/Lhcfl/sharkey-stelpolva/refs/heads/stelpolva/.config/docker_example.env
# wget -O Sharkey/.config/docker.env https://activitypub.software/TransFem-org/Sharkey/-/raw/stable/.config/docker_example.env
cd Sharkey
Edit .config/default.yml
. Modify the url
to your domain name, and adjust other variables as needed.
Then edit docker-compose.yml
, uncomment the image
line under service/web
, and if using the previously mentioned built image, change the content to wuhang2003/sharkey-stelpolva-docker:latest
, commenting out the next line build
.
Note
You can try replacing the built-in Redis with Valkey, which is based on a fork of the open-source Redis version, perfectly compatible and with better performance than the original.
Change the image
line under service/db
to groonga/pgroonga:latest
, which is a necessary dependency for the modified version.
The completed docker-compose.yml
reference is as follows: (The network has been modified to 1Panel network
for convenience in management)
services:
web:
image: wuhang2003/sharkey-stelpolva-docker:latest
restart: always
links:
- db
- valkey
depends_on:
db:
condition: service_healthy
valkey:
condition: service_healthy
ports:
- "4514:3000"
networks:
- 1panel-network
# env_file:
# - .config/docker.env
volumes:
- ./files:/sharkey/files
- ./.config:/sharkey/.config:ro
valkey:
restart: always
image: valkey/valkey:8-alpine
networks:
- 1panel-network
volumes:
- ./valkey:/data
healthcheck:
test: "valkey-cli ping"
interval: 5s
retries: 20
db:
restart: always
image: groonga/pgroonga:3.2.5-alpine-17
networks:
- 1panel-network
env_file:
- .config/docker.env
volumes:
- ./db:/var/lib/postgresql/data
healthcheck:
test: "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"
interval: 5s
retries: 20
networks:
1panel-network:
external: true
After completing, start PostgreSQL and Redis (or Valkey) with sudo docker compose up -d db redis
, copy the names of the two containers (assuming they are sharkey-valkey-1 and sharkey-db-1), then modify the host
in the .config/default.yml
for the db and redis sections to the corresponding container names. Then enter the db container and connect to the database using psql, executing CREATE EXTENSION pgroonga;
to add the pgroonga extension to the database. This completes all the preparatory work before officially starting.
Next, run docker compose up -d
. Refer to the Misskey documentation to configure the reverse proxy. In the Sharkey directory, execute sudo chown -R 991:991 files/
to change the folder ownership to avoid issues with file uploads on the web interface.
After completing, log in to the web interface to register the initial account and optimize the site experience.
Optimization#
Modify Instance Information and Join Relays#
Modify instance information: Control Panel -> Settings -> General Settings
Add server and site logo: Control Panel -> Settings -> Branding
Join relays: Control Panel -> Settings -> Relay. Common Chinese relays: Nya Relay, DragonRelay, Isle Relay.
After enabling relays, small instances may experience cross-site message congestion (if there are large sites in the relay, the information flow is too frequent, congesting the small instance's sidekiq) and cross-site timeline confusion (content from a much earlier time inserted into the current cross-site timeline), please confirm if you can accept this (generally harmless). Additionally, adding more relays will increase the size of the server's PostgreSQL database.
CloudFlare#
The process of adding the site will not be detailed here, just a special point: for the instance's domain name, you need to disable Rocket Loader, which can be done by globally turning off this option (Speed -> Optimization -> Content Optimization) or using Configuration Rules to set rules for specific sites.
In addition, consider using R2 to store images and other resources.
Add Permission Groups and Enable Some Permissions#
Control Panel -> Roles, create a new role, set the role permissions to administrator, and the authorization object to manual. The policy settings are as follows:
- Rate limiting: cancel the default and set it to the minimum 0% (to avoid issues when using tools to upload emojis via API)
- Enable management of custom emojis/manage avatar attachments
- Increase cloud storage capacity as needed (approximately 500M to 1G) to facilitate the addition of custom emojis and avatar attachments
Then assign this role to your account, return to the role settings, and enable the option "Can search posts" under basic roles to complete.
Add Emojis (Scraping + Uploading)#
Since uploading custom emojis will be stored in the corresponding account's cloud storage, it is generally recommended to create a separate account specifically for storing emojis and other public resources. This account needs to be assigned the aforementioned administrator role to upload emojis without restrictions.
Scrape emojis from other Misskey sites: powerfullz/misskey-emoji-downloader
Bulk categorize and upload: pentaCoxian/misskey-emoji-bulk-uploader
Anti-SPAM#
Considering the wave of SPAM targeting the Fediverse that occurred last October, this section is added, mainly divided into internal prevention (prohibiting unauthorized registrations) and external prevention (preventing external instances from SPAMming the message flow).
Prohibit unauthorized registrations: Sharkey does not require active settings, as it defaults to closed registration (i.e., requires an invitation code). You can enable "Registration requires an email address" and "New users must be manually approved" in the Control Panel -> Management, and set up CAPTCHA and email verification under the "Security" tab.
Prevent external instances from SPAMming the message flow: Control Panel -> Roles, create a new role, keep the role permissions unchanged (normal users), select "Meets conditions" for the authorization object, and set the conditions and policies as seen in this post's image, then save.
Updates#
Since everything is deployed with Docker Compose, just run docker compose pull && docker compose up -d
to complete.
Finally, feel free to follow @wuhang2003@m.zwh.moe
, and my old account @wuhang2003@nya.one
, thank you meow.
References#
This article is synchronized and updated to xLog by Mix Space. The original link is https://zwh.moe/posts/technology/sharkey-deploy