Simplify contribution

This commit is contained in:
Sung 2025-10-05 21:36:27 -07:00
commit 732c325e87
9 changed files with 86 additions and 263 deletions

View file

@ -8,89 +8,61 @@ Dnote is an open source project.
## Setting up
Dnote uses [Vagrant](https://github.com/hashicorp/vagrant) to provision a consistent development environment.
The CLI and server are single single binary files with SQLite embedded - no databases to install, no containers to run, no VMs required.
*Prerequisites*
**Prerequisites**
* Vagrant ([Download](https://www.vagrantup.com/downloads.html))
* VirtualBox ([Download](https://www.virtualbox.org/))
* Go 1.25+ ([Download](https://go.dev/dl/))
* Node.js 18+ ([Download](https://nodejs.org/) - only needed for building frontend assets)
Run the following command from the project root. It starts the virtual machine and bootstraps the project.
**Quick Start**
```
vagrant up
```
1. Clone the repository
2. Install dependencies:
```bash
make install
```
3. Start developing! Run tests:
```bash
make test
```
Or start the dev server:
```bash
make dev-server
```
*Workflow*
* You can make changes to the source code from the host machine.
* Any commands need to be run inside the virtual machine. You can connect to it by running `vagrant ssh`.
* If you want to run tests in a WATCH mode, please do so from the host machine. We cannot watch file changes due to the limitation of file system used in a virtual machine.
That's it. You're ready to contribute.
## Server
The server consists of the frontend web application and a web server.
### Development
* Run `make dev-server` to start a local server.
* You can access the server on `localhost:3000` on your machine.
### Test
```bash
# Run tests for app
# Start dev server (runs on localhost:3000)
make dev-server
# Run tests
make test-api
# Run in watch mode
# Run tests in watch mode
WATCH=true make test-api
```
## Command Line Interface
### Build
```bash
# Run tests
make test-cli
You can build either a development version or a production version:
```
# Build a development version for your platform and place it in your `PATH`.
# Build dev version (places in your PATH)
make debug=true build-cli
# Build a production version for all platforms
# Build production version for all platforms
make version=v0.1.0 build-cli
# Build a production version for a specific platform
# Build for a specific platform
# Note: You cannot cross-compile using this method because Dnote uses CGO
# and requires the OS specific headers.
GOOS=[insert OS] GOARCH=[insert arch] make version=v0.1.0 build-cli
```
### Test
* Run all tests for the command line interface:
```
make test-cli
```
### Debug
Run Dnote with `DNOTE_DEBUG=1` to print debugging statements. For instance:
```
# Debug mode
DNOTE_DEBUG=1 dnote sync
```
### Release
* Run `make version=v0.1.0 release-cli` to achieve the following:
* Build for all target platforms, create a git tag, push all tags to the repository
* Create a release on GitHub and [Dnote Homebrew tap](https://github.com/dnote/homebrew-dnote).
**Note**
- If a release is not stable,
- disable the homebrew release by commenting out relevant code in the release script.
- mark release as pre-release on GitHub release

View file

@ -3,30 +3,42 @@
![Build Status](https://github.com/dnote/dnote/actions/workflows/ci.yml/badge.svg)
Dnote is a simple command line notebook for programmers.
Dnote is a simple command line notebook. Single binary, no dependencies. Since 2017.
It **keeps you focused** by providing a way of effortlessly capturing and retrieving information **without leaving your terminal**. It also offers a seamless **multi-device sync**.
Your notes are stored in **one SQLite file** - portable, searchable, and completely under your control. Optional sync between devices via a self-hosted server with REST API access.
![A demo of Dnote command line interface](assets/cli.gif "Dnote command line interface")
```sh
# Add a note (or omit -c to launch your editor)
dnote add linux -c "Check disk usage with df -h"
# View notes in a book
dnote view linux
# Full-text search
dnote find "disk usage"
# Sync notes
dnote sync
```
## Installation
On macOS, you can install using Homebrew:
On Unix-like systems (Linux, FreeBSD, macOS), you can use the installation script:
curl -s https://www.getdnote.com/install | sh
Or on macOS with Homebrew:
```sh
brew tap dnote/dnote
brew install dnote
```
On Linux or macOS, you can use the installation script:
curl -s https://www.getdnote.com/install | sh
Otherwise, you can download the binary for your platform manually from the [releases page](https://github.com/dnote/dnote/releases).
You can also download the binary for your platform from the [releases page](https://github.com/dnote/dnote/releases).
## Server
You can install it [using Docker](https://github.com/dnote/dnote/blob/master/host/docker/README.md), or [using a binary](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md).
Self-host your own Dnote server - just run a binary, no database required. [Download](https://github.com/dnote/dnote/blob/master/SELF_HOSTING.md) or run [with Docker](https://github.com/dnote/dnote/blob/master/host/docker/README.md).
## Documentation

View file

@ -1,47 +1,26 @@
# Installing Dnote Server
# Self-Hosting Dnote Server
This guide documents the steps for installing the Dnote server on your own machine. If you prefer Docker, please see [the Docker guide](https://github.com/dnote/dnote/blob/master/host/docker/README.md).
For Docker installation, see [the Docker guide](https://github.com/dnote/dnote/blob/master/host/docker/README.md).
## Overview
## Quick Start
Dnote server comes as a single binary file that you can simply download and run. It uses SQLite as the database.
## Installation
1. Download the official Dnote server release from the [release page](https://github.com/dnote/dnote/releases).
2. Extract the archive and move the `dnote-server` executable to `/usr/local/bin`.
Download from [releases](https://github.com/dnote/dnote/releases), extract, and run:
```bash
tar -xzf dnote-server-$version-$os.tar.gz
mv ./dnote-server /usr/local/bin
dnote-server start --webUrl=https://your.server
```
3. Run Dnote
You're up and running. Database: `~/.local/share/dnote/server.db` (customize with `--dbPath`). Run `dnote-server start --help` for options.
```bash
dnote-server start --webUrl=$webURL
```
Set `apiEndpoint: https://your.server/api` in `~/.config/dnote/dnoterc` to connect your CLI to the server.
Replace `$webURL` with the full URL to your server, without a trailing slash (e.g. `https://your.server`).
## Optional guide
Additional flags:
- `--port`: Server port (default: `3000`)
- `--disableRegistration`: Disable user registration (default: `false`)
- `--logLevel`: Log level: `debug`, `info`, `warn`, or `error` (default: `info`)
- `--appEnv`: environment (default: `PRODUCTION`)
### Nginx
You can also use environment variables: `PORT`, `WebURL`, `DisableRegistration`, `LOG_LEVEL`, `APP_ENV`.
## Configuration
By now, Dnote is fully functional in your machine. The API, frontend app, and the background tasks are all in the single binary. Let's take a few more steps to configure Dnote.
### Configure Nginx
To make it accessible from the Internet, you need to configure Nginx.
1. Install nginx.
2. Create a new file in `/etc/nginx/sites-enabled/dnote` with the following contents:
Create `/etc/nginx/sites-enabled/dnote`:
```
server {
@ -55,17 +34,16 @@ server {
}
}
```
3. Replace `my-dnote-server.com` with the URL for your server.
4. Reload the nginx configuration by running the following:
```
Replace `my-dnote-server.com` with your domain, then reload:
```bash
sudo service nginx reload
```
### Configure Apache2
### Apache2
1. Install Apache2 and install/enable mod_proxy.
2. Create a new file in `/etc/apache2/sites-available/dnote.conf` with the following contents:
Enable `mod_proxy`, then create `/etc/apache2/sites-available/dnote.conf`:
```
<VirtualHost *:80>
@ -79,26 +57,20 @@ sudo service nginx reload
</VirtualHost>
```
3. Enable the dnote site and restart the Apache2 service by running the following:
Enable and restart:
```
```bash
a2ensite dnote
sudo service apache2 restart
```
Now you can access the Dnote frontend application on `/`, and the API on `/api`.
### TLS
### Configure TLS by using LetsEncrypt
Use LetsEncrypt to obtain a certificate and configure HTTPS in your reverse proxy.
It is recommended to use HTTPS. Obtain a certificate using LetsEncrypt and configure TLS in Nginx.
### systemd Daemon
In the future versions of the Dnote Server, HTTPS will be required at all times.
### Run Dnote As a Daemon
We can use `systemd` to run Dnote in the background as a Daemon, and automatically start it on system reboot.
1. Create a new file at `/etc/systemd/system/dnote.service` with the following content:
Create `/etc/systemd/system/dnote.service`:
```
[Unit]
@ -118,45 +90,23 @@ ExecStart=/usr/local/bin/dnote-server start --webUrl=$WebURL
WantedBy=multi-user.target
```
Replace `$user` and `$WebURL` with the actual values.
Replace `$user` and `$WebURL`. Add `--dbPath` to `ExecStart` if you want a custom database location.
By default, the database will be stored at `$XDG_DATA_HOME/dnote/server.db` (typically `~/.local/share/dnote/server.db`). To use a custom location, add `--dbPath=/path/to/database.db` to the `ExecStart` command.
Enable and start:
2. Reload the change by running `sudo systemctl daemon-reload`.
3. Enable the Daemon by running `sudo systemctl enable dnote`.`
4. Start the Daemon by running `sudo systemctl start dnote`
```bash
sudo systemctl daemon-reload
sudo systemctl enable dnote
sudo systemctl start dnote
```
### Optional: Email Support
### Email Support
To enable sending emails, add the following environment variables to your configuration. But they are not required.
If you want emails, add these environment variables:
- `SmtpHost` - SMTP server hostname
- `SmtpPort` - SMTP server port
- `SmtpHost` - SMTP hostname
- `SmtpPort` - SMTP port
- `SmtpUsername` - SMTP username
- `SmtpPassword` - SMTP password
For systemd, add these as additional `Environment=` lines in `/etc/systemd/system/dnote.service`.
### Configure clients
Let's configure Dnote clients to connect to the self-hosted web API endpoint.
#### CLI
We need to modify the configuration file for the CLI. It should have been generated at `~/.config/dnote/dnoterc` upon running the CLI for the first time.
The following is an example configuration:
```yaml
editor: nvim
apiEndpoint: https://localhost:3000/api
```
Simply change the value for `apiEndpoint` to a full URL to the self-hosted instance, followed by '/api', and save the configuration file.
e.g.
```yaml
editor: nvim
apiEndpoint: my-dnote-server.com/api
```
For systemd, add as `Environment=` lines in the service file.

20
Vagrantfile vendored
View file

@ -1,20 +0,0 @@
# -*- mode: ruby -*-
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.synced_folder '.', '/go/src/github.com/dnote/dnote'
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 5432, host: 5433
config.vm.provision 'shell', path: './scripts/vagrant/install_utils.sh'
config.vm.provision 'shell', path: './scripts/vagrant/install_go.sh', privileged: false
config.vm.provision 'shell', path: './scripts/vagrant/install_node.sh', privileged: false
config.vm.provision 'shell', path: './scripts/vagrant/install_postgres.sh', privileged: false
config.vm.provision 'shell', path: './scripts/vagrant/bootstrap.sh', privileged: false
config.vm.provider "virtualbox" do |v|
v.memory = 4000
v.cpus = 2
end
end

View file

@ -1,19 +0,0 @@
#!/usr/bin/env bash
set -ex
echo "export DNOTE=/go/src/github.com/dnote/dnote" >> /home/vagrant/.bash_profile
echo "cd /go/src/github.com/dnote/dnote" >> /home/vagrant/.bash_profile
# install dependencies
(cd /go/src/github.com/dnote/dnote && make install)
# set up database
sudo -u postgres createdb dnote
sudo -u postgres createdb dnote_test
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
# allow connection from host and allow to connect without password
sudo sed -i "/port*/a listen_addresses = '*'" /etc/postgresql/14/main/postgresql.conf
sudo sed -i 's/host.*all.*.all.*md5/# &/' /etc/postgresql/14/main/pg_hba.conf
sudo sed -i "$ a host all all all trust" /etc/postgresql/14/main/pg_hba.conf
sudo service postgresql restart

View file

@ -1,26 +0,0 @@
#!/usr/bin/env bash
# shellcheck disable=SC1091
set -eux
VERSION=1.21
OS=linux
ARCH=amd64
tarball=go$VERSION.$OS-$ARCH.tar.gz
wget -q https://dl.google.com/go/"$tarball"
sudo tar -C /usr/local -xzf "$tarball"
sudo tar -xf "$tarball"
sudo mkdir -p /go/src
sudo mkdir -p /go/bin
sudo mkdir -p /go/pkg
sudo chown -R vagrant:vagrant /go
GOPATH=/go
echo "export GOPATH=$GOPATH" >> /home/vagrant/.bash_profile
echo "export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin" >> /home/vagrant/.bash_profile
source /home/vagrant/.bash_profile
go version
go env

View file

@ -1,19 +0,0 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC1091
set -eux
VERSION=12.16.2
NVM_VERSION=v0.35.0
# Install nvm
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/"$NVM_VERSION"/install.sh | bash
cat >> /home/vagrant/.bash_profile<< EOF
export NVM_DIR="\$([ -z "\${XDG_CONFIG_HOME-}" ] && printf %s "\${HOME}/.nvm" || printf %s "\${XDG_CONFIG_HOME}/nvm")"
[ -s "\$NVM_DIR/nvm.sh" ] && \. "\$NVM_DIR/nvm.sh" # This loads nvm
EOF
source /home/vagrant/.bash_profile
# Install a node and alias
nvm install --no-progress "$VERSION" 1>/dev/null
nvm alias default "$VERSION"
nvm use default

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
set -ex
sudo apt-get -y install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install -y postgresql-14

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -eux
sudo apt-get update
sudo apt-get install -y htop git wget build-essential inotify-tools
# Install Chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list
sudo apt-get -y update
sudo apt-get install -y google-chrome-stable
# Install dart-sass
dart_version=1.34.1
dart_tarball="dart-sass-$dart_version-linux-x64.tar.gz"
wget -q "https://github.com/sass/dart-sass/releases/download/$dart_version/$dart_tarball"
tar -xvzf "$dart_tarball" -C /tmp/
sudo install /tmp/dart-sass/sass /usr/bin