Random Mandalorian GIFs generator using Doppler for managing app configuration and secrets via environment variables.
Doppler's secure and scalable Universal Secrets Manager seeks to make developers lives easier by removing the need for env files, hardcoded secrets, and copy-pasted credentials.
The Doppler CLI provides easy access to secrets in every environment from local development to production and a single dashboard makes it easy for teams to centrally manage app configuration for any application, platform, and cloud provider.
Learn more at our product website or docs.
- Python 3.9 or above
- Git
- Make
- Doppler CLI (used to manage environment variables)
- Create a GIPHY app in order to generate an API (not SDK) key (see instructions)
The instructions following are for macOS but can easily be adapted for Linux and Windows environments.
NOTE: If using Windows, use the Python venv docs to create and activate your virtual environment in the Terminal or PowerShell.
Setting up for local development is mostly-automated through commands in the Makefile
, but these can be run manually if make
is not installed.
- Install the latest version of Python 3:
brew install python
- Clone the Mandalorian GIFs repo:
git clone https://github.com/DopplerUniversity/mandalorian-gifs-python
- Create the virtual environment (which includes installing dev dependencies):
make create-virtual-env
- Activate virtual environment:
eval $(make activate)
# See https://docs.doppler.com/docs/enclave-installation for other operating systems and environments, e.g. Docker
brew install dopplerhq/cli/doppler
- Login and create your free Doppler account on the Community plan:
doppler login
- Create the Doppler project providing the GIPHY API KEY:
make create-doppler-project GIPHY_API_KEY=YOUR_KEY_HERE
Once you've created the Doppler project, you can run the app locally:
make dev
To debug in Visual Studio code, simply run the python: server
launch configuration.
To debug in a Dev Container, you'll need to open the project using the code
binary from an external terminal window in order to set the environment variables required by the container.
To do this:
- Close this project in Visual Studio Code
- Open a new terminal
- Change into the
mandalorian-gifs
directory - Launch Visual Studio Code from the terminal and setting the required Doppler environment variables:
DOPPLER_TOKEN=$(doppler configure get token --plain) \
DOPPLER_PROJECT=$(doppler configure get project --plain) \
DOPPLER_CONFIG=$(doppler configure get config --plain) \
code .
Now re-open the project as a dev container by running the command: Remote-Containers: Rebuild and Reopen in Container
.
The once the dev container has been built and is ready, run the python: dev container
launch configuration.
Deploying to Heroku is done in three steps:
- Populate Doppler production config
- Deploy to Heroku using the Heroku CLI
- Enable the Doppler Heroku integration for the production config
To prepare for deploying to Heroku, we need to populate the production (prd) Doppler environment for our project.
We do this by re-using the secrets from the dev environment, then updating for production usage:
make setup-doppler-production
To deploy the application to Heroku:
- Install the Heroku CLI, then login using the
heroku login
command - Edit the Makefile, changing
HEROKU_TEAM
to your team or account name and changingHEROKU_APP
to be unique, e.gmandalorian-gifs-ryan
- Create and deploy the app to Heroku:
make heroku-create
The application will deploy but won't work yet as it does not have any environment variables (Heroku Config Vars) set, but we'll fix that next with Doppler's Heroku integration.
The Doppler Heroku integration enables you to automatically sync any secret changes for a config to a Heroku application.
To set up the Heroku integration:
- Access the mandalorian-gifs project from the Doppler dashboard, then click on Integrations from the projects menu on the left
- Click on Heroku, and authorize the Doppler application
- Doppler will then ask you to select the Heroku application and config to sync. Select
mandalorian-gifs
application and prd configuration
Once the integration is set up, go to the Heroku Dashboard, view the settings for your application and click on Reveal Config Vars to see the secrets Doppler has synced across.
Your Heroku app is now ready for testing.