Git Product home page Git Product logo

docker-flask-template's Introduction

docker-flask-template

This project will create a generic, Dockerized, Flask application ready for action!

This example shows two different use-cases for the Flask Application. An API and an HTML site. If you want just an HTML site, you can remove the API functionality by deleting these lines in app/resources.py.

After following the setup instructions and starting your Docker container, you should have a running Flask application with two routes:

Technology Stack

Language

Python

Framework

Flask

Development Operations

Docker Compose

Local Development Environment Setup Instructions

1: Clone the repository to a local directory

git clone [email protected]:harvard-lts/docker-flask-template.git

2: Copy the cloned files into your own new project repository

After cloning your brand-new project repository, you can copy the files from this repository into it.

3: Create app config

Create config file for environment variables
  • Make a copy of the config example file ./env-example.txt
  • Rename the file to .env
  • Replace placeholder values as necessary

Note: The config file .env is specifically excluded in .gitignore and .dockerignore, since it contains credentials it should NOT ever be committed to any repository.

Create webapp.conf file for environment variables
  • Make a copy of the config example file ./webapp.conf.example
  • Rename the file to webapp.conf
  • Replace placeholder values as necessary (anything localhost will be changed in a deployed environment)

Note: The config file webapp.conf is specifically excluded in .gitignore and .dockerignore, since it can contain credentials it should NOT ever be committed to any repository.

4: Change container and network names in docker-compose-local.yml

5: Change image names in docker-compose.yml

6: Change log file names in supervisord.conf

7: Change titles and descriptions in app/resources.py

7: Change uid and gid in DockerfilePub

8: Start

START

This command builds all images and runs all containers specified in the docker-compose-local.yml configuration.

docker-compose -f docker-compose-local.yml up --build --force-recreate

9: Install Packages (optional)

This step is only required if additional python packages must be installed during development. Update the requirements.txt inside the container to install new python packages.

Run docker exec to execute a shell in the container by name

Open a shell using the exec command to access the hgl-downloader container.

docker exec -it docker-flask-template bash
Install a new pip package

Once inside the mps-asset-validation container, run the pip install command to install a new package and update the requirements text file.

pip install packagename && pip freeze > requirements.txt

10: Stop

STOP AND REMOVE

This command stops and removes all containers specified in the docker-compose-local.yml configuration. This command can be used in place of the 'stop' and 'rm' commands.

docker-compose -f docker-compose-local.yml down

docker-flask-template's People

Contributors

clayheaton avatar dependabot[bot] avatar dl-maura avatar phil-plencner-hl avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

clayheaton

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.