GithubHelp home page GithubHelp logo

thumbor-container's Introduction

thumbor-container

thumbor in a Docker container.

Inspired by the web.dev blog post How to install the Thumbor image CDN by Katie Hempenius, this details both the process to put thumbor in a container (even though there are better containers out there, such as minimalcompact/thumbor) and how to use Google Cloud Platform to build and host thumbor.

tl;dr: Run on Google Cloud

container usage

Use the container directly as published at ghchinoy/thumbor or build and deploy it as per below.

docker run -d -p 8080:8080 -e ALLOW_UNSAFE_URL=True ghchinoy/thumbor

If you want to use the HMAC security, supply your own SECRET_KEY environment variable, sort of like this (and remember it, since you'll have to use that to encode your URLs):

SECURITY_KEY=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13)
docker run -d -p 8080:8080 -e SECURITY_KEY=${SECURITY_KEY} ghchinoy/thumbor

building

Use the included Dockerfile to build the container in the standard manner:

docker build -t thumbor .

Or, use the Google Cloud Platform Cloud Build service to build the container for you. The first 120 build-minutes per day are free, even though you have to enable billing for your GCP account. See also the container registry pricing for storage of and security scanning of containers.

Use the included cloudbuild.yaml which uses an environment variable to specify your project, i.e. do something like this first: export PROJECT_ID=thumbor-container (substituting your own project name, of course).

View build logs at your project name, ex. thubmor-container

# prerequisites
export PROJECT_ID=thumbor-container
# create a gcp project
gcloud projects create $PROJECT_ID
# enable billing, find via `gcloud alpha billing account list`
gcloud alpha billing projects link $PROJECT_ID --billing-account YOUR-ACCT-NUMB
# enable cloud build service
gcloud services enable cloudbuild.googleapis.com

# build step
gcloud builds submit --config cloudbuild.yaml .

deploy

One can run the container from Docker hub registry, as above, or use Cloud Run to serve up the container!

Choose a region and allow unauthenticated access, when asked.

# enable the API
gcloud services enable run.googleapis.com

# deploy to cloud run
gcloud beta run deploy --image gcr.io/$PROJECT_ID/thumbor --platform managed --set-env-vars=ALLOW_UNSAFE_URL=True

After this is deployed, you'll see something like the following.

Deploying container to Cloud Run service [thumbor] in project [thumbor-container] region [us-central1]
✓ Deploying... Done.                                                                                   
  ✓ Creating Revision...                                                                               
  ✓ Routing traffic...                                                                                 
Done.                                                                                                  
Service [thumbor] revision [thumbor-xh4h4] has been deployed and is serving 100 percent of traffic at https://thumbor-3u7t5nnjpq-uc.a.run.app

Test with URLs in the blog posts Optimize images with Thumbor or How to install the Thumbor image CDN.

thumbor-container's People

Contributors

ghchinoy avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

dindinet

thumbor-container's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.