Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inception

A Docker-based infrastructure project that sets up a complete web application stack using Docker Compose, featuring NGINX, WordPress, and MariaDB.

Overview

This project creates a fully containerized web infrastructure with three main services:

  • NGINX as a reverse proxy and web server
  • WordPress as the content management system
  • MariaDB as the database backend

All services are orchestrated using Docker Compose with persistent data volumes and secure secret management.

Architecture

Services

NGINX

  • Acts as the reverse proxy and web server
  • Handles HTTPS connections on port 443
  • Serves WordPress content
  • Custom configuration for optimal performance

WordPress

  • Content Management System running on PHP-FPM
  • Exposed on port 9000 internally
  • Connected to MariaDB database
  • Persistent storage for themes, plugins, and media

MariaDB

  • Database server for WordPress
  • Exposed on port 3306
  • Persistent data storage
  • Secure credential management using Docker secrets

Network

All services communicate through a custom bridge network named bkas_network, ensuring isolation and secure inter-container communication.

Volumes

The project uses bind-mount volumes for data persistence:

  • WordPress data: ~/data/wordpress
  • MariaDB data: ~/data/mariadb
  • NGINX data: ~/data/nginx

Prerequisites

  • Docker Engine
  • Docker Compose
  • Make
  • Sufficient disk space for volumes
  • Root/sudo access for volume cleanup operations

Installation

1. Clone the Repository

git clone <repository-url>
cd inception

2. Configure Environment Variables

Create a .env file in the srcs/ directory with the necessary environment variables for your services.

3. Set Up Secrets

Populate the secret files in the secrets/ directory:

  • secrets/admin.txt - Admin credentials
  • secrets/database.txt - Database credentials
  • secrets/user.txt - User credentials

Usage

Build and Start Services

make

This command will:

  1. Create the necessary data directories
  2. Build all Docker images
  3. Start all services in detached mode

Alternative Commands

Start Services Only

make up

Stop Services

make down

Restart Services

make re

View Container Status

make list

View Logs

make logs

Cleanup

Clean Volumes

make clean

Stops containers, removes unused volumes, and deletes WordPress and MariaDB data.

Full System Clean

make full_clean

Performs a complete cleanup including all Docker images, containers, volumes, and networks.

Project Structure

inception/
├── Makefile                           # Build and management commands
├── secrets/                           # Secret files for credentials
│   ├── admin.txt
│   ├── database.txt
│   └── user.txt
└── srcs/
    ├── docker-compose.yml             # Service orchestration
    └── requirements/
        ├── mariadb/                   # MariaDB container
        │   ├── Dockerfile
        │   ├── conf/
        │   │   └── 50-server.cnf
        │   └── tools/
        │       └── docker-entrypoint.sh
        ├── nginx/                     # NGINX container
        │   ├── Dockerfile
        │   ├── conf/
        │   │   └── config.conf
        │   └── tools/
        │       └── docker-entrypoint.sh
        └── wordpress/                 # WordPress container
            ├── Dockerfile
            ├── conf/
            │   └── www.conf
            └── tools/
                └── docker-entrypoint.sh

Security Considerations

  • Credentials are managed through Docker secrets
  • Services communicate through an isolated network
  • NGINX handles HTTPS connections
  • Database is not directly exposed to the host network
  • Separate configuration files for each service

Data Persistence

All critical data is persisted using Docker volumes mapped to the host filesystem:

  • WordPress files and uploads are preserved across container restarts
  • Database data remains intact even when containers are removed
  • Configuration changes are maintained

Troubleshooting

Check Container Status

make list

View Service Logs

make logs

Inspect Individual Container

docker logs <container-name>

Access Container Shell

docker exec -it <container-name> /bin/sh

Common Issues

Port Already in Use

Ensure ports 443, 9000, and 3306 are not being used by other services.

Permission Denied

Some cleanup operations require sudo access. Ensure you have the necessary permissions.

Volume Mount Issues

Verify that the data directories exist and have proper permissions.

Maintenance

Backup Data

To backup your data, copy the volume directories:

cp -r ~/data/wordpress ~/backup/wordpress
cp -r ~/data/mariadb ~/backup/mariadb

Update Services

To update service images:

  1. Stop the services: make down
  2. Rebuild images: make up

License

This project is part of the 42 curriculum.

About

A Docker-based infrastructure project developed for 42 School, demonstrating containerization and system administration skills using Docker Compose, NGINX, WordPress, and MariaDB.

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages