Code Monkey home page Code Monkey logo

pilot-image-board's Introduction

Ephemeral Environments

This repository contains a demo for ephemeral environments.

Ephemeral environments are environments that are created on demand and destroyed when no longer needed. They are typically used for testing and development purposes. They accelerate the development process by providing a fast feedback loop. They also reduce the cost of devlopment environments by only running when needed.

Demo

This demo uses:

  • Terraform to provision the infrastructure on a Kubernetes cluster
  • Helm charts to deploy the application
  • ArgoCD to update the application when the code changes
  • GitHub Actions to orchestrate the workflow

It also integrates with:

Workflow

You can see an example of the workflow here and a demo of the ephemeral environment here.

The workflow is triggered when a pull request is opened. It runs the following steps:

  • Check the format of the code
  • Lint the code
  • Check if it builds
  • Send the code to SonarQube for analysis

Then it runs concurrently:

  • A deployment of the application with terraform
    • It creates a namespace
    • A PostgreSQL database
    • Creates the backend and frontend deployments
  • A build of the images

Theses two run concurrently because they can both take a long time to run. Even though the build is needed for the deployment, it is not a blocker. Kubernetes will keep trying to pull the image until it is available.

When the build is done, it pushes the images to the GitHub Container Registry.

Finally, it sends a message to the pull request with the URL of the ephemeral environment.

Finally, when the pull request is closed, it destroys the ephemeral environment.

Stuff to consider

  • The workflow does not run the terraform files from the main branch, but from the pull request branch. This means that if your repository is not private and you don't configure who can run the workflow, anyone can run the workflow and create an ephemeral environment. This can be a security issue.
  • You need to use concurrency groups to run the deployment and the build concurrently. Terraform does not support concurrency natively. If you don't use concurrency groups, you might run into conflicts and race conditions.

The actual application

Note: The application is not the focus of this demo. It is only used to demonstrate the ephemeral environments. As it is an old application I made to learn React and NestJS, it is not a good example of how to write a React or NestJS application.

This demo runs a simple image board application. It allows users to upload images or text in threads. It is composed of:

pilot-image-board's People

Contributors

mmoreiradj avatar

Watchers

 avatar

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.