]> Untitled Git - lemmy.git/blob - docs/src/contributing_local_development.md
Merge branch 'master' into use-pictrs-1
[lemmy.git] / docs / src / contributing_local_development.md
1 ### Ubuntu
2
3
4 #### Build requirements:
5 ```
6 sudo apt install git cargo libssl-dev pkg-config libpq-dev yarn curl gnupg2 git
7 # install yarn
8 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
9 echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
10 sudo apt update && sudo apt install yarn
11 ```
12
13 #### Get the source code
14 ```
15 git clone https://github.com/LemmyNet/lemmy.git
16 # or alternatively from gitea
17 # git clone https://yerbamate.dev/LemmyNet/lemmy.git
18 ```
19
20 All the following commands need to be run either in `lemmy/server` or `lemmy/ui`, as indicated
21 by the `cd` command.
22
23 #### Build the backend (Rust)
24 ```
25 cd server
26 cargo build
27 # for development, use `cargo check` instead)
28 ```
29
30 #### Build the frontend (Typescript)
31 ```
32 cd ui
33 yarn
34 yarn build
35 ```
36
37 #### Setup postgresql
38 ```
39 sudo apt install postgresql
40 sudo systemctl start postgresql
41 # initialize postgres database
42 sudo -u postgres psql -c "create user lemmy with password 'password' superuser;" -U postgres
43 sudo -u postgres psql -c 'create database lemmy with owner lemmy;' -U postgres
44 export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy
45 # or execute server/db-init.sh
46 ```
47
48 #### Run a local development instance
49 ```
50 # run each of these in a seperate terminal
51 cd server && cargo run
52 ui & yarn start
53 ```
54
55 Then open [localhost:4444](http://localhost:4444) in your browser. It will auto-refresh if you edit
56 any frontend files. For backend coding, you will have to rerun `cargo run`. You can use
57 `cargo check` as a faster way to find compilation errors.
58
59 To speed up incremental builds, you can add the following to `~/.cargo/config`:
60 ```
61 [target.x86_64-unknown-linux-gnu]
62 rustflags = ["-Clink-arg=-fuse-ld=lld"]
63 ```
64
65 Note that this setup doesn't include image uploads or link previews (provided by pict-rs and
66 iframely respectively). If you want to test those, you should use the
67 [Docker development](contributing_docker_development.md).