- Notifications
You must be signed in to change notification settings - Fork24
highly opinionated, minimal pastebin
License
wantguns/bin
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A minimal pastebin which also accepts binary files like Images, PDFs and shipsmultiple clients.
It does not require you to host a SQL server and everything is self-contained ina statically linked binary (the docker image runs on scratch !), which makes itextremely easy to deploy.
Try it out on:https://basedbin.fly.dev
You can paste
Get the client fromthis repository or from my deployed paste:
curl -o pst https://bin.wantguns.dev/clientchmod +x pst
or manually copy the following at a file in your path.
#!/bin/bash# Change the url accordinglyURL="https://basedbin.fly.dev"FILEPATH="$1"FILENAME=$(basename --"$FILEPATH")EXTENSION="${FILENAME##*.}"RESPONSE=$(curl --data-binary @${FILEPATH:-/dev/stdin} --url$URL)PASTELINK="$URL$RESPONSE"[-z"$EXTENSION" ]&& \echo"$PASTELINK"|| \echo"$PASTELINK.$EXTENSION"
You have the option to remove the/client
description / help in thelanding page. To show the/client
description, run thebin
binarywith eitherBIN_CLIENT_DESC
env variable or a-c
flag. More onarguments later
It just works.
$ pst somefile.txt$ cat someimage.png| pst
- Install the CLI client
- Append this to your init.vim / vimrc
nnoremap<leader>p :!pst %<CR>
Use<leader> + p
paste.
Currently, builds for the following target triples are shipped:
- x86_64-unknown-linux-gnu (amd64)
- aarch64-unknown-linux-gnu (arm64)
The builds shipped are statically linked, so you don't even need a libc to runthe binary !
The docker manifest labelledwantguns/bin:latest
includes the images for both amd64 and arm64 images.
$ docker run -p 6162:6162 wantguns/bin
version:'3.3'services:pastebin:image:wantguns/bincontainer_name:pastebinports: -127.0.0.1:6163:6163environment: -BIN_PORT=6163# Defaults to 6162 -BIN_LIMITS={form="16 MiB"} -BIN_CLIENT_DESC=placeholdervolumes: -./upload:/upload# upload folder will have your pastes
- Grab a copy of the binary from GH releases
OR - Build on your own:
# A statically linked build$ cargo build --release
- Execute the binary as is, no extra shenanigans needed:
$ ./bin
USAGE: bin [OPTIONS]OPTIONS: -a, --address <ADDRESS> Address on which the webserver runs [default: 127.0.0.1] -b, --binary-upload-limit <BINARY_UPLOAD_LIMIT> Binary uploads file size limit (in MiB) [default: 100] -c, --client-desc Include client description [env: CLIENT_DESC=] -h, --help Print help information -p, --port <PORT> Port on which the webserver runs [default: 6162] -u, --upload <UPLOAD> Path to the uploads folder [default: ./upload] -V, --version Print version information
This pastebin utilizes a custom configuration provider from Rocket. Apart fromthe essential arguments, you can also use environment variables, which have thehighest preference in order.
Everything from theofficial Rocketdoc is supported,just that you have to prefix the env variable with "BIN_":
BIN_PORT=6163BIN_ADDRESS=0.0.0.0BIN_LIMITS={form="16 MiB"}BIN_WORKERS=8BIN_IDENT=false...
GET /<id>
Get raw pastes
GET /p/<id>
Get highlighted pastes
GET /p/<id>.<ext>
Get syntax highlighted pastes.
E.g.https://basedbin.fly.dev/p/foobaz.cpp should return a C++ syntaxhighlighted paste
POST /
Post binary data
This pastebin:
- does not use a database. It lacks non-essential features likepassword-protection / automatic deletion as a result of which, it can docompletely fine with flat filesystems. As an upside (opinionated), it makesdeploying it easier.
- uses server sided highlighting, which ensures that everything stays light andsnappy at the client side.
- uses very minimal frontend because a pastebin does not need it. It focuses(or atleast tries to) on getting things done in minimum amount of clicks.
If you want to ensure your pushed refs will pass CI, add the prepush scriptto your Git hooks:
$ cp -a tools/prepush .git/hooks/pre-push
Alternately, just run
./tools/prepush
yourself before pushing.The Cargo configuration for this project is set for statically compiledbuilds. You can check out theconfig file to know more.
Read thebuildci to know how the project isstatically compiled for two architectures.
About
highly opinionated, minimal pastebin