[#58] pre-link MFM content (#59)
[akkoma] / docs / development / setting_up_akkoma_dev.md
1 # Setting up a Akkoma development environment
2
3 Akkoma requires some adjustments from the defaults for running the instance locally. The following should help you to get started.
4
5 ## Installing
6
7 1. Install Akkoma as explained in [the docs](../installation/debian_based_en.md), with some exceptions:
8 * You can use your own fork of the repository and add akkoma as a remote `git remote add akkoma 'https://akkoma.dev/AkkomaGang/akkoma.git'`
9 * You can skip systemd and nginx and all that stuff
10 * No need to create a dedicated akkoma user, it's easier to just use your own user
11 * For the DB you can still choose a dedicated user, the mix tasks set it up for you so it's no extra work for you
12 * For domain you can use `localhost`
13 * instead of creating a `prod.secret.exs`, create `dev.secret.exs`
14 * No need to prefix with `MIX_ENV=prod`. We're using dev and that's the default MIX_ENV
15 2. Change the dev.secret.exs
16 * Change the scheme in `config :pleroma, Pleroma.Web.Endpoint` to http (see examples below)
17 * If you want to change other settings, you can do that too
18 3. You can now start the server `mix phx.server`. Once it's build and started, you can access the instance on `http://<host>:<port>` (e.g.http://localhost:4000 ) and should be able to do everything locally you normaly can.
19
20 Example config to change the scheme to http. Change the port if you want to run on another port.
21 ```elixir
22 config :pleroma, Pleroma.Web.Endpoint,
23 url: [host: "localhost", scheme: "http", port: 4000],
24 ```
25
26 Example config to disable captcha. This makes it a bit easier to create test-users.
27 ```elixir
28 config :pleroma, Pleroma.Captcha,
29 enabled: false
30 ```
31
32 Example config to change the log level to info
33 ```elixir
34 config :logger, :console,
35 # :debug :info :warning :error
36 level: :info
37 ```
38
39 ## Testing with HTTPS
40
41 If you end up developing alongside other software like misskey,
42 you will not be able to federate without an SSL certificate. You should
43 be able to use the snakeoil certificate that comes standard with most
44 distributions or generate one from scratch, then force elixir to accept it.
45
46 HTTP clients are none too keen to accept self-signed certs, but we can do
47 this:
48
49 ```elixir
50 config :pleroma, :http,
51 adapter: [
52 pools: %{
53 default: [
54 conn_opts: [
55 transport_opts: [
56 verify: :verify_none
57 ]
58 ]
59 ]
60 }
61 ]
62 ```
63
64 Now your SSL requests will work. Hooray.
65
66 ## Testing
67
68 1. Create a `test.secret.exs` file with the content as shown below
69 2. Create the database user and test database.
70 1. You can use the `config/setup_db.psql` as a template. Copy the file if you want and change the database name, user and password to the values for the test-database (e.g. 'akkoma_local_test' for database and user). Then run this file like you did during installation.
71 2. The tests will try to create the Database, so we'll have to allow our test-database user to create databases, `sudo -Hu postgres psql -c "ALTER USER akkoma_local_test WITH CREATEDB;"`
72 3. Run the tests with `mix test`. The tests should succeed.
73
74 Example content for the `test.secret.exs` file. Feel free to use another user, database name or password, just make sure the database is dedicated for the testing environment.
75 ```elixir
76 # Akkoma test configuration
77
78 # NOTE: This file should not be committed to a repo or otherwise made public
79 # without removing sensitive information.
80
81 import Config
82
83 config :pleroma, Pleroma.Repo,
84 username: "akkoma_local_test",
85 password: "mysuperduperpassword",
86 database: "akkoma_local_test",
87 hostname: "localhost"
88
89 ```
90
91 ## Updating
92
93 Update Akkoma as explained in [the docs](../administration/updating.md). Just make sure you pull from upstream and not from your own fork.
94
95 ## Working on multiple branches
96
97 If you develop on a separate branch, it's possible you did migrations that aren't merged into another branch you're working on. If you have multiple things you're working on, it's probably best to set up multiple Akkoma instances each with their own database. If you finished with a branch and want to switch back to develop to start a new branch from there, you can drop the database and recreate the database (e.g. by using `config/setup_db.psql`). The commands to drop and recreate the database can be found in [the docs](../administration/backup.md).