Code Monkey home page Code Monkey logo

flask-digitalocean's Introduction

Flask Hello World App Deployment

This repository contains a simple Flask "Hello World" application, Dockerized and deployed on DigitalOcean using Terraform.

Overview

This repository demonstrates how to containerize a basic Flask application using Docker and deploy it to a DigitalOcean Droplet using Terraform.

Prerequisites

  1. DigitalOcean Account: Ensure you have a DigitalOcean account.
  2. DigitalOcean API Token: Generate a Personal Access Token from DigitalOcean.
  3. Terraform: Install Terraform.
  4. Docker: Install Docker.
  5. SSH Key: Ensure you have an SSH key added to your DigitalOcean account.

Flask Application

The Flask app is defined in app/app.py. This simple application responds with "Hello, World!" when accessed.

Docker

Build and Push Docker Image

  1. Log in to Docker Hub:

    docker login
  2. Build the Docker image:

    docker build -t yourdockerhubusername/flask-hello-world:latest app/
  3. Push the Docker image to Docker Hub:

    docker push yourdockerhubusername/flask-hello-world:latest

Terraform

The Terraform configuration files are located in the terraform/ directory. These files will help you create and manage your DigitalOcean Droplet.

Variables to Update

Update the following variables in terraform/terraform.tfvars:

  • digitalocean_token: Your DigitalOcean API token.
  • ssh_fingerprint: The fingerprint of your SSH key.
  • private_key_path: The path to your private SSH key.

Initialize and Apply Terraform

  1. Initialize Terraform:

    terraform init
  2. Apply the Terraform configuration:

    terraform apply

    Confirm the action by typing yes when prompted.

Access Your Flask App

After the Terraform apply process completes, it will output the IP address of your DigitalOcean Droplet. You can access your Flask app by navigating to http://<droplet-ip> in your web browser.

Summary

This setup provides a simple Flask "Hello World" application, containerized using Docker, and deployed to a DigitalOcean Droplet using Terraform. Ensure to replace placeholders like yourdockerhubusername, your_digitalocean_api_token, and your_ssh_key_fingerprint with your actual values.

flask-digitalocean's People

Contributors

kingrichardrosenbaum 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.