Skip to content

Commit

Permalink
Add notes about this version / repo
Browse files Browse the repository at this point in the history
  • Loading branch information
gavtroy committed Jan 18, 2025
1 parent 1c97547 commit 48d4c79
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 108 deletions.
85 changes: 31 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
[![Build Status][travis-badge]][travis]
[![Test and Build][github-workflow]][github-workflow]
[![Docker Cloud Build Status][docker-cloud-build-status]][docker-hub]
[![Docker Pulls][docker-pulls]][docker-hub]
[![Docker Image Size][docker-size]][docker-hub]

[travis-badge]: https://travis-ci.org/mkaczanowski/pastebin.svg?branch=master
[travis]: https://travis-ci.org/mkaczanowski/pastebin/
[docker-hub]: https://hub.docker.com/r/mkaczanowski/pastebin
[docker-cloud-build-status]: https://img.shields.io/docker/cloud/build/mkaczanowski/pastebin
[docker-pulls]: https://img.shields.io/docker/pulls/mkaczanowski/pastebin
[docker-size]: https://img.shields.io/docker/image-size/mkaczanowski/pastebin/latest
[github-workflow]: https://github.com/mkaczanowski/pastebin/workflows/Test%20and%20Build/badge.svg

# Pastebin
Simple, fast, standalone pastebin service.

## Notes on this repo / version

* Dependency bumps (incl. Rocket 0.5) and as a result the build is fixed
* Various UI changes
* Dark theme (and a softer Light theme)
* Pastes are directly opened after creation
* Expiry is shown more discreetly and in human friendly form
* Text wrapping
* Diff highlighting
* Line linking
* Passwordless encryption (or optionally with a password)
* Encryption reworked to use Web Crypto API and URI fragments
* Pastes are cookie protected and can only be removed by the creator
* & smaller changes

Database compatible with `mkaczanowski/pastebin`, but `chown -R 820:820` the database or remove USER from the Dockerfile if migrating. If reverting, note that you will not be able to decrypt pastes that were encrypted with this fork.

## Why?
Whenever you need to share a code snippet, diff, logs, or a secret with another human being, the Pastebin service is invaluable. However, using public services such as [pastebin.com](https://pastebin.com), [privnote.com](https://privnote.com), etc. should be avoided when you're sharing data that should be available only for a selected audience (i.e., your company, private network). Instead of trusting external providers, you could host your own Pastebin service and take ownership of all your data!

Expand Down Expand Up @@ -58,64 +61,38 @@ Currently supported:


## Usage
Build requires the `clang` compiler (rocksdb deps). To skip the build process, you can use the docker image.
Browsers will only allow the Encrypt feature if a secure connection is used. It is most convenient to manage TLS certs with a reverse proxy such as nginx, though --tls-certs and --tls-key options are also available.

### Cargo
The rocksdb dependency requires the `clang` compiler library (and a few minutes of compilation time).
```
cargo build --release
cargo run
```
### Docker
x86 image:
The repo must be cloned to build the Docker image. This fork is not published to Docker Hub.

Setup:
```
docker pull mkaczanowski/pastebin:latest
docker run --init --network host mkaczanowski/pastebin --address localhost --port 8000
mkdir -p /var/lib/pastebin.db && chown -R 820:820 /var/lib/pastebin.db
```

ARM images:
Compose:
```
docker pull mkaczanowski/pastebin:armv7
docker pull mkaczanowski/pastebin:armv8
URI=https://paste.example.com docker compose up
```

Compose setup:
Without compose:
```
URI="http://localhost" docker-compose up
curl -L "http://localhost"
docker build --pull -t local/pastebin .
docker run --init -p 127.0.0.1:8000:8000 -v /var/lib/pastebin.db:/pastebin.db local/pastebin --ui-line-numbers --address=0.0.0.0 --uri=https://paste.example.com
```
This example would make Pastebin available on port 8000 on the local machine. Nginx could then be used to proxy to port 80 externally while adding TLS and compression.

### Client
```
alias pastebin="curl -w '\n' -q -L --data-binary @- -o - http://localhost:8000/"
echo "hello World" | pastebin
http://localhost:8000/T9kGrI5aNkI4Z-PelmQ5U
```

## Nginx (optional)
The Pastebin service serves `/static` files from memory. To lower down the load on the service you might want to consider setting up nginx with caching and compression enabled, as shown here:
```
map $sent_http_content_type $expires {
default off;
text/css 30d;
application/javascript 30d;
image/x-icon 30d;
}
server {
listen 80;
server_name paste.domain.com;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
expires $expires;
location / {
proxy_pass http://localhost:8000;
include proxy-settings.conf;
}
access_log /var/log/nginx/access.log;
}
http://localhost:8000/T9kGrI5aN
```

## REST API
Expand Down
60 changes: 6 additions & 54 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,12 @@
version: "3.7"

services:
pastebin:
image: mkaczanowski/pastebin:latest
image: local/pastebin
build:
context: .
container_name: pastebin
volumes:
- $DOCKERDIR/pastebin:/var/lib/pastebin
restart: unless-stopped
command: --address 0.0.0.0 --port 8081 --uri ${URI} --db=/var/lib/pastebin/
ports:
- "8081:8081"
- "127.0.0.1:8000:8000"
volumes:
- ./db:/var/lib/pastebin/

nginx:
image: "nginx"
ports:
- "80:80"
links:
- pastebin:pastebin
command: |
bash -c "bash -s <<'EOF'
cat > /etc/nginx/nginx.conf <<'EON'
daemon off;
error_log /dev/stderr info;
events {
worker_connections 768;
}
http {
map $$sent_http_content_type $$expires {
default off;
text/css 30d;
application/javascript 30d;
image/x-icon 30d;
}
server {
listen 80;
server_name 0.0.0.0;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
expires $$expires;
location / {
proxy_pass http://pastebin:8081;
}
access_log /dev/stdout;
}
}
EON
set -eux
cat /etc/nginx/nginx.conf
nginx
EOF"
- /var/lib/pastebin.db:/pastebin.db
command: --ui-line-numbers --address 0.0.0.0 --uri ${URI}

0 comments on commit 48d4c79

Please sign in to comment.