Draftsmith can be installed and configured entirely through Docker, this will include the API, database and Web App:
git clone https://github.com/RyanGreenup/draftsmith_rs
cd draftsmith_rs/containers/main
docker compose up
This will build a container with some dependencies and:
- a clone of:
- Compiled version of
- CLI for draftsmith_rs_api
- Virtual Environment for draftsmith_flask
The docker-compose.yml
will create 3 services:
postgres
- The database storing all the data
app
- This is the Rest API that communicates with the database
scripts/entrypoint.sh
will check for a marker file and if it’s not found:- 1. Create a database
- 2. Initialize that dabase with tables etc. (using diesel migrations)
web-app
- The web application communicating with the REST API
scripts/web_entrypoint.sh
will source the virtual environmnent (created in the image) and run the web app
- The web application communicating with the REST API
Users can jump inside the container to interact directly with the REST API or database if they wish:
docker compose exec -it app /bin/sh
# Or
docker compose exec -it app /bin/fish
docker compose exec -it app /usr/sbin/nu
Or call the client without forwarding the REST API to the system:
# change this according to the docker-compose
API_PORT=37242
docker compose exec -it app draftsmith client --url 'http://localhost:'$API_PORT notes tree | jq
These steps are all handled by docker through scripts/init-db.sh
and scripts/entrypoint.sh
(which uses a marker ./data/.initialized
).
This approach can be good for development.
Users will need a postgres database accessible (A docker-compose.yml
is included in this repo), the port and host can be set as arguments to the cli.
# Create a Database
PGPASSWORD=postgres createdb --host=postgres-db --port=5432 --username=postgres draftsmith2 || true
# Clone the repositories (This is handled in Dockerfile)
git clone --recurse-submodules https://github.com/RyanGreenup/draftsmith_rs $HOME/draftsmith_rs
# Run Diesel migrations
cd $HOME/draftsmith_rs/draftsmith_rs_api
diesel migration run --migration-dir migrations --database-url "$DATABASE_URL"
# There is a =.env= in draftsmith_rs_api with the correct details
# Build the project (The binary is is $HOME/draftsmith_rs/target/cli)
cargo build --release
# Install the project
cargo install --path .
# Spin up the db
docker compose up postgres-db -d
# Build the container
docker compose up app
# From now on the following will work
docker compose up -d
# Rename binary for local installations
mv ~/.cargo/bin/cli ~/.cargo/bin/draftsmith
# Serve
draftsmith -a '0.0.0.0:37240'
# Curl
curl http://localhost:37240/notes/flat | jq
# Rust Client / CLI
draftsmith client notes flat list | jq
git clone
poetry install deps
poetry run gunicorn -w 4 -b 0.0.0.0:5000 server:app
**