A Go-based command line tool for publishing and serving static files

DevOps engineers frequently need to setup quick solutions to serve static files, for example to publish test artifacts or to make static pages (like internal software documentation) available as part of a continuous integration process. In such scenarios, setting up a full-fledged web server and a comprehensive deployment pipeline feels like using a sledgehammer to crack a nut. That’s why our very own engineer Stephano developed Pimba, a tool that allows you to serve and publish static files with nothing more than a few key strokes on the command line.

Getting started with Pimba

To get started with Pimba, first install the tool with go get:

$ go get github.com/signavio/pimba

Alternatively, you can download a binary release here.

Then, run $ pimba api --storage /path/to/data/storage --secret <my-jwt-secret> --port <port-number> to run a Pimba server that publishes all files that are available at a provided path, for example:

$ pimba api --storage . --secret supersecret --port 4004

Pimba requires a secret to securely transfer the bucket and push data using JSON Web Tokens (JWT). The argument --port is optional. When you add or edit files at the provided path, Pimba automatically makes the changes available.

That’s all you need to do to serve files with Pimba! But you can also publish additional files to a specific resource (bucket) of the Pimba server. To do so, navigate to the directory you want to publish and run $ pimba push --server pimba.server.host:port --name my-bucket-name.

This example makes the content of the current folder available at http://localhost:8080/test:

$ pimba push --server localhost:8080 --name test

In contrast to the basic Pimba setup, you need to explicitly update files you’ve pushed to a specific resource. For this, you need the JWT token Pimba returns after the initial push. To update a bucket, run $ pimba push --server pimba.server.host:port --name my-bucket-name --token returned-token, for example:

$ pimba push --server localhost:8080 --name my-bucket-name --token cM3dLMgjbO eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJidWNrZXQiOiJjTTNkTE1namJPIiwidGltZXN0YW1wIjoxNTA3OTA0MDY2fQ.zpSUeqH3JSI-Zq1_ljBLspNJjxwxg9dxsQLumUFR1n0

Note: Instead of specifying all arguments on the command line, you can store them in a configuration file.

And that’s all you need to know to use Pimba! For more details checkout the README or run $ pimba api --help, respectively $ pimba push --help.

Do you have ideas for improving Pimba? Open an issue or checkout the code and open a pull request!

Alternatives

Surge is a service that provides Pimba-like functionality in the cloud. It’s the way to go if you neither have nor need the infrastructure for hosting static files yourself. In contrast, Pimba comes into play for situations where using cloud services is either not allowed or does not make sense, for example if it’s more convenient to host files on a service within your organization’s internal network.

Mr Cup / Fabien Barral