Git Product home page Git Product logo

devops-example-25981's Introduction

devops_example_25981

This repo contains terraform files to deploy django app using github actions.

.
├── .github
│   └── workflows
│       ├── build-v1.yml
│       ├── build.yml
├── .terraform.lock.hcl
├── README.md
├── main.tf
└── src
    └── app
        ├── .dockerignore
        ├── .env
        ├── .env.example
        ├── .pytest_cache
        ├── Dockerfile
        ├── Pipfile
        ├── Pipfile.lock
        ├── README.md
        ├── devops_example_25981
        ├── docker-compose.override.yml
        ├── docker-compose.yml
        ├── heroku.yml
        ├── home
        ├── manage.py
        ├── modules
        ├── postgres-data
        ├── static
        ├── staticfiles
        └── users

Setup

Following are instructions on setting up your environment.

Prerequsites

Steps

  1. Generate Heroku Authorization and Terraform backend store
heroku authorizations:create --description terraform-my-app
APP_NAME=<Define app name>
heroku addons:create heroku-postgresql:hobby-dev --app $APP_NAME
  1. Setup Github Secrets for Heroku:

    • DATABASE_URL - This is needed to store terraform remote file state.
    • HEROKU_API_KEY - Store the authorziation token generated
    • HEROKU_EMAIL - Email id for heroku account
  2. Setup Github Secrets for App:

    • SECRET_KEY
  3. Github Actions CI/CD setup is now ready and can be triggered with push to master branch or manually from actions tab.

Github Actions

There are 2 Actions defined in this repo

Terraform Output

heroku_build.example: Still creating... [4m10s elapsed]
heroku_build.example: Still creating... [4m20s elapsed]
heroku_build.example: Still creating... [4m30s elapsed]
heroku_build.example: Creation complete after 4m34s [id=74b5d9f5-943e-4040-a96f-84dfe964d983]

Apply complete! Resources: 1 added, 0 changed, 1 destroyed.

Outputs:

app_id = "9b4a5cd9-4ee4-42d3-8476-20f7a9fc3bee"
app_name = "shashank123456789"
app_url = "https://shashank123456789.herokuapp.com"

Running Terraform Deployment locally

Steps

  1. export HEROKU_API_KEY=<TOKEN>
  2. export HEROKU_EMAIL
  3. export DATABASE_URL=$(heroku config:get DATABASE_URL --app $APP_NAME)
  4. terraform init -backend-config="conn_str=$DATABASE_URL"
  5. terraform plan -out plan
  6. terraform apply plan

devops-example-25981's People

Contributors

crowdbotics-apps avatar shashanksinha89 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.