banner
 Aeris

Aerisの小宇宙

Deploy Akkoma using 1Panel

After deploying Sharkey, I came across a branch of Pleroma—Akkoma, which seems to be more lightweight than Sharkey.

(I don't have high hopes for Mastodon, after all, it's a small microserver)

So, driven by curiosity, I started another deployment journey.

The method shared in this article is a foolproof installation via 1panel, testing on the Debian 12 system.

Welcome everyone to join the federated universe.

Official repository: https://akkoma.dev/AkkomaGang/akkoma/

Official documentation: https://docs.akkoma.dev/stable/

Preparation#

Before deployment, you need to prepare a domain name and a clean VPS system. This article uses the Debian 12 system. If you are using another system, please refer to the official documentation for the relevant code.

Set up Swap#

(Or find it in the Toolbox - Quick Setup - Swap section of the 1panel)

wget https://www.moerats.com/usr/shell/swap.sh && bash swap.sh

Official Deployment#

Install curl#

apt install curl

Install 1Panel#

1panel official documentation: https://1panel.cn/docs/installation/online_installation/

During the installation of 1Panel, Docker and Docker-Compose will also be installed.

I used Debian

curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && bash quick_start.sh

Create a user named akkoma#

sudo useradd -r -s /bin/false -m -d /var/lib/akkoma -U akkoma

Add Docker permissions for akkoma#

sudo usermod -aG docker akkoma

Open a new Shell window and log in as akkoma#

su -l akkoma -s $SHELL

Return to the original root window, grant permissions to the akkoma folder, and pull resources#

sudo mkdir -p /opt/akkoma
sudo chown -R akkoma:akkoma /opt/akkoma
sudo -Hu akkoma git clone https://akkoma.dev/AkkomaGang/akkoma.git -b stable /opt/akkoma

Return to the akkoma window and enter the download directory#

cd /opt/akkoma

Modify the docker-composed.yml file#

version: "3.7"

services:
  db:
    image: akkoma-db:latest
    build: ./docker-resources/database
    restart: unless-stopped
    user: ${DOCKER_USER}
    environment: {
      # This might seem insecure but is usually not a problem.
      # You should leave this at the "akkoma" default.
      # The DB is only reachable by containers in the same docker network,
      # and is not exposed to the open internet.
      #
      # If you do change this, remember to update "config.exs".
      POSTGRES_DB: akkoma,
      POSTGRES_USER: akkoma,
      POSTGRES_PASSWORD: akkoma,
    }
    env_file:
      - .env 
    volumes:
      - type: bind
        source: ./pgdata
        target: /var/lib/postgresql/data

  akkoma:
    image: akkoma:latest
    build: .
    restart: unless-stopped
    env_file:
      - .env
    links:
      - db
    ports: [
      # Uncomment/Change port mappings below as needed.
      # The left side is your host machine, the right one is the akkoma container.
      # You can prefix the left side with an ip.

      # Webserver (for reverse-proxies outside of docker)
      # If you use a dockerized proxy, you can leave this commented
      # and use a container link instead.
      "0.0.0.0:4000:4000",
    ]
    volumes:
      - .:/opt/akkoma

  # Uncomment the following if you want to use a reverse proxy
  #proxy:
  #  image: caddy:2-alpine
  #  restart: unless-stopped
  #  links:
  #    - akkoma
  #  ports: [
  #     "443:443",
  #     "80:80"
  #  ]
  #  volumes:
  #    - ./docker-resources/Caddyfile:/etc/caddy/Caddyfile
  #    - ./caddy-data:/data
  #    - ./caddy-config:/config

The changes I made:

Changed the akkoma deployment IP from 127.0.0.1 to 0.0.0.0.

Start deployment according to the official documentation#

cp docker-resources/env.example .env
echo "DOCKER_USER=$(id -u):$(id -g)" >> .env

Build the container#

./docker-resources/build.sh

Generate the instance#

mkdir pgdata
./docker-resources/manage.sh mix deps.get
./docker-resources/manage.sh mix compile
./docker-resources/manage.sh mix pleroma.instance gen

When you enter the last line of code, it will ask you several questions

The database hostname is db, the database password is akkoma (do not press enter for auto-generation), you need to set the IP to 0.0.0.0.

Input parameters#

What domain will your instance use? 
(e.g akkoma.example.com) [] #Enter your instance domain

What is the name of your instance? 
(e.g. The Corndog Emporium) [kaixin.meme] #Site name
What is your admin email address? [] #Admin email
What email address do you want to use for sending email notifications? [[email protected]]  #Email for sending notifications
Do you want search engines to index your site? (y/n) [y]  #Enable search functionality
Do you want to store the configuration in the database (allows controlling it from admin-fe)? (y/n) [n]  #Allow admin panel to modify database content, recommended to enable
What is the hostname of your database? [localhost] #Database address, if using docker, fill in db
# Fill in akkoma for these three items
# ——————————————————
What is the name of your database? [akkoma]   
What is the user used to connect to your database? [akkoma]  
What is the password used to connect to your database? [autogenerated]  akkoma
# ——————————————————
Would you like to use RUM indices? [n]  #I didn't enable it because I'm not sure what it's for (heh, newbie)
What port will the app listen to (leave it if you are using the default setup with nginx)? [4000]  #Port number
What ip will the app listen to (leave it if you are using the default setup with nginx)? [127.0.0.1]  0.0.0.0 #I used 1panel, so I wrote 0.0.0.0
# I didn't change the following two items
# ————————————————
What directory should media uploads go in (when using the local uploader)? [uploads]  
What directory should custom public files be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)? [instance/static/] 
# ————————————————
Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as installed. (y/n) [y]  n #Whether to extract GPS information from uploaded photos, I didn't enable it
Do you want to anonymize the filenames of uploads? (y/n) [n]  y #Anonymize filenames, I enabled it
Do you want to deduplicate uploaded files? (y/n) [n]  y
#Remove duplicate uploaded files, I chose yes

If you make a mistake with the email or similar, it doesn't matter; you can also modify it in the /config/generated_config.exs file

Or add the --force parameter to redeploy

Continue deployment#

cp config/generated_config.exs config/prod.secret.exs

Initialize the database#

docker compose run --rm --user akkoma -d db 
# Note down the name it gives here, it will be something like akkoma_db_run, you can log into the 1panel-container to check
docker compose run --rm akkoma psql -h db -U akkoma -f config/setup_db.psql
docker stop akkoma_db_run # Replace with the name you noted down, change to your container name

Run migrations#

./docker-resources/manage.sh mix ecto.migrate

Start the service and run in the background#

docker compose up -d

Check if there is a service at IP address:4000. If not, check if there is still 127.0.0.1 somewhere.

If everything goes smoothly, you can continue to create an account.

Create an account#

./docker-resources/manage.sh mix pleroma.user new MY_USERNAME MY_EMAIL@SOMEWHERE --admin

Change MY_USERNAME to your username.

Change MY_EMAIL@SOMEWHERE to your email.

After running, a URL will be generated for setting the initial account password, remember to save it, as you will need it after setting up HTTPS for reverse proxy.

Install frontend#

./docker-resources/manage.sh mix pleroma.frontend install pleroma-fe --ref stable
./docker-resources/manage.sh mix pleroma.frontend install admin-fe --ref stable

1Panel Operations#

  1. Apply for a certificate

  2. Reverse proxy the website

  3. Install Meilisearch

  4. Maintenance and backup later

Apply for a certificate#

First, go to Website - Certificates

image

Create a DNS account#

I used Cloudflare; you can search online for how to obtain the API key for others.

image-20240208201948972

Currently, CloudFlare requires using API Token

Create an Acme account#

image

Click Apply for Certificate, and wait for completion.

Reverse proxy the website#

image

Enter the main domain name for your website address.

Fill in the proxy address as your server IP port number.

Go to Configuration

image

image

Select the previously created Acme account and certificate, and save.

Don't forget to add records at your DNS provider!#

image

At this point, your website has been set up. Enter the command generated by the server during account creation to set the password, and you can start using it.

I personally find the method using the database plugin too complicated (heh), so I chose Meilisearch.

Search for MeiliSearch in 1Panel and install it.

image

Check the parameters.

image

Open your site, look at the upper right corner, and click to enter the control panel.

image

Click Settings - Search.

image

Select Meilisearch.

URL: Go back to 1Panel and click on the container.

image

Here you can see the IP address, port, and Key. Fill in the parameters you saw before.

Click Submit in the lower right corner.

Go back to the homepage for testing.

image

Done.


If this article has helped you, feel free to visit/follow @[email protected]

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.