How to deploy PrivateBin on Google Cloud Run and Google Cloud Storage

12 Sep, 2021
Xebia Background Header Wave

This blog shows you how to deploy PrivateBin on Google Cloud Run and Google Cloud Storage, to achieve a cheap and high available deployment for low intensity usage.

PrivateBin is a classic PHP web application which you install on a virtual machine and write data to the local file-system or a database.

If you want a cheap and reliable deployment for low intensity usage, it will be hard. Writing to the local file-system will make it very hard to achieve high availability, writing to a database will increase the cost significantly.

That is why I wrote a Google Cloud Storage plugin for PrivateBin. It provides multi-regional availability of the stored data against very low cost. Furthermore, it allows me to deploy the application using Google Cloud Run. The combination of these two services mean that you only pay when using the service and storing data. Truly serverless.

Deploy PrivateBin

To deploy PrivateBin in a serverless fashion, you can use the terraform module terraform-google-privatebin. The module will create the following resources:

  • a cloud run service named privatebin
    runs the application on-demand.
  • storage bucket named privatebin-<google project name>
    where the data is stored.
  • service account named privatebin
    used by the service to access the bucket.
  • a secret named privatebin-configuration
    contains the PrivateBin configuration which is loaded as a file into the container.

To deploy privatebin in your Google project, add the following snippet to your Terraform template:

module "privatebin" {
  source  = "git::https:/"
  image   = ""

  providers = {
    google      = google
    google-beta = google-beta

The application deploys in the project and region specified by your providers. After Terraform apply, the output will print the URL of your privatebin installation.

build your own image

Google Cloud Storage support is not yet release, but is available on the master branch of PrivateBin. The module currently uses my image To build your own image, type:

git clone
cd docker-nginx-fpm-alpine
docker build --build-arg RELEASE=master --tag $YOUR_IMAGE --output type=registry,push=true .

Now set the variable image to $YOUR_IMAGE in the Terraform template, and you are good to go.


PrivateBin is not serverless application by design: it prefers you install it on a virtual machine and store data on the local file-system or in a database. Due to the storage plugin architecture of PrivateBin, it was pretty easy to add Google Cloud Storage Support to PrivateBin and deploy PrivateBin on Google Cloud Run to make a serverless deployment.

Special thanks to the maintainers elrido and rugk for their patience for their support and integration of the changes in PrivateBin.

Photo by Michael Dziedzic on Unsplash

Mark van Holsteijn
Mark van Holsteijn is a senior software systems architect at Xebia Cloud-native solutions. He is passionate about removing waste in the software delivery process and keeping things clear and simple.

Get in touch with us to learn more about the subject and related solutions

Explore related posts