{"id":28417319,"url":"https://github.com/yusefsaid/containerization-technology","last_synced_at":"2026-02-08T08:02:41.259Z","repository":{"id":296467472,"uuid":"993494358","full_name":"YusefSaid/Containerization-Technology","owner":"YusefSaid","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-30T23:15:27.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-26T00:37:09.945Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YusefSaid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-30T22:26:51.000Z","updated_at":"2025-05-30T23:15:30.000Z","dependencies_parsed_at":"2025-05-31T09:17:39.444Z","dependency_job_id":"3a1e282f-32b0-4a0f-be65-bb4bfa4384f6","html_url":"https://github.com/YusefSaid/Containerization-Technology","commit_stats":null,"previous_names":["yusefsaid/containerization-technology"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/YusefSaid/Containerization-Technology","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YusefSaid%2FContainerization-Technology","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YusefSaid%2FContainerization-Technology/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YusefSaid%2FContainerization-Technology/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YusefSaid%2FContainerization-Technology/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YusefSaid","download_url":"https://codeload.github.com/YusefSaid/Containerization-Technology/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YusefSaid%2FContainerization-Technology/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269799407,"owners_count":24477635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-04T04:42:57.947Z","updated_at":"2026-02-08T08:02:40.196Z","avatar_url":"https://github.com/YusefSaid.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Containerization Technology\n\nThis project demonstrates comprehensive containerization practices using Docker, including multi-stage builds, CI/CD integration with GitLab, and reverse proxy configurations. The setup containerizes the Beetroot API using Infrastructure as Code principles with Docker Compose orchestration and automated deployment pipelines.\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Prerequisites](#prerequisites)\n- [Project Structure](#project-structure)\n- [Quick Start](#quick-start)\n- [Components](#components)\n- [Multi-Stage Dockerfile Architecture](#multi-stage-dockerfile-architecture)\n- [Reverse Proxy Configurations](#reverse-proxy-configurations)\n- [GitLab CI/CD Integration](#gitlab-cicd-integration)\n- [Configuration](#configuration)\n- [Troubleshooting](#troubleshooting)\n- [Daily Operations](#daily-operations)\n- [Technical Details](#technical-details)\n\n## Overview\n\nThis project automates the containerization and deployment of the Beetroot API with the following architecture:\n- **Multi-Stage Docker Build**: Optimized Go compilation with minimal runtime image\n- **Container Registry**: GitLab-integrated automated image building and storage\n- **Reverse Proxy Solutions**: Traefik, Nginx, and Apache configurations\n- **Network Isolation**: API accessible only through reverse proxies\n- **CI/CD Automation**: GitLab pipelines for automated builds and deployments\n- **Environment Management**: .env file configurations for different deployment scenarios\n\n## Prerequisites\n\nBefore starting, ensure you have the following installed and configured:\n\n- **Docker Engine** (20.10 or later)\n- **Docker Compose** (v2.0 or later)\n- **GitLab Account**: With container registry access\n- **Git**: For repository management\n- **MTU Configuration**: Docker daemon configured with MTU 1442\n\n### Required System Configuration\n\nEnsure your Docker daemon configuration includes:\n```json\n{\n  \"mtu\": 1442\n}\n```\n\n## Project Structure\n\n```\nexercise-02-containerization-technology/\n├── README.md --------------------------------\u003e # This file\n├── Dockerfile -------------------------------\u003e # Multi-stage Beetroot container build\n├── .gitlab-ci.yml ---------------------------\u003e # CI/CD pipeline configuration\n├── beetroot/ --------------------------------\u003e # Base Beetroot application setup\n│   ├── docker-compose.yml -------------------\u003e # Basic container orchestration\n│   ├── .env ---------------------------------\u003e # Environment variables\n│   └── .env.example -------------------------\u003e # Environment template\n├── data/ ------------------------------------\u003e # Application data\n│   └── beetroot.json ------------------------\u003e # API data file\n├── traefik/ ---------------------------------\u003e # Traefik reverse proxy stack\n│   ├── docker-compose.yml -------------------\u003e # Traefik orchestration\n│   ├── traefik.yml --------------------------\u003e # Traefik static configuration\n│   ├── config.yml ---------------------------\u003e # Traefik dynamic configuration\n│   ├── .env ---------------------------------\u003e # Traefik environment variables\n│   └── .env.example -------------------------\u003e # Traefik environment template\n├── nginx/ -----------------------------------\u003e # Nginx reverse proxy stack\n│   ├── docker-compose.yml -------------------\u003e # Nginx orchestration\n│   ├── nginx.conf ---------------------------\u003e # Nginx proxy configuration\n│   ├── .env ---------------------------------\u003e # Nginx environment variables\n│   └── .env.example -------------------------\u003e # Nginx environment template\n└── apache/ ----------------------------------\u003e # Apache reverse proxy stack\n    ├── docker-compose.yml -------------------\u003e # Apache orchestration\n    ├── apache.conf --------------------------\u003e # Apache proxy configuration\n    ├── .env ---------------------------------\u003e # Apache environment variables\n    └── .env.example -------------------------\u003e # Apache environment template\n```\n\n## Quick Start\n\n### Automated Deployment\n\n1. **Clone the repository:**\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd exercise-02-containerization-technology\n   ```\n\n2. **Set up environment variables:**\n   ```bash\n   # Copy example environment files\n   cp beetroot/.env.example beetroot/.env\n   cp traefik/.env.example traefik/.env\n   cp nginx/.env.example nginx/.env\n   cp apache/.env.example apache/.env\n   \n   # Edit .env files with your configurations\n   nano beetroot/.env\n   ```\n\n3. **Build and deploy with Traefik (recommended):**\n   ```bash\n   cd traefik/\n   docker compose --env-file .env up -d\n   ```\n\n4. **Access the API:**\n   - Visit: `http://localhost`\n   - API endpoint: `http://localhost/api`\n\n### Alternative Proxy Deployments\n\n**Nginx deployment:**\n```bash\ncd nginx/\ndocker compose --env-file .env up -d\n```\n\n**Apache deployment:**\n```bash\ncd apache/\ndocker compose --env-file .env up -d\n```\n\n## Components\n\n### Container Components\n\n| Component | Description | Image | Port |\n|-----------|-------------|-------|------|\n| **Beetroot API** | Go-based REST API application | Custom built (Alpine-based) | 8080 |\n| **Traefik** | Modern reverse proxy and load balancer | traefik:v2.10 | 80 |\n| **Nginx** | High-performance web server and reverse proxy | nginx:1.25 | 80 |\n| **Apache** | Flexible web server with reverse proxy | httpd:2.4 | 80 |\n\n### Network Architecture\n\n- **External Access**: `Internet` → **Reverse Proxy:80** → **Beetroot API:8080**\n- **Container Isolation**: API not directly accessible from external network\n- **Service Discovery**: Container-to-container communication via Docker networking\n\n## Multi-Stage Dockerfile Architecture\n\nThe Dockerfile implements a two-stage build process for optimal security and size:\n\n### Stage 1: Builder (golang:1.21-alpine)\n- **Purpose**: Compile Go source code into static binary\n- **Components**: Git, Go toolchain, tzdata for timezone support\n- **Process**: Clone repository → Install dependencies → Build binary\n\n### Stage 2: Runtime (alpine:3.18)\n- **Purpose**: Minimal runtime environment\n- **Components**: Only tzdata (temporary), compiled binary\n- **Security**: No build tools, minimal attack surface\n- **Size Optimization**: ~19.7MB final image\n\n### Build Flow\n\n\u003cimg width=\"600\" alt=\"Multi-stage build flow for creating the Beetroot API container image\" src=\"https://github.com/user-attachments/assets/d27d44d4-4cc9-44a5-87ed-a1c28b77d290\" /\u003e\n\n*Figure 1: Multi-stage build flow for creating the Beetroot API container image.*\n\n### Network Topology\n\n\u003cimg width=\"500\" alt=\"Topology of Beetroot API deployment using a reverse proxy\" src=\"https://github.com/user-attachments/assets/ba0cf006-49c9-428d-849d-f7b796f28d57\" /\u003e\n\n*Figure 2: Topology of Beetroot API deployment using a reverse proxy (Traefik, Nginx, or Apache).*\n\n## Reverse Proxy Configurations\n\n### Traefik Configuration\n\n**Modern Features:**\n- Dynamic service discovery\n- Automatic HTTPS (when configured)\n- Dashboard and API monitoring\n- File-based configuration with hot reload\n\n**Key Files:**\n- `traefik.yml`: Static configuration (entry points, providers)\n- `config.yml`: Dynamic routing rules\n- Labels-based service discovery in docker-compose\n\n### Nginx Configuration\n\n**Traditional Approach:**\n- High-performance HTTP server\n- Robust reverse proxy capabilities\n- Custom `nginx.conf` configuration\n- Upstream load balancing support\n\n**Configuration Highlights:**\n```nginx\nlocation / {\n    proxy_pass http://beetroot:8080;\n    proxy_set_header Host $host;\n    proxy_set_header X-Real-IP $remote_addr;\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n}\n```\n\n### Apache Configuration\n\n**Enterprise Features:**\n- Module-based architecture\n- Flexible virtual host configuration\n- ProxyPass/ProxyPassReverse directives\n- Extensive logging capabilities\n\n**Configuration Highlights:**\n```apache\nProxyPass \"/\" \"http://beetroot:8080/\"\nProxyPassReverse \"/\" \"http://beetroot:8080/\"\nProxyPreserveHost On\n```\n\n## GitLab CI/CD Integration\n\n### Pipeline Architecture\n\nThe CI/CD pipeline uses **Kaniko** for secure, unprivileged container building:\n\n```yaml\nbuild:\n  stage: build\n  image:\n    name: gcr.io/kaniko-project/executor:v1.23.2-debug\n    entrypoint: [\"\"]\n  script:\n    - /kaniko/executor \\\n      --context \"${CI_PROJECT_DIR}\" \\\n      --dockerfile \"${CI_PROJECT_DIR}/Dockerfile\" \\\n      --destination \"${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}\"\n  rules:\n    - changes:\n      - Dockerfile\n```\n\n### Automation Features\n\n- **Trigger Conditions**: Automatic builds on Dockerfile changes\n- **Secure Building**: No privileged Docker daemon required\n- **Registry Integration**: Direct push to GitLab Container Registry\n- **Version Management**: Git tag-based image versioning\n\n## Configuration\n\n### Environment Variables (.env files)\n\n#### Beetroot Application (`beetroot/.env`)\n```bash\nREGISTRY_IMAGE=registry.gitlab.com/username/project\nTAG=latest\nBEETROOT_JSON_PATH=/data/beetroot.json\nTZ=Europe/Oslo\n```\n\n#### Traefik Configuration (`traefik/.env`)\n```bash\nREGISTRY_IMAGE=registry.gitlab.com/username/project\nTAG=latest\nTRAEFIK_API_DASHBOARD=true\nTRAEFIK_LOG_LEVEL=DEBUG\n```\n\n#### Nginx Configuration (`nginx/.env`)\n```bash\nREGISTRY_IMAGE=registry.gitlab.com/username/project\nTAG=latest\nNGINX_HOST=localhost\nNGINX_PORT=80\n```\n\n#### Apache Configuration (`apache/.env`)\n```bash\nREGISTRY_IMAGE=registry.gitlab.com/username/project\nTAG=latest\nAPACHE_SERVER_NAME=localhost\nAPACHE_LOG_LEVEL=warn\n```\n\n### Data Configuration\n\nThe `data/beetroot.json` file contains the API data served by the application:\n```json\n{\n  \"status\": \"online\",\n  \"message\": \"Beetroot API is running\",\n  \"timestamp\": \"2025-01-01T00:00:00Z\"\n}\n```\n\n## Troubleshooting\n\n### Common Issues\n\n| Issue | Symptoms | Solution |\n|-------|----------|----------|\n| **Image tag case sensitivity** | GitLab push failures | Use lowercase tags only: `latest` not `Latest` |\n| **Binary not found** | Container startup failures | Verify COPY paths in Dockerfile match build output |\n| **Port conflicts** | \"Port already in use\" errors | Stop conflicting containers: `docker compose down` |\n| **Environment variables** | Configuration not loading | Check .env file syntax and placement |\n| **Network isolation** | Direct API access possible | Verify no published ports on beetroot service |\n| **MTU configuration** | Network connectivity issues | Ensure Docker daemon MTU is set to 1442 |\n\n### Diagnostic Commands\n\n#### Container Diagnostics\n```bash\n# Check running containers\ndocker ps -a\n\n# View container logs\ndocker logs \u003ccontainer-name\u003e\n\n# Inspect container configuration\ndocker inspect \u003ccontainer-name\u003e\n\n# Test API accessibility\ncurl -i http://localhost/\ncurl -i http://localhost:8080/  # Should fail (no direct access)\n```\n\n#### Image Diagnostics\n```bash\n# List built images\ndocker images\n\n# Check image layers and size\ndocker history \u003cimage-name\u003e\n\n# Verify multi-stage build\ndocker build --target builder -t beetroot-builder .\ndocker run --rm beetroot-builder ls -la /app/Beetroot/cmd/beetroot/\n```\n\n#### Network Diagnostics\n```bash\n# Check Docker networks\ndocker network ls\n\n# Inspect compose network\ndocker network inspect \u003ccompose-network\u003e\n\n# Test internal connectivity\ndocker exec \u003cproxy-container\u003e ping beetroot\n```\n\n## Daily Operations\n\n### Development Workflow\n\n1. **Local Development:**\n   ```bash\n   # Build image locally\n   docker build -t beetroot-local .\n   \n   # Test with different proxies\n   cd traefik/ \u0026\u0026 docker compose up -d\n   cd ../nginx/ \u0026\u0026 docker compose up -d\n   cd ../apache/ \u0026\u0026 docker compose up -d\n   ```\n\n2. **Testing Changes:**\n   ```bash\n   # Rebuild and restart services\n   docker compose build\n   docker compose up -d --force-recreate\n   \n   # View logs for debugging\n   docker compose logs -f\n   ```\n\n3. **Production Deployment:**\n   ```bash\n   # Tag and push to registry\n   git tag v1.0.0\n   git push origin v1.0.0\n   \n   # Deploy with production image\n   docker compose --env-file .env up -d\n   ```\n\n### Maintenance Tasks\n\n#### Starting Services\n```bash\n# Start specific proxy stack\ncd \u003cproxy-directory\u003e/\ndocker compose --env-file .env up -d\n\n# Verify services are running\ndocker compose ps\ncurl -i http://localhost/\n```\n\n#### Stopping Services\n```bash\n# Stop and remove containers\ndocker compose down\n\n# Stop and remove containers + volumes\ndocker compose down -v\n\n# Remove unused images\ndocker image prune -f\n```\n\n#### Updating Configurations\n```bash\n# Reload proxy configurations (Traefik auto-reloads)\n# Nginx/Apache require restart:\ndocker compose restart nginx\ndocker compose restart apache\n\n# Update environment variables\nnano .env\ndocker compose up -d --force-recreate\n```\n\n## Technical Details\n\n### Security Considerations\n\n- **Multi-stage builds**: Eliminate build tools from runtime image\n- **Non-root execution**: Alpine base with minimal permissions\n- **Network isolation**: API only accessible through reverse proxy\n- **Version pinning**: Specific image tags prevent supply chain attacks\n- **Secret management**: Environment variables for sensitive configuration\n\n### Performance Optimization\n\n- **Image size**: 19.7MB final image using Alpine Linux\n- **Build caching**: Docker layer caching for faster rebuilds\n- **Static binary**: Go compilation produces self-contained executable\n- **Reverse proxy caching**: Optional caching headers for static content\n\n### Container Orchestration\n\n- **Service dependencies**: Proper container startup order\n- **Health checks**: Built-in container health monitoring\n- **Volume management**: Persistent data and configuration mounting\n- **Network segmentation**: Isolated container communication\n\n### CI/CD Best Practices\n\n- **Kaniko builds**: Secure, unprivileged container building\n- **Registry integration**: Automated image storage and versioning\n- **Change detection**: Builds triggered only on relevant file changes\n- **Tag management**: Git tag-based image versioning strategy\n\n## Additional Notes\n\n### Customization Options\n\n- **Timezone configuration**: Modify `TZ` build argument for different regions\n- **API data**: Update `data/beetroot.json` for custom API responses\n- **Proxy settings**: Adjust reverse proxy configurations for specific requirements\n- **Resource limits**: Add memory/CPU constraints in docker-compose files\n\n### Extension Possibilities\n\n- **HTTPS support**: Add SSL/TLS termination at proxy level\n- **Monitoring**: Integrate Prometheus metrics and Grafana dashboards\n- **Load balancing**: Scale API containers with proxy load balancing\n- **Health checks**: Implement application health endpoints\n\n### Production Considerations\n\nThis setup is designed for educational purposes. For production deployment:\n- Implement proper SSL/TLS certificates\n- Configure authentication and authorization\n- Set up centralized logging and monitoring\n- Implement backup and disaster recovery procedures\n- Use container orchestration platforms (Kubernetes, Docker Swarm)\n\n---\n\n**Project**: Exercise 02 - Containerization Technology  \n**Course**: IKT114 - IT Orchestration  \n**Institution**: University of Agder  \n**Authors**: Yusef Said \u0026 Eirik André Lindseth\n\n## Version History\n\n- **v1.0**: Initial multi-stage Docker implementation with reverse proxy configurations\n- **v1.1**: Added GitLab CI/CD integration and automated container registry deployment\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusefsaid%2Fcontainerization-technology","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusefsaid%2Fcontainerization-technology","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusefsaid%2Fcontainerization-technology/lists"}