vaultwarden/BUILD.md

71 lines
2.3 KiB
Markdown
Raw Normal View History

2018-07-13 09:48:49 +00:00
# Build instructions
## Dependencies
2018-07-09 13:09:30 +00:00
- `Rust nightly` (strongly recommended to use [rustup](https://rustup.rs/))
- `OpenSSL` (should be available in path, install through your system's package manager or use the [prebuilt binaries](https://wiki.openssl.org/index.php/Binaries))
- `NodeJS` (required to build the web-vault, (install through your system's package manager or use the [prebuilt binaries](https://nodejs.org/en/download/))
2018-05-25 15:15:31 +00:00
2018-07-09 13:09:30 +00:00
## Run/Compile
2018-05-25 15:15:31 +00:00
```sh
2018-07-09 13:09:30 +00:00
# Compile and run
2018-05-25 15:15:31 +00:00
cargo run
2018-07-09 13:09:30 +00:00
# or just compile (binary located in target/release/bitwarden_rs)
cargo build --release
2018-05-25 15:15:31 +00:00
```
2018-07-09 13:09:30 +00:00
When run, the server is accessible in [http://localhost:80](http://localhost:80).
2018-05-25 15:15:31 +00:00
2018-07-09 13:09:30 +00:00
### Install the web-vault
Clone the git repository at [bitwarden/web](https://github.com/bitwarden/web) and checkout the latest release tag (e.g. v2.1.1):
```sh
# clone the repository
git clone https://github.com/bitwarden/web.git web-vault
cd web-vault
# switch to the latest tag
git checkout "$(git tag | tail -n1)"
```
2018-05-25 15:15:31 +00:00
Apply the patch file from `docker/set-vault-baseurl.patch`:
```sh
# In the Vault repository directory
git apply /path/to/bitwarden_rs/docker/set-vault-baseurl.patch
2018-05-25 15:15:31 +00:00
```
Then, build the Vault:
2018-05-25 15:15:31 +00:00
```sh
npm run sub:init
2018-05-25 15:15:31 +00:00
npm install
npm run dist
2018-05-25 15:15:31 +00:00
```
Finally copy the contents of the `build` folder into the `bitwarden_rs/web-vault` folder.
2018-05-25 15:15:31 +00:00
2018-07-09 13:09:30 +00:00
# Configuration
The available configuration options are documented in the default `.env` file, and they can be modified by uncommenting the desired options in that file or by setting their respective environment variables. Look at the README file for the main configuration options available.
Note: the environment variables override the values set in the `.env` file.
## How to recreate database schemas (for developers)
2018-05-25 15:15:31 +00:00
Install diesel-cli with cargo:
```sh
2018-07-09 13:09:30 +00:00
cargo install diesel_cli --no-default-features --features sqlite-bundled
2018-05-25 15:15:31 +00:00
```
Make sure that the correct path to the database is in the `.env` file.
If you want to modify the schemas, create a new migration with:
```
diesel migration generate <name>
```
Modify the *.sql files, making sure that any changes are reverted in the down.sql file.
Apply the migrations and save the generated schemas as follows:
2018-07-09 13:09:30 +00:00
```sh
2018-05-25 15:15:31 +00:00
diesel migration redo
2018-07-09 13:09:30 +00:00
# This step should be done automatically when using diesel-cli > 1.3.0
# diesel print-schema > src/db/schema.rs
```