aboutsummaryrefslogtreecommitdiff
path: root/readme.md
blob: 94e75eb66ea36d659b6db50d1adb7106ae771245 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Wormhole

Enables you to send messages from mastodon into a wormhole to have it go through time and space and appear in a new galaxy!

In this new galaxy, you can see what other people have shared and subscribe to it's RSS feed to receive updates. What a great way to share links with friends!

Note: Not quite production ready yet. I have hard coded some values specifically to galaxy.mccd.space and also there is no persistent storage available yet!

## Motivation

I am part of a group of researchers / decentralization enthusiasts, and we want to have a way to share links that we found interesting. Along with that, we'd also like to be able to discuss and comment on those. Initially I built a boring link sharing server where you logged in and shared things. Instead, more interesting would be to send everything into a wormhole, where the shared links pop up on the other side. From there, people can follow content updates by either going into the website or subscribing to an RSS feed.

I built it in OCaml because it is by far the most underrated programming language on the planet and the web framework Dream is a BEAST in terms of productivity. Hyper fast compilation speed + great performance + productive + safe + lots of industry use.

## Prerequisites

You'll need [nix](https://nixos.org/) to run it locally. It sets everything up to make it dead easy
to run locally.

If you use direnv, then set direnv allow to enable it to start automagically when you cd to the directory.

You'll need to have the experimental flags nix-command and flakes set for it to work.

Alternatively, you can execute each command with the flag

```
--extra-experimental-features "nix-command flakes"
```

And it will work to.

## Running locally

```
nix build . # Will take a long time the first time, after that it will go very fast.
ENV=DEV DISABLE_AUTH=true nix develop -c dune exec --watch --root . wormhole
```

Dev flag adds some mock data.

## Allow list

There is a allow list in bin/main.ml that you will need to update to allow specific actors to make posts. This is a safety precaution as there is no federation yet.

## Build

```
opam install . --deps-only
opam exec -- dune build
```

## Hosting

You can make use of the dockerfile to host your wormhole, personally I host it on a 4gb VPC on Hetzner for 8$ a month using Dokku.

### Hosting with dokku

Follow the install instructions from [dokku](https://dokku.com/), attach your dokku instance to a domain, then create a new app:

```
root@server$ dokku apps:create my-wormhole
```

Now, clone this repo and add a new remote, then push it to create the app

```
you@comp$ git remote add dokku dokku@your-dokku-domain.com
you@comp$ git push dokku master
```

This will set up the instance. I had little success with this on a 2gb VPC, so do avoid that.

Once up, let's setup SSL for it to work:

```
root@server$ dokku plugin:install https://github.com/dokku/dokku-letsencrypt
root@server$ dokku letsencrypt:set my-wormhole email your@email.tld
root@server$ dokku letsencrypt:enable my-wormhole
```

Now it should be possible to find your wormhole in Mastodon! Look for @wormhole@my-wormhole.your-dokku-domain.com.

## Development

Good documentation:

- [Yojson](https://github.com/janestreet/ppx_yojson_conv)

### Testing

You can install `hurl` do to integration tests. For example:

```
hurl http/inbox.hurl
```

## Contributing

Send patches to marc@mccd.space. Never sent email patches before? Check out [this tutorial](https://git-send-email.io/). Let us move to a more decentralized ecosystem for open source development!