]> Untitled Git - lemmy.git/blob - docs/src/contributing_local_development.md
Isomorphic docker (#1124)
[lemmy.git] / docs / src / contributing_local_development.md
1 ### Install build requirements
2 #### Ubuntu
3 ```
4 sudo apt install git cargo libssl-dev pkg-config libpq-dev yarn curl gnupg2 espeak
5 # install yarn
6 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
7 echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
8 sudo apt update && sudo apt install yarn
9 ```
10
11 #### macOS
12
13 Install Rust using [the recommended option on rust-lang.org](https://www.rust-lang.org/tools/install) (rustup).
14
15 Then, install [Homebrew](https://brew.sh/) if you don't already have it installed.
16
17 Finally, install Node and Yarn.
18
19 ```
20 brew install node yarn
21 ```
22
23 ### Get the back end source code
24 ```
25 git clone https://github.com/LemmyNet/lemmy.git
26 # or alternatively from gitea
27 # git clone https://yerbamate.dev/LemmyNet/lemmy.git
28 ```
29
30 ### Build the backend (Rust)
31 ```
32 cargo build
33 # for development, use `cargo check` instead)
34 ```
35
36 ### Get the front end source code
37 ```
38 git clone https://github.com/LemmyNet/lemmy-ui.git
39 ```
40
41 ### Setup postgresql
42 #### Ubuntu
43 ```
44 sudo apt install postgresql
45 sudo systemctl start postgresql
46
47 # Either execute db-init.sh, or manually initialize the postgres database:
48 sudo -u postgres psql -c "create user lemmy with password 'password' superuser;" -U postgres
49 sudo -u postgres psql -c 'create database lemmy with owner lemmy;' -U postgres
50 export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy
51 ```
52
53 #### macOS
54 ```
55 brew install postgresql
56 brew services start postgresql
57 /usr/local/opt/postgres/bin/createuser -s postgres
58
59 # Either execute db-init.sh, or manually initialize the postgres database:
60 psql -c "create user lemmy with password 'password' superuser;" -U postgres
61 psql -c 'create database lemmy with owner lemmy;' -U postgres
62 export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy
63 ```
64
65 ### Run a local development instance
66 ```
67 cd lemmy
68 cargo run
69 ```
70
71 Then open [localhost:1235](http://localhost:1235) in your browser. To reload back-end changes, you will have to rerun `cargo run`. You can use `cargo check` as a faster way to find compilation errors.
72
73 To do front end development:
74
75 ```
76 cd lemmy-ui
77 yarn
78 yarn dev
79 ```
80
81 and goto [localhost:1234](http://localhost:1234). Front end saves should rebuild the project.
82
83 Note that this setup doesn't include image uploads or link previews (provided by pict-rs and
84 iframely respectively). If you want to test those, you should use the
85 [Docker development](contributing_docker_development.md).