├── .gitignore ├── TODO.md ├── ghostbin.sh ├── Makefile ├── Dockerfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | data/ 2 | logs/ 3 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | - [X] Remove persona javascript and references to navigator.id 2 | - [X] navigator.id = {logout: function(){}, watch: function(){}} 3 | - [X] Check expiry 4 | - [X] Check encryption 5 | -------------------------------------------------------------------------------- /ghostbin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ ! -f /data/expiry.gob ]; then 3 | touch /data/expiry.gob 4 | chown -R ghostbin:ghostbin /data 5 | fi 6 | sudo -E -u ghostbin /ghostbin/go/src/github.com/DHowett/ghostbin/ghostbin -addr="0.0.0.0:8619" -log_dir="/logs" -root="/data" 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | docker build -t dexafree/ghostbin . 5 | 6 | run_attach: 7 | docker run --rm -it --entrypoint="/bin/sh" -p 8619:8619 -v $(shell pwd)/logs:/logs -v $(shell pwd)/data:/data dexafree/ghostbin 8 | 9 | run: 10 | docker run --rm -it -p 8619:8619 -v $(shell pwd)/logs:/logs -v $(shell pwd)/data:/data dexafree/ghostbin 11 | 12 | clean_logs: 13 | rm -rf $(shell pwd)/logs/* 14 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.8.3-alpine3.6 2 | 3 | RUN apk add --update \ 4 | git \ 5 | py-pygments \ 6 | sudo \ 7 | nodejs nodejs-npm && npm install npm@latest -g \ 8 | && rm -rf /var/cache/apk/* \ 9 | && adduser -h /ghostbin -u 10000 -D -g "" ghostbin 10 | USER ghostbin 11 | ENV GOPATH=/ghostbin/go 12 | RUN mkdir -p /ghostbin/go/src/github.com/DHowett \ 13 | && git clone https://github.com/DHowett/ghostbin.git /ghostbin/go/src/github.com/DHowett/ghostbin \ 14 | && cd /ghostbin/go/src/github.com/DHowett/ghostbin \ 15 | && git checkout -b v1-stable c392751c67afa1c1f0c6771ab6a99da2ef5c5c41 \ 16 | # Change pygmentize path 17 | && sed -i -e 's:./bin/pygments/pygmentize:/usr/bin/pygmentize:g' languages.yml \ 18 | && echo "Go get" \ 19 | && go get \ 20 | && echo "Go install" \ 21 | && go install \ 22 | && echo "Go build" \ 23 | && go build \ 24 | && npm install 25 | WORKDIR /ghostbin/go/src/github.com/DHowett/ghostbin 26 | USER root 27 | RUN mkdir /logs \ 28 | && chown -R ghostbin:ghostbin /logs \ 29 | && mkdir /data \ 30 | && chown -R ghostbin:ghostbin /data 31 | 32 | EXPOSE 8619 33 | 34 | VOLUME /logs 35 | VOLUME /data 36 | 37 | COPY ghostbin.sh /ghostbin/ghostbin.sh 38 | # Ensure it's executable 39 | RUN chmod +x /ghostbin/ghostbin.sh 40 | ENTRYPOINT /ghostbin/ghostbin.sh 41 | # CMD -addr="0.0.0.0:8619" -log_dir="/logs" -root="/data" 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dexafree/ghostbin Dockerfile [![Docker Build Status](https://img.shields.io/docker/build/dexafree/ghostbin.svg)](https://hub.docker.com/r/dexafree/ghostbin/) 2 | 3 | This is a repository I've created in order to have a Docker image for running [Ghostbin](https://ghostbin.com) in a private server. 4 | 5 | It allows you to run it in your own computer, internally in your company, or host it in a public server. 6 | 7 | The [Ghostbin project](https://github.com/DHowett/spectre) is also Open Source, but due to its hard setup, I thought that creating a Dockerfile and a Docker image would be helpful for people like me who want to host it on their own hardware. 8 | 9 | ## Base image 10 | 11 | The base image used for this Dockerfile is `golang:1.8.3-alpine3.6`: 12 | 13 | * Golang as Ghostbin is written in Go, an thus is needed to compile it. 14 | * Alpine as it provides a smaller base image, and therefore the resulting image will also be smaller. 15 | 16 | ## Limitations 17 | 18 | In order for expiration, encryption and syntax highlighting to work, you need to be using Docker in a Linux system. 19 | 20 | This is due to a difference in the internal Filesystem Docker for Linux uses: The FS driver used on Docker for macOS and Docker for Windows does not support the use of `xattrs` (extended attributes: saving metadata for a file in the filesystem), and Ghostbin relies on those attributes for saving the paste properties, such as the language, the encryption password and the expiration (if any of those is set). 21 | 22 | So, you will need to run it on a host using Docker for Linux in order for them to work. 23 | 24 | ## Notes 25 | 26 | As the [master branch of the Ghostbin project](https://github.com/DHowett/spectre/commit/90de2d7c989a603cf494eae3d31ec88420ebe750) (link to the latest master commit at the time of writing this readme) is not stable right now (it has mixed namespaces and is in the middle of a refactor), this Dockerfile uses the latest commit in the `v1-stable` branch, so it will probably not be running the exact same Ghostbin version the production server is running. 27 | 28 | I spoke to the author and he told me he is working in making it stable, so in the future this image should adapt to the latest version. 29 | 30 | ## Usage 31 | 32 | In order to run the image, you need to know three things: 33 | 34 | 1. Ports: This image exposes the 8619 port for serving the Ghostbin site. 35 | 2. Logs volume: This image exposes a `logs` volume, so you are able to read the logs that Ghostbin outputs. The path inside the container will be `/logs` 36 | 3. Data volume: This image exposes a `data` volume, so you are able to access and persist things like pastes, session keys and accounts through containers (and survive restarts). 37 | 38 | So, a way to run this container exposing all 3 things would be: 39 | 40 | ``` 41 | docker run -it -d --name="ghostbin" -p 8619:8619 -v /var/log/ghostbin:/logs -v /var/data/ghostbin:/data dexafree/ghostbin 42 | ``` 43 | 44 | It would expose the 8619 port of the host machine, mount the `logs` volume at the local path `/var/log/ghostbin` and mount the `data` volume at the local path `/var/data/ghostbin`. You can adapt it to any use you need. 45 | --------------------------------------------------------------------------------