This project utilizes Docker to set up a development environment for a Python application. It includes a project initialization script, a docker-compose configuration to orchestrate necessary services, and a Dockerfile to build the Docker image of the application.
- Docker and Docker Compose installed on your machine.
- Basic knowledge of Docker, Docker Compose, and Python.
Create a .env file at the root of your project with the following variables:
PYTHON_HOST=0.0.0.0
PYTHON_PORT=8000
APP_NAME=python_starter_app
PYTHON_VERSION=3.12
NETWORK=python_networkAdjust these values as needed. They will be used by Docker Compose and the shell scripts.
The Dockerfile sets up the necessary environment to run the Python application, based on a Python Alpine image for minimal footprint.
The docker-compose.yml file defines the service for the Python application, using environment variables for configuration. It mounts the source code into the container and exposes the necessary port to access the application.
init-project.sh: Script to initialize the Python project if not already set up. Installs necessary dependencies.docker.sh: Script to manage the Docker environment (start, stop, restart, SSH access).
-
Project Initialization: Ensure the
.envfile is set up. Run theinit-project.shscript to initialize the Python project. -
Starting the Environment: Use the
docker.shscript with thestartargument to start the Docker environment. For example:
./docker.sh start-
Accessing the Application: Open your browser and navigate to
http://localhost:8000(or another configured port) to see your Python application in action. -
Stopping the Environment: Use the
docker.shscript with thestopargument to stop all services.
./docker.sh stop- Restarting the Environment: To restart, use
restart:
./docker.sh restart- SSH into the Container: To SSH into the container, use
ssh:
./docker.sh sshFeel free to contribute to the project by submitting pull requests or reporting issues.