• Stars
    star
    431
  • Rank 100,866 (Top 2 %)
  • Language
    Shell
  • License
    GNU General Publi...
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Selfhost your Emacs and access it in browser

Docker Cloud Build Status

Docker hub

For ages I've been seeking a decent browser frontend for my org-mode notes and todo lists. Until I realized that nothing prevents me from having emacs itself in my browser.

Selfhost your Emacs with your favorite configuration.

Demo screenshot

Motivation

Since I've became hooked on emacs, I've been looking for ways to have same experience in my browser. Sometimes you have to use non-personal computers where it's not possible/undesirable to install desktop Emacs and Dropbox/Syncthing to access your personal data. So I've been looking for some cloud solution since I've got a VPS.

The closest tool to what I wanted was Filestash: it supports vim/emacs bindings and some org-mode goodies. However, it wasn't anywhere as convenient as emacs.

Dropbox is not capable of previewing arbitrary text files let alone edit; and even if it could you obviously wouldn't get anything close to your usual emacs workflow.

And you could imagine that while elisp/vim style editing is fairly application agnostic, it's a thankless job to rewrite/port all the amazing emacs packages and features I'm used to like neotree, helm, refile, swoop, agenda, projectile, org-drill etc.

So I figured the only thing that would keep me happy is to run emacs itself over the web! Thankfully, due to its TUI interface that works surprisingly well.

It works really well with spacemacs style SPC/, bindings because they for the most part don't overlap with OS/browser hotkeys.

How does it work?

Dockerfile has got some comments and should be straightforward to follow, but in essence:

  1. Gotty is a tool that allows accessing any TTY app as a web page (also allows forwarding input)
  2. We use Gotty to run emacsclient --tty -a '' command, that connects to the existing Emacs instance or starts a new one. That makes the session persist tab closes, connection problems etc.
  3. Your Emacs configs and files you want to expose to Cloudmacs are mapped in docker-compose.yml file.

Try it out locally

  1. cp docker-compose.example.yml docker-compose.yml
  2. Edit necessary variables in docker-compose.yml, presumably your want to
    • map the files you want to make accessible to container
    • map the path to your config files/directories (e.g. .emacs.d or .spacemacs/.spacemacs.d). Also check the 'Setting up Spacemacs' section!
    • change port (see 'selfhost' section)
  3. Run the container: ./compose up -d.
  4. Check it out in browser: 'http://localhost:8080'.

Setting up Spacemacs

Spacemacs doesn't use init.el, instead you have ~/.spacemacs.d directory, and ~/.emacs.d serves as Spacemacs distribution. I don't recommend you to reuse ~/.emacs.d your OS emacs distribution will generally be different from containers, and who knows what else could it break. Instead just clone spacemacs in a separate dir and map it.

On your Host OS:

git clone https://github.com/syl20bnr/spacemacs.git -b develop ~/.cloudmacs.d
cd ~/.cloudmacs.d && git revert --no-edit 5d4b80 # get around https://github.com/syl20bnr/spacemacs/issues/11585

In your docker-compose.yml, add:

    volumes:
      - ${HOME}/.cloudmacs.d:/home/emacs/.emacs.d

Customize

Some packages need extra binaries in the container (e.g. magit needs git). There are to ways you can deal with it

  1. Extend cloudmacs dockerfile and mix in the packages you need: see my example, where I'm extending the container with git and ripgrep. Then you can build it, e.g.:

    docker build -f Dockerfile.customized -t customized-cloudmacs --build-arg RIPGREP_VERSION="11.0.2" .
    

    Don't forget to update docker-compose.yml with the name of your new container.

  2. Install packages directly on running container. The downside is that it's easy to lose changes if you delete the container. Unfortunately docker-compose file doesn't support post-start scripts so if you want to automate this perhaps easiest would be to write a wrapper script like this:

    #!/bin/bash -eux
    docker-compose up -d
    docker exec cloudmacs sh -c "apk add --no-cache git"
    

Selfhost

  • I use basic auth to access my container.
  • Set up reverse proxy to access Gotty. Steps may vary depending on your web server, but for my nginx it looks like that:
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_http_version 1.1;
        proxy_pass http://localhost:8888;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
    

Potential improvements

  • split rg/locales/gotty in separate docker containers? maybe locales could be somehow moved to original emacs container?
    • also, after splitting it would be easy to make setup more generic and let people run vim/neovim, since the setup is pretty editor agnostic

Limitations

  • Mobile phones -- you'd struggle to use default emacs/spacemacs on touchscreens. Perhaps there is some special phone friendly config out there? Anyway, I tend to use orgzly on my Android phone.

Credits

License

GPL due to the fact that I looked at other GPL licensed dockerfiles as reference.

More Repositories

1

promnesia

Another piece of your extended mind
Python
1,534
star
2

HPI

Human Programming Interface 🧑👽🤖
Python
1,252
star
3

orgparse

Python module for reading Emacs org-mode files
Python
323
star
4

grasp

A reliable org-capture browser extension for Chrome/Firefox
JavaScript
286
star
5

orger

Tool to convert data into searchable and interactive org-mode views
Python
274
star
6

cachew

Transparent and persistent cache/serialization powered by type hints
Python
189
star
7

pockexport

Export/access your Pocket data, including highlights!
Python
148
star
8

rexport

Reddit takeout: export your account data as JSON: comments, submissions, upvotes etc. 🦖
Python
137
star
9

kobuddy

Kobo database backup and parser: extracts notes, highlights, reading progress and more
Python
104
star
10

beepb00p

My blog!
Python
73
star
11

exobrain

My external brain 🧠
67
star
12

fbmessengerexport

Export/access you Messenger/Facebook chat messages
Python
60
star
13

ghexport

Export your Github activity: events, repositories, stars, etc.
Python
39
star
14

myinfra

A diagram of my personal infrastructure
Python
38
star
15

dron

What if cron and systemd had a baby?
Python
35
star
16

hypexport

Export/access your Hypothes.is data: annotations and profile info
Python
33
star
17

spotifyexport

Export your personal Spotify data: playlists, saved tracks/albums/shows, etc. as JSON
Python
29
star
18

instapexport

Export your personal Instapaper data: bookmarked articles and highlights
Python
27
star
19

arctee

Atomic tee
Python
24
star
20

telegram-backup-to-txt

Tool to dump telegram into text files for quick search (e.g. with grep)
Python
23
star
21

axol

Personal news feed: search for results on Reddit/Pinboard/Twitter/Hackernews and read as RSS
Python
23
star
22

pinbexport

Export your bookmarks from Pinboard
Python
22
star
23

inorganic

Convert python structures into org-mode
Python
21
star
24

dashboard

Python
18
star
25

goodrexport

Goodreads data export
Python
17
star
26

dotemacs

Emacs config (Doom/Spacemacs) + supplementary files and scripts
Emacs Lisp
14
star
27

telegram2org

Tool to create TODO tasks from Telegram messages in one tap
Python
14
star
28

bleanser

Tool for cleaning old and redundant backups
Python
11
star
29

blinkist-backup

Extract your blinkist hightlights and library books
Python
11
star
30

open-in-editor

Script to jump into files in you text editor, from your web browser
Python
9
star
31

exobrain-md

8
star
32

stexport

Export and access your Stackexchange data
Python
8
star
33

rescuexport

Export/access your Rescuetime data
Python
8
star
34

vkdump

Script for VK.com backup
Python
7
star
35

sufs

Merge multiple directories into one via symlinks
Python
7
star
36

scrapyroo

Full text search over deliveroo restaurants
JavaScript
6
star
37

exobrain-compiler

Scripts I'm using to generate my exobrain
Emacs Lisp
6
star
38

cofunctor-pl

Haskell
5
star
39

autohash

AutoValue extension which speeds up `hashCode` calculation for immutable objects
Java
5
star
40

monzoexport

Tool to export your Monzo transactions
Python
4
star
41

checker-fenum-android-demo

Demo setup for using Checker Framework custom @Fenum annotations in your Android project
Java
4
star
42

pymplate

My Python project template
Python
4
star
43

emfitexport

Python
4
star
44

exports

Various data export scripts that don't deserve a separate repository yet
Python
3
star
45

endoexport

Export/access your Endomondo data
Python
3
star
46

hpi-personal-overlay

Python
3
star
47

mreddit

Simple script to check whether some of your subreddits are not in a multireddit
Python
3
star
48

nordvpn-kill-switch

Tool to prevent DNS leaks. Discontinued in favor of jotyGill/openpyn-nordvpn
Shell
3
star
49

beepb00p-raw

Raw plaintext export of my blog posts
3
star
50

qm-reverse-engineering

Reverse engineering quantified-mind.com
Python
2
star
51

RobolectricPowermock

Java
2
star
52

hpi_fission_talk

Talk on 20210422
CSS
2
star
53

bt-wifi-reconnect

Make BT Wifi great again
Python
2
star
54

kython

A collection of common python stuff I use
Python
2
star
55

scripts

Various personal scripts
Python
2
star
56

porg

Library for xpath-like org-mode queries
Python
2
star
57

haveibeenpwned

Script to track changes on haveibeenpwned (discontinued in favor of https://monitor.firefox.com)
Python
2
star
58

ruci

Rust
1
star
59

karlicoss.github.io

Staging for my blog
HTML
1
star
60

mydata

Public bits of my personal data
1
star
61

gcal-quickeradd

Python
1
star
62

lagrangians

Jupyter Notebook
1
star
63

my-awesome-list

Awesome stuff I am using
1
star
64

masters-thesis

TeX
1
star
65

exobrain-logseq

CSS
1
star
66

exporthelpers

Python
1
star
67

hsbc-parser

Extract transaction data from HSBC credit card PDF statements
Python
1
star
68

dominatepp

Dominate++
Python
1
star
69

hypothesis-top-annotators

Python
1
star
70

scrapyroo-slides

CSS
1
star
71

android-template

My empty Android project template
Groovy
1
star
72

python_duplicate_warnings_investigation

Python
1
star
73

promnesia-demos

Binary assets for Promnesia
1
star
74

.emacs.d

My emacs config
Emacs Lisp
1
star
75

backup-trees

Python
1
star
76

rtm-backup

Script to backup your Remember The Milk account data
Python
1
star
77

dropbox-paranoid

Tool to detect Dropbox conflicts and prevent symlink mess
Python
1
star
78

syncthing-paranoid

Python
1
star