diff --git a/.dockerignore b/.dockerignore index 03466f0a3..73c475542 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,4 @@ ui/node_modules ui/dist server/target -docs .git diff --git a/README.md b/README.md index c5a30598d..5109d169f 100644 --- a/README.md +++ b/README.md @@ -36,63 +36,6 @@ Front Page|Post ---|--- ![main screen](https://i.imgur.com/kZSRcRu.png)|![chat screen](https://i.imgur.com/4XghNh6.png) -## 📝 Table of Contents - - - -- [Features](#features) -- [About](#about) - * [Why's it called Lemmy?](#whys-it-called-lemmy) -- [Install](#install) - * [Docker](#docker) - + [Updating](#updating) - * [Ansible](#ansible) - * [Kubernetes](#kubernetes) -- [Develop](#develop) - * [Docker Development](#docker-development) - * [Local Development](#local-development) - + [Requirements](#requirements) - + [Set up Postgres DB](#set-up-postgres-db) - + [Running](#running) -- [Configuration](#configuration) -- [Documentation](#documentation) -- [Support](#support) -- [Translations](#translations) -- [Credits](#credits) - - - -## Features - -- Open source, [AGPL License](/LICENSE). -- Self hostable, easy to deploy. - - Comes with [Docker](#docker), [Ansible](#ansible), [Kubernetes](#kubernetes). -- Clean, mobile-friendly interface. - - Live-updating Comment threads. - - Full vote scores `(+/-)` like old reddit. - - Themes, including light, dark, and solarized. - - Emojis with autocomplete support. Start typing `:` - - User tagging using `@`, Community tagging using `#`. - - Notifications, on comment replies and when you're tagged. - - i18n / internationalization support. - - RSS / Atom feeds for `All`, `Subscribed`, `Inbox`, `User`, and `Community`. -- Cross-posting support. - - A *similar post search* when creating new posts. Great for question / answer communities. -- Moderation abilities. - - Public Moderation Logs. - - Both site admins, and community moderators, who can appoint other moderators. - - Can lock, remove, and restore posts and comments. - - Can ban and unban users from communities and the site. - - Can transfer site and communities to others. -- Can fully erase your data, replacing all posts and comments. -- NSFW post / community support. -- High performance. - - Server is written in rust. - - Front end is `~80kB` gzipped. - - Supports arm64 / Raspberry Pi. - -## About - [Lemmy](https://github.com/dessalines/lemmy) is similar to sites like [Reddit](https://reddit.com), [Lobste.rs](https://lobste.rs), [Raddle](https://raddle.me), or [Hacker News](https://news.ycombinator.com/): you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them. Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the [Fediverse](https://en.wikipedia.org/wiki/Fediverse). For a link aggregator, this means a user registered on one server can subscribe to forums on any other server, and can have discussions with users registered elsewhere. @@ -101,15 +44,6 @@ The overall goal is to create an easily self-hostable, decentralized alternative Each lemmy server can set its own moderation policy; appointing site-wide admins, and community moderators to keep out the trolls, and foster a healthy, non-toxic environment where all can feel comfortable contributing. -### Why's it called Lemmy? - -- Lead singer from [Motörhead](https://invidio.us/watch?v=pWB5JZRGl0U). -- The old school [video game](). -- The [Koopa from Super Mario](https://www.mariowiki.com/Lemmy_Koopa). -- The [furry rodents](http://sunchild.fpwc.org/lemming-the-little-giant-of-the-north/). - -Made with [Rust](https://www.rust-lang.org), [Actix](https://actix.rs/), [Inferno](https://www.infernojs.org), [Typescript](https://www.typescriptlang.org/) and [Diesel](http://diesel.rs/). - ## Install ### Docker @@ -157,88 +91,6 @@ nano inventory # enter your server, domain, contact email ansible-playbook lemmy.yml --become ``` -### Kubernetes - -You'll need to have an existing Kubernetes cluster and [storage class](https://kubernetes.io/docs/concepts/storage/storage-classes/). -Setting this up will vary depending on your provider. -To try it locally, you can use [MicroK8s](https://microk8s.io/) or [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/). - -Once you have a working cluster, edit the environment variables and volume sizes in `docker/k8s/*.yml`. -You may also want to change the service types to use `LoadBalancer`s depending on where you're running your cluster (add `type: LoadBalancer` to `ports)`, or `NodePort`s. -By default they will use `ClusterIP`s, which will allow access only within the cluster. See the [docs](https://kubernetes.io/docs/concepts/services-networking/service/) for more on networking in Kubernetes. - -**Important** Running a database in Kubernetes will work, but is generally not recommended. -If you're deploying on any of the common cloud providers, you should consider using their managed database service instead (RDS, Cloud SQL, Azure Databse, etc.). - -Now you can deploy: - -```bash -# Add `-n foo` if you want to deploy into a specific namespace `foo`; -# otherwise your resources will be created in the `default` namespace. -kubectl apply -f docker/k8s/db.yml -kubectl apply -f docker/k8s/pictshare.yml -kubectl apply -f docker/k8s/lemmy.yml -``` - -If you used a `LoadBalancer`, you should see it in your cloud provider's console. - -## Develop - -### Docker Development - -Run: - -```bash -git clone https://github.com/dessalines/lemmy -cd lemmy/docker/dev -./docker_update.sh # This builds and runs it, updating for your changes -``` - -and go to http://localhost:8536. - -### Local Development - -#### Requirements - -- [Rust](https://www.rust-lang.org/) -- [Yarn](https://yarnpkg.com/en/) -- [Postgres](https://www.postgresql.org/) - -#### Set up Postgres DB - -```bash - psql -c "create user lemmy with password 'password' superuser;" -U postgres - psql -c 'create database lemmy with owner lemmy;' -U postgres - export DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy -``` - -#### Running - -```bash -git clone https://github.com/dessalines/lemmy -cd lemmy -./install.sh -# For live coding, where both the front and back end, automagically reload on any save, do: -# cd ui && yarn start -# cd server && cargo watch -x run -``` - -## Configuration - -The configuration is based on the file [defaults.hjson](server/config/defaults.hjson). This file also contains documentation for all the available options. To override the defaults, you can copy the options you want to change into your local `config.hjson` file. - -Additionally, you can override any config files with environment variables. These have the same name as the config options, and are prefixed with `LEMMY_`. For example, you can override the `database.password` with -`LEMMY__DATABASE__POOL_SIZE=10`. - -An additional option `LEMMY_DATABASE_URL` is available, which can be used with a PostgreSQL connection string like `postgres://lemmy:password@lemmy_db:5432/lemmy`, passing all connection details at once. - -## Documentation - -- [Websocket API for App developers](docs/api.md) -- [ActivityPub API.md](docs/apub_api_outline.md) -- [Goals](docs/goals.md) -- [Ranking Algorithm](docs/ranking.md) - ## Support Lemmy is free, open-source software, meaning no advertising, monetizing, or venture capital, ever. Your donations directly support full-time development of the project. diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index d62e7b279..761d8cc3c 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -32,6 +32,14 @@ RUN cargo build --frozen --release # Get diesel-cli on there just in case # RUN cargo install diesel_cli --no-default-features --features postgres + +FROM ekidd/rust-musl-builder:1.38.0-openssl11 as docs +WORKDIR /app +COPY docs ./docs +RUN sudo chown -R rust:rust . +RUN mdbook build docs/ + + FROM alpine:3.10 # Install libpq for postgres @@ -40,6 +48,7 @@ RUN apk add libpq # Copy resources COPY server/config/defaults.hjson /config/defaults.hjson COPY --from=rust /app/server/target/x86_64-unknown-linux-musl/release/lemmy_server /app/lemmy +COPY --from=docs /app/docs/book/ /app/dist/documentation/ COPY --from=node /app/ui/dist /app/dist RUN addgroup -g 1000 lemmy diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 000000000..7585238ef --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +book diff --git a/docs/book.toml b/docs/book.toml new file mode 100644 index 000000000..55cce8c03 --- /dev/null +++ b/docs/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["Felix Ableitner"] +language = "en" +multilingual = false +src = "src" +title = "Lemmy Documentation" diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md new file mode 100644 index 000000000..d89169746 --- /dev/null +++ b/docs/src/SUMMARY.md @@ -0,0 +1,16 @@ +# Summary + +- [About](about.md) + - [Features](about_features.md) + - [Goals](about_goals.md) + - [Post and Comment Ranking](about_ranking.md) +- [Administration](administration.md) + - [Install with Docker](administration_install_docker.md) + - [Install with Ansible](administration_install_ansible.md) + - [Install with Kubernetes](administration_install_kubernetes.md) + - [Configuration](administration_configuration.md) +- [Contributing](contributing.md) + - [Docker Development](contributing_docker_development.md) + - [Local Development](contributing_local_development.md) + - [Websocket API](contributing_websocket_api.md) + - [ActivityPub API Outline](contributing_apub_api_outline.md) diff --git a/docs/src/about.md b/docs/src/about.md new file mode 100644 index 000000000..14743df2c --- /dev/null +++ b/docs/src/about.md @@ -0,0 +1,22 @@ +

A link aggregator / reddit clone for the fediverse. +
+

+ +[Lemmy Dev instance](https://dev.lemmy.ml) *for testing purposes only* + +[Lemmy](https://github.com/dessalines/lemmy) is similar to sites like [Reddit](https://reddit.com), [Lobste.rs](https://lobste.rs), [Raddle](https://raddle.me), or [Hacker News](https://news.ycombinator.com/): you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them. Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the [Fediverse](https://en.wikipedia.org/wiki/Fediverse). + +For a link aggregator, this means a user registered on one server can subscribe to forums on any other server, and can have discussions with users registered elsewhere. + +The overall goal is to create an easily self-hostable, decentralized alternative to reddit and other link aggregators, outside of their corporate control and meddling. + +Each lemmy server can set its own moderation policy; appointing site-wide admins, and community moderators to keep out the trolls, and foster a healthy, non-toxic environment where all can feel comfortable contributing. + +### Why's it called Lemmy? + +- Lead singer from [Motörhead](https://invidio.us/watch?v=pWB5JZRGl0U). +- The old school [video game](). +- The [Koopa from Super Mario](https://www.mariowiki.com/Lemmy_Koopa). +- The [furry rodents](http://sunchild.fpwc.org/lemming-the-little-giant-of-the-north/). + +Made with [Rust](https://www.rust-lang.org), [Actix](https://actix.rs/), [Inferno](https://www.infernojs.org), [Typescript](https://www.typescriptlang.org/) and [Diesel](http://diesel.rs/). diff --git a/docs/src/about_features.md b/docs/src/about_features.md new file mode 100644 index 000000000..dab859c13 --- /dev/null +++ b/docs/src/about_features.md @@ -0,0 +1,26 @@ +- Open source, [AGPL License](/LICENSE). +- Self hostable, easy to deploy. + - Comes with [Docker](#docker), [Ansible](#ansible), [Kubernetes](#kubernetes). +- Clean, mobile-friendly interface. + - Live-updating Comment threads. + - Full vote scores `(+/-)` like old reddit. + - Themes, including light, dark, and solarized. + - Emojis with autocomplete support. Start typing `:` + - User tagging using `@`, Community tagging using `#`. + - Notifications, on comment replies and when you're tagged. + - i18n / internationalization support. + - RSS / Atom feeds for `All`, `Subscribed`, `Inbox`, `User`, and `Community`. +- Cross-posting support. + - A *similar post search* when creating new posts. Great for question / answer communities. +- Moderation abilities. + - Public Moderation Logs. + - Both site admins, and community moderators, who can appoint other moderators. + - Can lock, remove, and restore posts and comments. + - Can ban and unban users from communities and the site. + - Can transfer site and communities to others. +- Can fully erase your data, replacing all posts and comments. +- NSFW post / community support. +- High performance. + - Server is written in rust. + - Front end is `~80kB` gzipped. + - Supports arm64 / Raspberry Pi. \ No newline at end of file diff --git a/docs/goals.md b/docs/src/about_goals.md similarity index 100% rename from docs/goals.md rename to docs/src/about_goals.md diff --git a/docs/ranking.md b/docs/src/about_ranking.md similarity index 100% rename from docs/ranking.md rename to docs/src/about_ranking.md diff --git a/docs/src/administration.md b/docs/src/administration.md new file mode 100644 index 000000000..c4c2b01f1 --- /dev/null +++ b/docs/src/administration.md @@ -0,0 +1 @@ +Information for Lemmy instance admins, and those who want to start an instance. \ No newline at end of file diff --git a/docs/src/administration_configuration.md b/docs/src/administration_configuration.md new file mode 100644 index 000000000..73ea35042 --- /dev/null +++ b/docs/src/administration_configuration.md @@ -0,0 +1,6 @@ +The configuration is based on the file [defaults.hjson](server/config/defaults.hjson). This file also contains documentation for all the available options. To override the defaults, you can copy the options you want to change into your local `config.hjson` file. + +Additionally, you can override any config files with environment variables. These have the same name as the config options, and are prefixed with `LEMMY_`. For example, you can override the `database.password` with +`LEMMY__DATABASE__POOL_SIZE=10`. + +An additional option `LEMMY_DATABASE_URL` is available, which can be used with a PostgreSQL connection string like `postgres://lemmy:password@lemmy_db:5432/lemmy`, passing all connection details at once. diff --git a/docs/src/administration_install_ansible.md b/docs/src/administration_install_ansible.md new file mode 100644 index 000000000..03642b897 --- /dev/null +++ b/docs/src/administration_install_ansible.md @@ -0,0 +1,11 @@ +First, you need to [install Ansible on your local computer](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) (e.g. using `sudo apt install ansible`) or the equivalent for you platform. + +Then run the following commands on your local computer: + +```bash +git clone https://github.com/dessalines/lemmy.git +cd lemmy/ansible/ +cp inventory.example inventory +nano inventory # enter your server, domain, contact email +ansible-playbook lemmy.yml --become +``` diff --git a/docs/src/administration_install_docker.md b/docs/src/administration_install_docker.md new file mode 100644 index 000000000..64abe737e --- /dev/null +++ b/docs/src/administration_install_docker.md @@ -0,0 +1,28 @@ +Make sure you have both docker and docker-compose(>=`1.24.0`) installed: + +```bash +mkdir lemmy/ +cd lemmy/ +wget https://raw.githubusercontent.com/dessalines/lemmy/master/docker/prod/docker-compose.yml +wget https://raw.githubusercontent.com/dessalines/lemmy/master/docker/lemmy.hjson +# Edit lemmy.hjson to do more configuration +docker-compose up -d +``` + +and go to http://localhost:8536. + +[A sample nginx config](/ansible/templates/nginx.conf), could be setup with: + +```bash +wget https://raw.githubusercontent.com/dessalines/lemmy/master/ansible/templates/nginx.conf +# Replace the {{ vars }} +sudo mv nginx.conf /etc/nginx/sites-enabled/lemmy.conf +``` +#### Updating + +To update to the newest version, run: + +```bash +wget https://raw.githubusercontent.com/dessalines/lemmy/master/docker/prod/docker-compose.yml +docker-compose up -d +``` diff --git a/docs/src/administration_install_kubernetes.md b/docs/src/administration_install_kubernetes.md new file mode 100644 index 000000000..886558dce --- /dev/null +++ b/docs/src/administration_install_kubernetes.md @@ -0,0 +1,22 @@ +You'll need to have an existing Kubernetes cluster and [storage class](https://kubernetes.io/docs/concepts/storage/storage-classes/). +Setting this up will vary depending on your provider. +To try it locally, you can use [MicroK8s](https://microk8s.io/) or [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/). + +Once you have a working cluster, edit the environment variables and volume sizes in `docker/k8s/*.yml`. +You may also want to change the service types to use `LoadBalancer`s depending on where you're running your cluster (add `type: LoadBalancer` to `ports)`, or `NodePort`s. +By default they will use `ClusterIP`s, which will allow access only within the cluster. See the [docs](https://kubernetes.io/docs/concepts/services-networking/service/) for more on networking in Kubernetes. + +**Important** Running a database in Kubernetes will work, but is generally not recommended. +If you're deploying on any of the common cloud providers, you should consider using their managed database service instead (RDS, Cloud SQL, Azure Databse, etc.). + +Now you can deploy: + +```bash +# Add `-n foo` if you want to deploy into a specific namespace `foo`; +# otherwise your resources will be created in the `default` namespace. +kubectl apply -f docker/k8s/db.yml +kubectl apply -f docker/k8s/pictshare.yml +kubectl apply -f docker/k8s/lemmy.yml +``` + +If you used a `LoadBalancer`, you should see it in your cloud provider's console. diff --git a/docs/src/contributing.md b/docs/src/contributing.md new file mode 100644 index 000000000..4f29af3da --- /dev/null +++ b/docs/src/contributing.md @@ -0,0 +1 @@ +Information about contributing to Lemmy, whether it is translating, testing, designing or programming. \ No newline at end of file diff --git a/docs/apub_api_outline.md b/docs/src/contributing_apub_api_outline.md similarity index 100% rename from docs/apub_api_outline.md rename to docs/src/contributing_apub_api_outline.md diff --git a/docs/src/contributing_docker_development.md b/docs/src/contributing_docker_development.md new file mode 100644 index 000000000..0ed5bde5e --- /dev/null +++ b/docs/src/contributing_docker_development.md @@ -0,0 +1,11 @@ +Run: + +```bash +git clone https://github.com/dessalines/lemmy +cd lemmy/docker/dev +./docker_update.sh # This builds and runs it, updating for your changes +``` + +and go to http://localhost:8536. + +Note that compile times are relatively long with Docker, because builds can't be properly cached. If this is a problem for you, you should use [Local Development](contributing_local_development.md). \ No newline at end of file diff --git a/docs/src/contributing_local_development.md b/docs/src/contributing_local_development.md new file mode 100644 index 000000000..a681eeb0d --- /dev/null +++ b/docs/src/contributing_local_development.md @@ -0,0 +1,24 @@ +#### Requirements + +- [Rust](https://www.rust-lang.org/) +- [Yarn](https://yarnpkg.com/en/) +- [Postgres](https://www.postgresql.org/) + +#### Set up Postgres DB + +```bash + psql -c "create user lemmy with password 'password' superuser;" -U postgres + psql -c 'create database lemmy with owner lemmy;' -U postgres + export DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy +``` + +#### Running + +```bash +git clone https://github.com/dessalines/lemmy +cd lemmy +./install.sh +# For live coding, where both the front and back end, automagically reload on any save, do: +# cd ui && yarn start +# cd server && cargo watch -x run +``` diff --git a/docs/api.md b/docs/src/contributing_websocket_api.md similarity index 100% rename from docs/api.md rename to docs/src/contributing_websocket_api.md