From de0fb631df8865ae48026aa6960c0841018c3e5f Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 10 Jun 2020 01:13:51 +0200 Subject: Improve documentation for local development --- docs/src/contributing_local_development.md | 70 +++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 20 deletions(-) (limited to 'docs') diff --git a/docs/src/contributing_local_development.md b/docs/src/contributing_local_development.md index e823c9d1..f801caf3 100644 --- a/docs/src/contributing_local_development.md +++ b/docs/src/contributing_local_development.md @@ -1,31 +1,61 @@ -#### Requirements +### Ubuntu -- [Rust](https://www.rust-lang.org/) -- [Yarn](https://yarnpkg.com/en/) -- [Postgres](https://www.postgresql.org/) -#### Set up Postgres DB +#### Build requirements: +``` +sudo apt install git cargo libssl-dev pkg-config libpq-dev yarn curl gnupg2 git +# install yarn +curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - +echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list +sudo apt update && sudo apt install yarn +``` -```bash +#### Get the source code +``` +git clone https://github.com/LemmyNet/lemmy.git +# or alternatively from gitea +# git clone https://yerbamate.dev/LemmyNet/lemmy.git +``` + +All the following commands need to be run either in `lemmy/server` or `lemmy/ui`, as indicated +by the `cd` command. + +#### Build the backend (Rust) +``` cd server -./db-init.sh +cargo build +# for development, use `cargo check` instead) ``` -Or run the commands manually: +#### Build the frontend (Typescript) +``` +cd ui +yarn +yarn build +``` -```bash -psql -c "create user lemmy with password 'password' superuser;" -U postgres -psql -c 'create database lemmy with owner lemmy;' -U postgres +#### Setup postgresql +``` +sudo apt install postgresql +sudo systemctl start postgresql +# initialize postgres database +sudo -u postgres psql -c "create user lemmy with password 'password' superuser;" -U postgres +sudo -u postgres psql -c 'create database lemmy with owner lemmy;' -U postgres export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy +# or execute server/db-init.sh ``` -#### Running - -```bash -git clone https://github.com/LemmyNet/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 +#### Run a local development instance ``` +# run each of these in a seperate terminal +cd server && cargo run +ui & yarn start +``` + +Then open [localhost:4444](http://localhost:4444) in your browser. It will auto-refresh if you edit +any frontend files. For backend coding, you will have to rerun `cargo run`. You can use +`cargo check` as a faster way to find compilation errors. + +Note that this setup doesn't include image uploads or link previews (provided by pict-rs and +iframely respectively). If you want to test those, you should use the +[Docker development](contributing_docker_development.md). -- cgit v1.2.3 From 5a6f39dae4ac00f6a8d322c862de995b09e56bd1 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 12 Jun 2020 15:29:50 +0200 Subject: Various build optimizations --- docs/src/contributing_docker_development.md | 15 +++++++++++++-- docs/src/contributing_local_development.md | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/src/contributing_docker_development.md b/docs/src/contributing_docker_development.md index 09239821..afa05107 100644 --- a/docs/src/contributing_docker_development.md +++ b/docs/src/contributing_docker_development.md @@ -3,11 +3,22 @@ ## Running ```bash +sudo apt install git docker-compose git clone https://github.com/LemmyNet/lemmy cd lemmy/docker/dev -./docker_update.sh # This builds and runs it, updating for your changes +sudo docker-compose up --no-deps --build ``` and go to http://localhost:8536. -Note that compile times when changing `Cargo.toml` are relatively long with Docker, because builds can't be incrementally cached. If this is a problem for you, you should use [Local Development](contributing_local_development.md). +To speed up the Docker compile, add the following to `/etc/docker/daemon.json` and restart Docker. +``` +{ + "features": { + "buildkit": true + } +} +``` + +If the build is still too slow, you will have to use a +[local build](contributing_local_development.md) instead. diff --git a/docs/src/contributing_local_development.md b/docs/src/contributing_local_development.md index f801caf3..066386f5 100644 --- a/docs/src/contributing_local_development.md +++ b/docs/src/contributing_local_development.md @@ -56,6 +56,12 @@ Then open [localhost:4444](http://localhost:4444) in your browser. It will auto- any frontend files. For backend coding, you will have to rerun `cargo run`. You can use `cargo check` as a faster way to find compilation errors. +To speed up incremental builds, you can add the following to `~/.cargo/config`: +``` +[target.x86_64-unknown-linux-gnu] +rustflags = ["-Clink-arg=-fuse-ld=lld"] +``` + Note that this setup doesn't include image uploads or link previews (provided by pict-rs and iframely respectively). If you want to test those, you should use the [Docker development](contributing_docker_development.md). -- cgit v1.2.3 From 84ed1ecdfd0ef645c25452299fa9869415399631 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 23 Jun 2020 09:37:16 -0400 Subject: Fixing docker install instructions for pictshare. #831 --- docs/src/administration_install_docker.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'docs') diff --git a/docs/src/administration_install_docker.md b/docs/src/administration_install_docker.md index 236faa6b..05ec8ab3 100644 --- a/docs/src/administration_install_docker.md +++ b/docs/src/administration_install_docker.md @@ -6,10 +6,15 @@ Make sure you have both docker and docker-compose(>=`1.24.0`) installed. On Ubun # create a folder for the lemmy files. the location doesnt matter, you can put this anywhere you want mkdir /lemmy cd /lemmy + # download default config files wget https://raw.githubusercontent.com/dessalines/lemmy/master/docker/prod/docker-compose.yml wget https://raw.githubusercontent.com/dessalines/lemmy/master/docker/lemmy.hjson wget https://raw.githubusercontent.com/dessalines/lemmy/master/docker/iframely.config.local.js + +# Set correct permissions for pictrs folder +mkdir -p volumes/pictrs +sudo chown -R 991:991 volumes/pictrs ``` After this, have a look at the [config file](administration_configuration.md) named `lemmy.hjson`, and adjust it, in particular the hostname, and possibly the db password. Then run: -- cgit v1.2.3 From 790b944031f9433be765936763d848ffa6e1b496 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 23 Jun 2020 13:47:02 -0400 Subject: Changing to new lemmynet repo location. --- docs/src/administration_install_docker.md | 12 ++++++------ docs/src/contributing.md | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/src/administration_install_docker.md b/docs/src/administration_install_docker.md index 05ec8ab3..a2bed794 100644 --- a/docs/src/administration_install_docker.md +++ b/docs/src/administration_install_docker.md @@ -8,9 +8,9 @@ mkdir /lemmy cd /lemmy # download default config files -wget https://raw.githubusercontent.com/dessalines/lemmy/master/docker/prod/docker-compose.yml -wget https://raw.githubusercontent.com/dessalines/lemmy/master/docker/lemmy.hjson -wget https://raw.githubusercontent.com/dessalines/lemmy/master/docker/iframely.config.local.js +wget https://raw.githubusercontent.com/LemmyNet/lemmy/master/docker/prod/docker-compose.yml +wget https://raw.githubusercontent.com/LemmyNet/lemmy/master/docker/lemmy.hjson +wget https://raw.githubusercontent.com/LemmyNet/lemmy/master/docker/iframely.config.local.js # Set correct permissions for pictrs folder mkdir -p volumes/pictrs @@ -21,10 +21,10 @@ After this, have a look at the [config file](administration_configuration.md) na `docker-compose up -d` -To make Lemmy available outside the server, you need to setup a reverse proxy, like Nginx. [A sample nginx config](https://raw.githubusercontent.com/dessalines/lemmy/master/ansible/templates/nginx.conf), could be setup with: +To make Lemmy available outside the server, you need to setup a reverse proxy, like Nginx. [A sample nginx config](https://raw.githubusercontent.com/LemmyNet/lemmy/master/ansible/templates/nginx.conf), could be setup with: ```bash -wget https://raw.githubusercontent.com/dessalines/lemmy/master/ansible/templates/nginx.conf +wget https://raw.githubusercontent.com/LemmyNet/lemmy/master/ansible/templates/nginx.conf # Replace the {{ vars }} sudo mv nginx.conf /etc/nginx/sites-enabled/lemmy.conf ``` @@ -36,6 +36,6 @@ You will also need to setup TLS, for example with [Let's Encrypt](https://letsen To update to the newest version, you can manually change the version in `docker-compose.yml`. Alternatively, fetch the latest version from our git repo: ```bash -wget https://raw.githubusercontent.com/dessalines/lemmy/master/docker/prod/docker-compose.yml +wget https://raw.githubusercontent.com/LemmyNet/lemmy/master/docker/prod/docker-compose.yml docker-compose up -d ``` diff --git a/docs/src/contributing.md b/docs/src/contributing.md index 4eabd6fc..69d2f42e 100644 --- a/docs/src/contributing.md +++ b/docs/src/contributing.md @@ -5,7 +5,7 @@ Information about contributing to Lemmy, whether it is translating, testing, des ## Issue tracking / Repositories - [GitHub (for issues)](https://github.com/LemmyNet/lemmy) -- [Gitea](https://yerbamate.dev/dessalines/lemmy) +- [Gitea](https://yerbamate.dev/LemmyNet/lemmy) - [GitLab](https://gitlab.com/dessalines/lemmy) ## Translating -- cgit v1.2.3