Sign inSign up

shakeelsaga/logipredict

By shakeelsaga

•Updated 29 days ago

A containerized Machine Learning API and web interface for predicting logistics transit times.

Image
Languages & frameworks
API management
Machine learning & AI
0

979

shakeelsaga/logipredict repository overview

⁠LogiPredict

LogiPredict is a full-stack, production-grade web application and RESTful API that predicts shipment transit times using a trained Random Forest Regressor machine learning pipeline.

This repository hosts the stateless web/API compute layer, optimized using a multi-stage Debian-slim build, running an unprivileged system user, and utilizing Gunicorn with master process preloading for high-concurrency safety.

⁠Architectural Requirements

This image contains the application runtime and the pre-trained machine learning model (model.pkl). It is entirely stateless and requires a backing PostgreSQL database to log estimation audits and maintain persistent history.

Do not run this image in absolute isolation without providing a valid DATABASE_URL.

⁠Configuration Parameters

The container reads configuration parameters via environment runtime injection. Ensure the following variables are passed to the container:

VariableDescriptionExample / Default
SECRET_KEYSymmetric encryption key for securing Flask session states.your_secure_string
DATABASE_URLFully qualified connection URI pointing to a target PostgreSQL service.postgresql://user:pass@hostname:5432/dbname
FLASK_ENVSets the application execution mode.production

⁠Quick Start via Docker Compose

The recommended deployment workflow is to orchestrate this image alongside a native PostgreSQL container using Docker Compose. This architecture handles network isolation, database health checks, and data volume mapping automatically.

Create a docker-compose.yml file in your workspace:

services:
  web:
    image: shakeelsaga/logipredict:v1.0.0
    ports:
      - "8080:5000"
    environment:
      - SECRET_KEY=super_secure_flask_key
      - DATABASE_URL=postgresql://logi_user:logi_pass@db:5432/logipredict_db
    depends_on:
      db:
        condition: service_healthy

  db:
    image: postgres:15-alpine
    environment:
      - POSTGRES_USER=logi_user
      - POSTGRES_PASSWORD=logi_pass
      - POSTGRES_DB=logipredict_db
    volumes:
      - pg_data:/var/lib/postgresql/data
    expose:
      - "5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U logi_user -d logipredict_db"]
      interval: 5s
      timeout: 5s
      retries: 5

volumes:
  pg_data:

⁠Running the Stack

Launch the decoupled environment directly from your shell:

docker compose up -d

The application interface will be accessible on the host machine at http://localhost:8080⁠.

⁠Image Features & Optimizations

  • Multi-Stage Footprint: Stripped of heavy OS compilation suites (gcc, build-essential) and caching modules, dropping artifact overhead significantly.
  • Principle of Least Privilege: Drops root terminal inheritance at build time; processes are executed by a restricted, non-root application user (logiuser).
  • PID 1 Signal Handling: Uses Gunicorn as the explicit process manager to route kernel termination events gracefully (SIGTERM).
  • Race Condition Mitigation: Built with worker pool memory preloading (--preload) to safeguard system catalogs during multi-worker initialization steps.

Tag summary

Content type

Image

Digest

sha256:4a532fb85…

Size

169.9 MB

Last updated

29 days ago

docker pull shakeelsaga/logipredict