Skip to content

usarral/python-docker-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-docker-template

Python Docker Deployment Template

This project provides a template for deploying a Python application using Docker and Docker Compose, including a PostgreSQL database setup. It's designed to be a starting point for Python applications that require a database.

Features

  • Dockerized Python application setup.
  • PostgreSQL database integration.
  • Environment variables for configuration.
  • Docker Compose for easy development and deployment.
  • .env file for environment-specific settings.
  • .gitignore setup to exclude environment files and IDE settings.

Prerequisites

  • Docker
  • Docker Compose

Getting Started

  1. Clone this repository.
  2. Copy .env.template to .env and adjust the environment variables according to your needs.
  3. Run docker-compose up --build to build and start the containers.

Structure

  • app/: Python application source code.
    • app.py: Entry point for the Python application.
    • requirements.txt: Python dependencies.
  • database/db: Directory for PostgreSQL data persistence.
  • Dockerfile: Dockerfile for the Python application.
  • docker-compose.yml: Docker Compose configuration for the entire application.
  • .env.template: Template for environment variables.
  • .gitignore: Git ignore file.

Configuration

The application can be configured using the following environment variables:

  • SERVICE_PORT: The port on which the Python application will run.
  • POSTGRES_USER: Username for PostgreSQL.
  • POSTGRES_PASSWORD: Password for PostgreSQL.
  • POSTGRES_DB: Database name for PostgreSQL.

Deployment

For development, the application can be run with Docker Compose using the command mentioned in the Getting Started section. For production deployment, it is recommended to remove the port mapping for the application service in docker-compose.yml and use a Docker network or a reverse proxy for routing.

Contributing

Contributions are welcome! Please feel free to submit a pull request.

License

This project is open source and available under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published