Get an isolated preview database for every Netlify Preview Deployment

Overview

Netlify Preview Database Plugin

Create an isolated preview database for each preview deployment in Netlify

you branch?

Quickstart   •   Website   •   Docs   •   Discord   •   Twitter

This plugin gives you a new and isolated database for your preview deployments in Netlify. When a pull-request is created, a new database is created and seeded with a Snaplet snapshot. Giving you a database (with data) to test your branch without side-effects.

Usage

1. Install the plugin

2. Configure settings in your project repo

# netlify.toml

[[plugins]]
 package = "@snaplet/netlify-preview-database-plugin"

  [plugins.inputs]
    databaseEnvVar = "DATABASE_URL"
    databaseCreateCommand = "snaplet db create --git --latest"
    databaseUrlCommand = "snaplet db url --git"
    reset = false

Note: We check the deploy context associated with the build. You can configure your settings by deploy context.

Inputs (All inputs are optional)

- name: databaseEnvVar
  description: Database environment variable name

- name: databaseCreateCommand
  description: Command used to generate the instant database

- name: databaseUrlCommand
  description: Command used to get the instant database url

- name: reset
  description: Reset the database state on each commit

3. Set environment variables

  • In the Dashboard. Navigate to your site then Site settings > Environment Variables. Select Specific scopes and pick the Build option.
  • Using build environments, you can define them in your project.
# netlify.toml

[[plugins]]
# ...
	
  [context.deploy-preview.environment]
  SNAPLET_ACCESS_TOKEN="<YOUR_SNAPLET_ACCESS_TOKEN>"

Required Environment variables

NETLIFY_ACCESS_TOKEN=// API Access token found in Netlify user settings.
NETLIFY_ACCOUNT_ID=// Account ID found in team settings
SNAPLET_ACCESS_TOKEN=// CLI Access token found in Snaplet UI
SNAPLET_PROJECT_ID=// Project ID found in Snaplet project settings.

How it works

How it works

Netlify + Snaplet Preview Database + Snaplet Snapshots = Love.

Combining preview databases with Snaplet snapshots and Netlify preview deployments gives your team a consistent experience to evaluate your deployment's Environment Variables.

Each commit triggers a build in Netlify. Before the build starts, the plugin will create an instant database using your latest snapshot. Once the create command is done, we will inject the URL returned, into the environment variable, linked to your database (By default this variable is DATABASE_URL).

Once the pre-build step is executed successfully, your build will continue and a site will be deployed with the preview database.

Additional resources

https://docs.netlify.com/integrations/build-plugins/#manage-plugin-versions

You might also like...

This is a demo of updating a map to show air quality data for the user’s current location using Next.js Advanced Middleware, powered by Netlify Edge Functions.

Show Local Air Quality Based on the User's Location Use AQI data to show the air quality near the current user. This is built using Next.js Advanced M

Nov 4, 2022

🤖 Persist the Playwright executable between Netlify builds

🤖 Persist the Playwright executable between Netlify builds

🤖 Netlify Plugin Playwright Cache Persist the Playwright executables between Netlify builds. Why netlify-plugin-playwright-cache When you install pla

Oct 24, 2022

Get a desktop notification every time a new correction slot is available for your 42 project.

42_slot_watcher A simple node.js corrections slots watcher for 42, working on Windows - MacOS - Linux. What is this I was bored of having to refresh t

Dec 20, 2022

A simple Node.js code to get unlimited instagram public pictures by every user without api, without credentials.

A simple Node.js code to get unlimited instagram public pictures by every user without api, without credentials.

Instagram Without APIs Instagram Scraping in August 2022, no credentials required This is a Node.js library, are you looking for the same in PHP? go t

Dec 29, 2022

Use pulsar to make custom trading strategy that uses Flashloans at low cost. No contract deployment required.

PULSAR Pulsar is a contract that will let you execute custom call on the blockchain and let you make use of the Flasloans in your trading sequences. Y

Jun 6, 2022

Continuous Deployment Pipelines (CI/CD) with Dozer

Continuous deployment pipelines are sets of scripts and tools helping you get your project from your workstation, or version control system, to somewhere your target audience can reach it.

Jan 2, 2023

🌬 Opiniated Nuxt 3 Starter — visual deployment indicator & more

Nuxt 3 Minimal Starter I recommend to look at the documentation. Key Features 🍍 State management with Pinia 📐 Prettier & ESLint 🔢 Pre-configured VS

Dec 7, 2022

Inferrd makes Machine Learning deployment easy and scalable.

Inferrd makes Machine Learning deployment easy and scalable.

Introduction ML Deployment made simple, scalable and collaborative The new open-source standard to deploy, monitor and secure Machine Learning service

Dec 16, 2022

ECS Blue/Green Deployment with AWS CodePipeline

 ECS Blue/Green Deployment with AWS CodePipeline

ECS Blue/Green Deployment with AWS CodePipeline This repository contains a set of configuration to setup a CI/CD pipeline for an AWS ECS Cluster. All

Sep 20, 2022
Comments
  • improvements: fetch accountId instead of asking the user for the value

    improvements: fetch accountId instead of asking the user for the value

    In this PR:

    • Code split into named functions and different files
    • No more bash scripts
    • accountId is not fetched from the API instead of asking the user for the value
    • We were setting the environment variable even when it's not necessary, now we set it only when it's not already set in Netlify
    • Improved the manifest, we can set the default value and the input requirement in there
    opened by jgoux 1
  • feat!: clean up resources

    feat!: clean up resources

    In this PR:

    • README update with corrections for instant -> preview databases
    • Implementation of resources cleanup by using GitHub API to find the original branch of a commit merged on main in the production context
    • Light type-checking using JSDoc

    It will be v2.0.0 as we're breaking the inputs API.

    opened by jgoux 0
  • doc: update readme & codebase

    doc: update readme & codebase

    • Change every mention of "instant" to "preview" when referring to preview databases. Apply this change in the project readme and codabase.
    • Update diagram to mention "preview" instead of "instant"
    opened by khaya-zulu 0
  • Gitlab integration

    Gitlab integration

    If we ever want to integrate with Gitlab, there is this endpoint to get linked merge requests for resources clean up: https://docs.gitlab.com/ee/api/commits.html#list-merge-requests-associated-with-a-commit

    opened by jgoux 0
Releases(v2.0.0)
  • v2.0.0(Oct 6, 2022)

    What's Changed

    • feat!: clean up resources by @jgoux in https://github.com/snaplet/netlify-preview-database-plugin/pull/5

    Full Changelog: https://github.com/snaplet/netlify-preview-database-plugin/compare/v1.1.0...v2.0.0

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Oct 5, 2022)

    What's Changed

    • doc: update readme & codebase by @khaya-zulu in https://github.com/snaplet/netlify-preview-database-plugin/pull/1
    • improvements: fetch accountId instead of asking the user for the value by @jgoux in https://github.com/snaplet/netlify-preview-database-plugin/pull/3

    New Contributors

    • @khaya-zulu made their first contribution in https://github.com/snaplet/netlify-preview-database-plugin/pull/1
    • @jgoux made their first contribution in https://github.com/snaplet/netlify-preview-database-plugin/pull/3

    Full Changelog: https://github.com/snaplet/netlify-preview-database-plugin/commits/v1.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
Snaplet
Snaplet
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Codebraid Preview provides a Markdown preview for Pandoc documents within VS Code.

Codebraid Preview provides a Markdown preview for Pandoc documents within VS Code. Most Markdown previews don't support all of Pandoc's extensions to Markdown syntax. Codebraid Preview supports 100% of Pandoc features—because the preview is generated by Pandoc itself! There is also full bidirectional scroll sync and document export.

Geoffrey Poore 12 Dec 28, 2022
A build plugin to integrate Gatsby seamlessly with Netlify

Essential Gatsby Plugin This build plugin is a utility for supporting Gatsby on Netlify. To support build caching and Gatsby functions on Netlify, you

Netlify 72 Dec 27, 2022
Netlify functions session cookie 🍪

netlify-functions-session-cookie ?? Cryptographically-signed session cookies for Netlify functions. Summary Install Concept and Usage API Environment

Matteo Cargnelutti 7 Jun 8, 2022
testing out ember + netlify's forms

survey-netlify I'm trying Ember + Netlify Forms. Will it work? Let's find out. Steps so far added prember and ember-cli-fastboot used the version of f

Melanie Sumner 3 Feb 14, 2022
A demo to show how to re-use Eleventy Image’s disk cache across Netlify builds.

Re-use Eleventy Image Disk Cache across Netlify Builds Live Demo This repository takes all of the high resolution browser logos and processes them thr

Eleventy 9 Apr 5, 2022
Easiest way to build documentation for your project. No config or build required, hosted on @netlify.

Hyperdocs is the simplest way you can create documentation for your project. It blends the best of all the other documentation tools in one. Hyperdocs

Lalit 76 Dec 22, 2022
A peculiar little website that uses Eleventy + Netlify + Puppeteer to create generative poster designs

Garden — Generative Jamstack Posters "Garden" is an experiment in building creative, joyful online experiences using core web technologies. ?? Buildin

George Francis 13 Jun 13, 2022
A minimal e-commerce store using Gatsby, SANITY, Stripe, Use-Shopping-Cart and Netlify

?? Gatsby Starter Stripemart Like a supermarket but for Stripe. No ongoing monthly costs. Perfect for artists, creators and independent builders doing

Eric Howey 26 Nov 14, 2022