Dereja M&E System - Docker Architecture

Introduction

This documentation provides a comprehensive overview of the Docker-based architecture for the Dereja M&E System. The system is containerized using Docker and orchestrated with Docker Compose, making it portable and scalable across different environments.

Key Features

  • Containerized Architecture: All components run in isolated Docker containers
  • Microservices Design: Independent services for web, database, analytics, etc.
  • CI/CD Pipeline: Automated build and deployment with GitLab CI
  • Scalability: Easily scale individual services as needed
  • Environment Consistency: Consistent environments from development to production
  • Infrastructure as Code: All infrastructure defined in Docker Compose files

System Overview

Component Description
Web Application PHP-based application with Nginx web server
Database MariaDB for application data and PostgreSQL for analytics
Analytics Metabase for business intelligence and reporting
Chatbot Python-based Streamlit application for AI interactions
Management Tools phpMyAdmin, pgAdmin, and Portainer for administration

Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

  • Docker (minimum version 20.10.x)
  • Docker Compose (minimum version 1.29.x)
  • Git (for cloning the repository)

Installation Steps

1 Clone the Repository

Terminal Command
git clone https://your-repository-url/derejame-system.git cd derejame-system

2 Start the System

Start Command
docker-compose -f docker-compose.yml -p derejame up -d --build

3 Access Services

Service URL
Main Application http://localhost:8880
Metabase Analytics http://localhost:4000
phpMyAdmin http://localhost:3307
Portainer http://localhost:9099
AI Chatbot http://localhost:8502

System Architecture

The Dereja M&E system follows a containerized microservices architecture. Each component runs in its own Docker container, communicating through a dedicated network.

Data Flow

The system follows this data flow pattern:

  1. User requests are handled by Nginx
  2. Static content is served directly by Nginx
  3. PHP requests are forwarded to the PHP-FPM service
  4. Application data is stored in MariaDB
  5. Analytics data is stored in PostgreSQL
  6. Metabase queries PostgreSQL for reporting
  7. Chatbot service provides AI-powered interactions

Network Architecture

The system uses a custom bridge network (derejanet) with a fixed subnet (192.168.160.0/24). Each service has a static IP address within this subnet:

Service IP Address Description
webdata 192.168.160.55 Shared volume service
php 192.168.160.10 Application backend
nginx 192.168.160.20 Web server
metabase 192.168.160.30 Analytics dashboard
postgres 192.168.160.40 Analytics database
db (MariaDB) 192.168.160.50 Application database

Docker Services

The Docker Compose file defines the following services that make up the Dereja M&E system:

webdata

Shared volume service that syncs source code to the web root.

  • Image: php:8.2-fpm-alpine
  • Volumes: web_content, source code
  • Network: derejanet (192.168.160.55)
Volume Sync Development

php

PHP-FPM service running the application backend.

  • Build: Custom Dockerfile
  • Exposes: Port 9009
  • Depends on: db, webdata
  • Network: derejanet (192.168.160.10)
PHP 8.2 Application

nginx

Web server handling HTTP/HTTPS traffic.

  • Build: Custom Dockerfile (nginx_extended)
  • Ports: 8880:80, 8443:443
  • Depends on: php, webdata, metabase
  • Network: derejanet (192.168.160.20)
Port 80/443 Reverse Proxy

metabase

Business intelligence and analytics dashboard.

  • Image: metabase/metabase:latest
  • Ports: 4000:3000
  • Depends on: postgres
  • Network: derejanet (192.168.160.30)
Port 3000 Analytics

db (MariaDB)

Primary application database.

  • Image: mariadb:latest
  • Ports: 3306:3306
  • Volumes: mysql_data
  • Network: derejanet (192.168.160.50)
Port 3306 Database

chat

AI-powered chatbot service.

  • Build: Custom Dockerfile (ai_chatbot)
  • Ports: 8502:8502
  • Network: derejanet (192.168.160.100)
Port 8502 AI Chat

Build Process

The system is built using a multi-stage Dockerfile that creates optimized images for different components.

Dockerfile Structure

The Dockerfile defines three build targets:

  1. base: PHP-FPM environment with all dependencies
  2. nginx_extended: Custom Nginx image with additional tools
  3. ai_chatbot: Python environment for the Streamlit chatbot

Building the System

To build the entire system:

Build Command
docker-compose -f docker-compose.yml -p derejame build --no-cache

Building Individual Components

To build specific services:

Build PHP Service
docker-compose -f docker-compose.yml -p derejame build php
Build Chatbot Service
docker-compose -f docker-compose.yml -p derejame build chat

Deployment

The system can be deployed to different environments using Docker Compose.

Starting the System

To start all services in detached mode:

Start Command
docker-compose -f docker-compose.yml -p derejame up -d

Stopping the System

To stop all services while preserving data volumes:

Stop Command
docker-compose -f docker-compose.yml -p derejame down

Full Cleanup

To stop all services and remove all resources:

Cleanup Command
docker-compose -f docker-compose.yml -p derejame down --volumes --rmi all

Environment-Specific Deployment

The system supports different deployment environments:

  • Development: Includes volume syncing for live code updates
  • Production: Uses optimized images with proper SSL configuration
Environment Compose File Command
Development docker-compose.yml docker-compose -p derejame up -d
Production prod-docker-compose.yml docker-compose -f prod-docker-compose.yml -p derejame up -d

Configuration

The system is configured through environment variables and configuration files.

Key Configuration Files

  • docker-compose.yml: Main service definitions and configurations
  • Dockerfile: Build instructions for custom images
  • config/nginx.conf: Nginx server configuration
  • config/php.ini: PHP runtime configuration
  • .env: Environment variables for development
  • .env.prod: Environment variables for production

Environment Variables

Variable Service Description Default
MYSQL_ROOT_PASSWORD db MariaDB root password merqderejadmin
MYSQL_DATABASE db Application database name me_dereja
MB_ADMIN_EMAIL metabase Metabase admin email dev@merqconsultancy.org
MB_ADMIN_PASSWORD metabase Metabase admin password merqderejadev0
PGADMIN_DEFAULT_EMAIL pgadmin pgAdmin admin email dev@merqconsultancy.org
PGADMIN_DEFAULT_PASSWORD pgadmin pgAdmin admin password merqderejadev

CI/CD Pipeline

The system uses GitLab CI for automated build and deployment.

Pipeline Stages

  1. Build: Create Docker images for application and chatbot
  2. Deploy: Deploy to production environment

Build Stage

Builds application and chatbot images and pushes to Docker Hub:

.gitlab-ci.yml (Build)
build-app: stage: build image: docker:24.0.7 services: - docker:24.0.7-dind script: - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - docker build -t $DOCKER_REGISTRY/$IMAGE_NAME:latest ... - docker push $DOCKER_REGISTRY/$IMAGE_NAME:latest

Deploy Stage

Deploys the application to production environment:

.gitlab-ci.yml (Deploy)
deploy-production: stage: deploy image: docker:24.0.7 services: - docker:24.0.7-dind tags: - derejaproduction script: - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - docker-compose -f docker-compose.yml -p $COMPOSE_PROJECT_NAME down - docker-compose -f docker-compose.yml pull - docker-compose -f docker-compose.yml -p $COMPOSE_PROJECT_NAME up -d --build - docker image prune -f only: - main

API Documentation

The system uses multiple APIs for different components and resources. For detailed API documentation, see the API Documentation.

The Dereja M&E system provides RESTful APIs for integration with other systems using PHPRunner's REST API implementation.

Security

All API endpoints require authentication. Unauthorized access returns:

Error Response
{ "error": "Access denied", "success": false }

HTTP Basic Authentication

Authenticate using username and password:

cURL Example
curl --user admin:password "https://mne.dereja.com/app/api/v1.php?table=candidates&action=list"

API Key Authentication

Authenticate using X-Auth-Token header:

cURL Example
curl -H "X-Auth-Token: dsagdsew45234etw435" \ "https://mne.dereja.com/app/api/v1.php?table=candidates&action=list"

Advanced Security

Row-level security from your project automatically applies to API calls. Use inRestApi() in event handlers:

PHP Example
// In AfterSuccessfulLogin event if (!inRestApi()) { header("Location: candidates_list.php"); exit(); }

API Endpoints

All endpoints use format: https://mne.dereja.com/app/api/v1.php?table=candidates&action={action}

1. List Candidates

Retrieve candidate records with pagination and filtering

Parameter Description Example
records Number of records to return records=10
skip Records to skip (pagination) skip=20
q Advanced search filter q=(Status~equals~Active)
qs Full-text search qs=Abebe
cURL Request
curl "https://mne.dereja.com/app/api/v1.php?table=candidates&action=list&records=5&skip=10"
Browser Request
https://mne.dereja.com/app/api/v1.php?table=candidates&action=list&records=5&skip=10&apikey=$2y$10$.....
Sample Response
{ "data": [ { "CandidateID": "11", "StudentID": "", "Full_Name": "Meti Terefe Beyera", "First_Name": "Meti", "Middle_Name": "Terefe", "Last_Name": "Beyera", "Sex": "Female", "DOB": "1998-08-03", "Age": "26", "Region": "Oromia", "City": "Adama", "Sub_City": "", "Zone": "", "Woreda": "", "Kebele": "", "House_No": "", "Phone_Number": "904172631", "Phone_Number_Alternate": "963290060", "Email_Address": "methyterefe@gmail.com", "Disability_Status": "", "Disability_Type": "", "Disability_Type_Other": "", "Institution_Type": "University", "Institution_Name": "Adama Science and Technology University", "Education_Level": "", "Department": "", "Minor": "", "Major": "", "Enrollement_Type": "", "Skills": "", "Languages": "amharic, oromifa, english", "English_Proficiency_Level": "", "Industry_Specific_Skills": "", "IT_Related_Skills": "", "Certifications": "", "Year_of_graduation": "2023/2015", "Field_Of_Study": "Computer Science", "GPA": "3.23", "Intervention": "", "Campaign": "", "Attend_Employability_Skill": "Yes", "DAAP_enrolled_1st Round": "", "DAAP_Completed": "", "DAAP_Completed_Courses": "", "Job_Fair_Clinic": "Yes", "Job_Fair": "Yes", "Exit_Exam_Score": null, "Exit_Exam_Status": "", "DAAP_enrolled_2nd_Round": "", "Upload_on_Tracker": "Yes", "Upload_on_Website": "No", "Work_Experience": "", "Joined_Dereja_Services": "", "Dereja_Services": "", "Program_In_Dereja": "", "Dereja_Training_Services": "ESJR", "Training_Start_Date": null, "Training_End_Date": null, "Dereja_Event_Services": "Job Fair", "Event_Start_Date": null, "Event_End_Date": null, "Event_Participant_Type": "Candidate ", "Dereja_web_profile_completion": null, "Dereja_Information_Source": "", "Employment_Status": "Wage Employed", "Employment_Company": "Kenera General Plc", "Employer_Sector": "", "Employment_Position": "Engineer", "Salary": "", "Career_Level_Of_Payment": "", "Placement_Type": "", "Placement_Duration": "", "Remark": "", "Date": null, "candidate_data": "CandidateID: 11, StudentID: , Full_Name: Meti Terefe Beyera, Sex: Female, DOB: 1998-08-03, Age: 26, Region: Oromia, Phone_Number: 904172631, Email_Address: methyterefe@gmail.com, Disability_Status: , Education_Level: , Dereja_Training_Services: ESJR, Dereja_Event_Services: Job Fair, Employment_Status: Wage Employed, Date: " }, { "CandidateID": "12", "StudentID": "", "Full_Name": "Sultan Woyema Beketa", "First_Name": "Sultan", "Middle_Name": "Woyema", "Last_Name": "Beketa", "Sex": "Male", "DOB": null, "Age": null, "Region": "Oromia", "City": "Adama", "Sub_City": "", "Zone": "", "Woreda": "", "Kebele": "", "House_No": "", "Phone_Number": "970581770", "Phone_Number_Alternate": "970581770", "Email_Address": "sultanwoyenabkt@gmail.com", "Disability_Status": "", "Disability_Type": "", "Disability_Type_Other": "", "Institution_Type": "University", "Institution_Name": "Adama Science and Technology University", "Education_Level": "", "Department": "", "Minor": "", "Major": "", "Enrollement_Type": "", "Skills": "", "Languages": "Amharic,Oromifa,English", "English_Proficiency_Level": "", "Industry_Specific_Skills": "", "IT_Related_Skills": "", "Certifications": "", "Year_of_graduation": "2023/2015", "Field_Of_Study": "Civil Engineering", "GPA": "3.69", "Intervention": "", "Campaign": "Yes", "Attend_Employability_Skill": "Yes", "DAAP_enrolled_1st Round": "Yes", "DAAP_Completed": "", "DAAP_Completed_Courses": "", "Job_Fair_Clinic": "Yes", "Job_Fair": "", "Exit_Exam_Score": null, "Exit_Exam_Status": "", "DAAP_enrolled_2nd_Round": "", "Upload_on_Tracker": "Yes", "Upload_on_Website": "No", "Work_Experience": "", "Joined_Dereja_Services": "", "Dereja_Services": "", "Program_In_Dereja": "", "Dereja_Training_Services": "ESJR", "Training_Start_Date": null, "Training_End_Date": null, "Dereja_Event_Services": "Campaign", "Event_Start_Date": null, "Event_End_Date": null, "Event_Participant_Type": "Candidate ", "Dereja_web_profile_completion": null, "Dereja_Information_Source": "", "Employment_Status": "Not Employed", "Employment_Company": "", "Employer_Sector": "", "Employment_Position": "", "Salary": "", "Career_Level_Of_Payment": "", "Placement_Type": "", "Placement_Duration": "", "Remark": "Switched Off", "Date": null, "candidate_data": "CandidateID: 12, StudentID: , Full_Name: Sultan Woyema Beketa, Sex: Male, DOB: , Age: , Region: Oromia, Phone_Number: 970581770, Email_Address: sultanwoyenabkt@gmail.com, Disability_Status: , Education_Level: , Dereja_Training_Services: ESJR, Dereja_Event_Services: Campaign, Employment_Status: Not Employed, Date: " }, { "CandidateID": "13", "StudentID": "", "Full_Name": "Tesfaye Feyisa Tumebo", "First_Name": "Tesfaye", "Middle_Name": "Feyisa", "Last_Name": "Tumebo", "Sex": "Male", "DOB": "2000-02-10", "Age": "25", "Region": "Oromia", "City": "Adama", "Sub_City": "", "Zone": "", "Woreda": "", "Kebele": "", "House_No": "", "Phone_Number": "973446289", "Phone_Number_Alternate": "973446869", "Email_Address": "indetastakelu0960@gmail.com/tesfaye@gmail.com", "Disability_Status": "", "Disability_Type": "", "Disability_Type_Other": "", "Institution_Type": "University", "Institution_Name": "Adama Science and Technology University", "Education_Level": "", "Department": "", "Minor": "", "Major": "", "Enrollement_Type": "", "Skills": "", "Languages": "Amharic,English", "English_Proficiency_Level": "", "Industry_Specific_Skills": "", "IT_Related_Skills": "", "Certifications": "", "Year_of_graduation": "2023/2015", "Field_Of_Study": "Electrical Power and Control Engineering", "GPA": "3.7", "Intervention": "", "Campaign": "", "Attend_Employability_Skill": "Yes", "DAAP_enrolled_1st Round": "", "DAAP_Completed": "", "DAAP_Completed_Courses": "", "Job_Fair_Clinic": "Yes", "Job_Fair": "Yes", "Exit_Exam_Score": null, "Exit_Exam_Status": "", "DAAP_enrolled_2nd_Round": "", "Upload_on_Tracker": "Yes", "Upload_on_Website": "No", "Work_Experience": "", "Joined_Dereja_Services": "", "Dereja_Services": "", "Program_In_Dereja": "", "Dereja_Training_Services": "ESJR", "Training_Start_Date": null, "Training_End_Date": null, "Dereja_Event_Services": "Job Fair", "Event_Start_Date": null, "Event_End_Date": null, "Event_Participant_Type": "Candidate ", "Dereja_web_profile_completion": null, "Dereja_Information_Source": "", "Employment_Status": "Not Employed", "Employment_Company": "", "Employer_Sector": "", "Employment_Position": "", "Salary": "", "Career_Level_Of_Payment": "", "Placement_Type": "", "Placement_Duration": "", "Remark": "Switched Off", "Date": null, "candidate_data": "CandidateID: 13, StudentID: , Full_Name: Tesfaye Feyisa Tumebo, Sex: Male, DOB: 2000-02-10, Age: 25, Region: Oromia, Phone_Number: 973446289, Email_Address: indetastakelu0960@gmail.com/tesfaye@gmail.com, Disability_Status: , Education_Level: , Dereja_Training_Services: ESJR, Dereja_Event_Services: Job Fair, Employment_Status: Not Employed, Date: " }, { "CandidateID": "14", "StudentID": "", "Full_Name": "Endale Kasahun Abebe", "First_Name": "Endale", "Middle_Name": "Kasahun", "Last_Name": "Abebe", "Sex": "Male", "DOB": "1998-01-01", "Age": "27", "Region": "Oromia", "City": "Adama", "Sub_City": "", "Zone": "", "Woreda": "", "Kebele": "", "House_No": "", "Phone_Number": "960977984", "Phone_Number_Alternate": "917055936", "Email_Address": "endalekasahun701@gmail.com", "Disability_Status": "", "Disability_Type": "", "Disability_Type_Other": "", "Institution_Type": "University", "Institution_Name": "Debre Tabor University", "Education_Level": "", "Department": "", "Minor": "", "Major": "", "Enrollement_Type": "", "Skills": "", "Languages": "AMHARIC,ENGLISH,OROMIA", "English_Proficiency_Level": "", "Industry_Specific_Skills": "", "IT_Related_Skills": "", "Certifications": "", "Year_of_graduation": "2023/2015", "Field_Of_Study": "Electrical and Electronics Engineering", "GPA": "2.87", "Intervention": "", "Campaign": "Yes", "Attend_Employability_Skill": "", "DAAP_enrolled_1st Round": "", "DAAP_Completed": "", "DAAP_Completed_Courses": "", "Job_Fair_Clinic": "", "Job_Fair": "", "Exit_Exam_Score": null, "Exit_Exam_Status": "", "DAAP_enrolled_2nd_Round": "", "Upload_on_Tracker": "Yes", "Upload_on_Website": "No", "Work_Experience": "", "Joined_Dereja_Services": "", "Dereja_Services": "", "Program_In_Dereja": "", "Dereja_Training_Services": "", "Training_Start_Date": null, "Training_End_Date": null, "Dereja_Event_Services": "Campaign", "Event_Start_Date": null, "Event_End_Date": null, "Event_Participant_Type": "Candidate ", "Dereja_web_profile_completion": null, "Dereja_Information_Source": "", "Employment_Status": "Not Employed", "Employment_Company": "", "Employer_Sector": "", "Employment_Position": "", "Salary": "", "Career_Level_Of_Payment": "", "Placement_Type": "", "Placement_Duration": "", "Remark": "Busy", "Date": null, "candidate_data": "CandidateID: 14, StudentID: , Full_Name: Endale Kasahun Abebe, Sex: Male, DOB: 1998-01-01, Age: 27, Region: Oromia, Phone_Number: 960977984, Email_Address: endalekasahun701@gmail.com, Disability_Status: , Education_Level: , Dereja_Training_Services: , Dereja_Event_Services: Campaign, Employment_Status: Not Employed, Date: " }, { "CandidateID": "15", "StudentID": "", "Full_Name": "Tamiru Ketema Taddese", "First_Name": "Tamiru", "Middle_Name": "Ketema", "Last_Name": "Taddese", "Sex": "Male", "DOB": "2000-01-01", "Age": "25", "Region": "Oromia", "City": "Adama", "Sub_City": "", "Zone": "", "Woreda": "", "Kebele": "", "House_No": "", "Phone_Number": "917799922", "Phone_Number_Alternate": "979778933", "Email_Address": "tamiruketema20@gmail.com", "Disability_Status": "", "Disability_Type": "", "Disability_Type_Other": "", "Institution_Type": "University", "Institution_Name": "Debre Tabor University", "Education_Level": "", "Department": "", "Minor": "", "Major": "", "Enrollement_Type": "", "Skills": "", "Languages": "Amharic, afan oromo, english", "English_Proficiency_Level": "", "Industry_Specific_Skills": "", "IT_Related_Skills": "", "Certifications": "", "Year_of_graduation": "2023/2015", "Field_Of_Study": "Applied Biology", "GPA": "3.76", "Intervention": "", "Campaign": "Yes", "Attend_Employability_Skill": "Yes", "DAAP_enrolled_1st Round": "", "DAAP_Completed": "", "DAAP_Completed_Courses": "", "Job_Fair_Clinic": "", "Job_Fair": "", "Exit_Exam_Score": null, "Exit_Exam_Status": "", "DAAP_enrolled_2nd_Round": "", "Upload_on_Tracker": "Yes", "Upload_on_Website": "No", "Work_Experience": "", "Joined_Dereja_Services": "", "Dereja_Services": "", "Program_In_Dereja": "", "Dereja_Training_Services": "ESJR", "Training_Start_Date": null, "Training_End_Date": null, "Dereja_Event_Services": "Campaign", "Event_Start_Date": null, "Event_End_Date": null, "Event_Participant_Type": "Candidate ", "Dereja_web_profile_completion": null, "Dereja_Information_Source": "", "Employment_Status": "Not Employed", "Employment_Company": "", "Employer_Sector": "", "Employment_Position": "", "Salary": "", "Career_Level_Of_Payment": "", "Placement_Type": "", "Placement_Duration": "", "Remark": "Switched Off", "Date": null, "candidate_data": "CandidateID: 15, StudentID: , Full_Name: Tamiru Ketema Taddese, Sex: Male, DOB: 2000-01-01, Age: 25, Region: Oromia, Phone_Number: 917799922, Email_Address: tamiruketema20@gmail.com, Disability_Status: , Education_Level: , Dereja_Training_Services: ESJR, Dereja_Event_Services: Campaign, Employment_Status: Not Employed, Date: " } ], "success": true }

2. View Candidate

Get details of a specific candidate

cURL Request
curl "https://mne.dereja.com/app/api/v1.php?table=candidates&action=view&editid1=101"
Sample Response
{ "data": { "CandidateID": 101, "FullName": "Abebe Kebede Bekele", "Email": "abebek@gmail.com", "Gender": "Male", "Phone": "+251912345678", }, "success": true }

3. Insert Candidate

Create a new candidate record

cURL Request
curl -X POST "https://mne.dereja.com/app/api/v1.php?table=candidates&action=insert" \ -d "FullName=New Candidate&Email=new@example.com&Status=Active"
Sample Response
{ "success": true, "data": { "CandidateID": 201, "FullName": "New Candidate", "Email": "new@example.com", "Status": "Active" } }

4. Update Candidate

Update an existing candidate record

cURL Request
curl -X POST "https://mne.dereja.com/app/api/v1.php?table=candidates&action=update" \ -d "editid1=101&Status=Inactive&Phone=+9876543210"
Sample Response
{ "success": true }

5. Delete Candidate

Delete a candidate record

cURL Request
curl -X POST "https://mne.dereja.com/app/api/v1.php?table=candidates&action=delete&editid1=101"
Sample Response
{ "success": true }

Advanced Functions

sendError($message, $errno)

Send custom error responses from API handlers

PHP Example
// In API event handler API::sendError("Too many requests", 429);

inRestApi()

Check if current execution is via REST API

PHP Example
if (inRestApi()) { // API-specific logic } else { // Regular web request logic }

Troubleshooting

Issue Solution
Authentication failures Verify credentials and authentication method (Basic vs API Key)
Unexpected redirects Wrap redirects in if (!inRestApi()) condition
Debugging API calls Use verbose mode: curl -v "http://..."
Filter not working Verify filter syntax using Advanced Search in web interface
Permission issues Check user roles and row-level security settings
Debugging Example
curl -v -H "X-Auth-Token: your_token_here" \ "https://mne.dereja.com/app/api/v1.php?table=candidates&action=list"

Database Documentation

The system uses multiple databases for different services. For detailed database schema documentation, see the Database Schema Documentation.

Database Type Username Password Host Port
me_dereja MariaDB me_dereja me_dereja db 3306
merqderejadb PostgreSQL merqderejadb merqderejadb postgres 5432
MongoDB MongoDB merqderejadev merqderejadev mongo 27017

Database Access Commands

Access MariaDB
docker exec -it derejame_mariadb mysql -u me_dereja -pme_dereja me_dereja
Access PostgreSQL
docker exec -it derejame_postgres psql -U merqderejadb -d merqderejadb

Virtualmin Hosting

Production deployment on Virtualmin requires specific configuration for Docker services.

Virtualmin Server Requirements

  • Ubuntu 22.04 LTS
  • 4 vCPU cores
  • 8GB RAM
  • 50GB storage
  • Docker and Docker Compose installed

Configuration Steps

1 Create Virtual Server

Virtualmin Command
sudo virtualmin create-domain --domain mne.dereja.com --pass 'securepassword' --desc "Dereja M&E System"

2 Configure Proxy

Virtualmin Command
sudo virtualmin create-proxy --domain viz.mne.dereja.com \ --path / --url http://127.0.0.1:4000/

3 SSL Configuration

Virtualmin Command
sudo virtualmin install-cert --domain mne.dereja.com --letsencrypt

Deployment to Production

Transfer Docker Setup
scp -r derejame-system/ user@mne.dereja.com:/opt/derejame
Start Production System
cd /opt/derejame docker-compose -f docker-compose.yml -p derejame up -d

Troubleshooting

Common issues and solutions for the Docker-based Dereja M&E system.

Common Problems

Issue Possible Cause Solution
Containers not starting Port conflicts Check for other services using ports 3306, 80, 443, etc.
Database connection errors Incorrect credentials Verify environment variables in .env file
Permission issues Volume ownership Run: chown -R www-data:www-data /var/www/html
Metabase not loading PostgreSQL connection issue Check PostgreSQL logs and connection settings
Chatbot not responding Python dependencies Reinstall requirements: pip install -r requirements.txt

Useful Commands

View Container Logs
docker-compose -p derejame logs -f php
Rebuild Single Service
docker-compose -f docker-compose.yml -p derejame up -d --build php