Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Latest commit

 

History

History

ruby

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Ruby application in Docker

This Ruby example checks if the environment variables DEMO_USERNAME and DEMO_PASSWORD have been set. If that's the case, you'll receive a 200 on http://localhost:8080 and if it's not, you'll get a 500.

Prerequisites

  1. Docker installed and running
  2. SecretHub installed
  3. A SecretHub repo that contains a username and password secret. To create it, run secrethub demo init.

Running the example

Set the SecretHub username in an environment variable

export SECRETHUB_USERNAME=<your-username>

Create a service account for the demo repo

secrethub service init --description demo_service \
--permission read --file demo_service.cred ${SECRETHUB_USERNAME}/demo

Build the ruby docker demo

docker build . -t ruby-secrethub-demo

Run the docker demo with the secrets in the environment variables

docker run -ti -p 8080:4567 \
  -e DEMO_USERNAME=secrethub://${SECRETHUB_USERNAME}/demo/username \
  -e DEMO_PASSWORD=secrethub://${SECRETHUB_USERNAME}/demo/password \
  -e SECRETHUB_CREDENTIAL=$(cat demo_service.cred) \
  ruby-secrethub-demo

If you now visit http://localhost:8080, you should see the welcome message including your username.