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.
- 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.
- Docker
- Docker Compose
- Clone this repository.
- Copy
.env.template
to.env
and adjust the environment variables according to your needs. - Run
docker-compose up --build
to build and start the containers.
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.
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.
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.
Contributions are welcome! Please feel free to submit a pull request.
This project is open source and available under the MIT License.