This FastAPI application delivers runtime and system data through HTTP endpoints. Built as a modular platform for DevOps education, it enables practical exploration of containerization, CI/CD pipelines, monitoring solutions, and infrastructure automation concepts.
- Python 3.11+
- pip (Python package manager)
- Clone the repository and navigate to the project directory:
cd app_python- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate- Install dependencies:
pip install -r requirements.txtThe application runs on 0.0.0.0:5000 with debug mode disabled by default:
python app.pyYou can customize the server behavior using environment variables:
# Run on localhost:8080
PORT=8080 python app.py
# Run on 127.0.0.1:3000 with debug/reload enabled
HOST=127.0.0.1 PORT=3000 DEBUG=true python app.pyAfter starting the application, test the endpoints using curl:
curl http://localhost:8080/
curl http://localhost:8080/healthReturns comprehensive JSON metadata with the following top-level sections:
- service – name, version, description, framework
- system – hostname, platform, platform_version, architecture, cpu_count, python_version
- runtime – uptime_seconds, uptime_human, current_time, timezone
- request – client_ip, user_agent, method, path
- endpoints – list of available paths and their purpose
Returns a compact health status document:
- status – string status ("healthy")
- timestamp – current UTC timestamp
- uptime_seconds – number of seconds the process has been running
The application is configured via environment variables. All variables are optional; if not set, the defaults below are used.
| Variable | Default | Description |
|---|---|---|
HOST |
0.0.0.0 |
IP address the server binds to |
PORT |
5000 |
TCP port the application listens on |
DEBUG |
False |
When true, enables debug mode with auto-reload and detailed error messages |
- Docker 25.0.0+
To build the Docker image:
cd app_python
docker build -t [image-name]:[tag] -f Dockerfile .Example:
docker build -t my-fastapi-app:latest -f Dockerfile .To run application in a container:
docker run -d -p [host-port]:[container-port] --name [container-name] [image-name]:[tag]Example:
docker run -d -p 5000:5000 --name myapp my-fastapi-app:latestWhen running in Docker, you can override these environment variables:
docker run -d -p 5000:5000 \
-e HOST=0.0.0.0 \
-e PORT=5000 \
-e DEBUG=False \
--name myapp \
my-fastapi-app:1.0.0To use the pre-built image from Docker Hub registry:
# Pull latest version
docker pull flowelx/fastapi-lab-app:latest
# Run pulled image
docker run -d -p 5000:5000 flowelx/fastapi-lab-app:latest