Skip to content

An introduction to docker-compose used to build and run containers with nginx, mariadb, wordpress, adminer, ftp, redis, cadvisor and prometheus

Notifications You must be signed in to change notification settings

nyuuuukie/inception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inception

Description

The aim of this project is to build and up the following services using docker-compose:

  • MariaDB
  • Wordpress
  • NGiNX
  • Adminer
  • FTP
  • Redis Cache
  • Cadvisor
  • Prometheus

As a one of the bonus, there is also a static webpage.

VM

If your device has x86 arch, use VirtualBox and skip this block. (use uname -m, padawan)

I've done this project using Macbook Air (M1, ARM64)

If you want to do this project on M1 either, read the spoiler:

UTM

VirtualBox is not supported ARM, and as I read from the forum, they are not planning to do ARM version of it.

UTM turned out to be a great replacement for VB.

Once installed go the the gallery and select the image of the VM.
My choice was Debian 10.4 (LDXE), you can choose another. Even MacOS can be installed over your MacOS :)

To install shared folder, use this instruction.


Docker

Official docker docs says :

Some command line tools do not work when Rosetta 2 is not installed.
The old version 1.x of docker-compose. We recommend that you use Compose V2 instead.
Either type docker compose or enable the Use Docker Compose V2 option in the General preferences tab.

I decided to work with docker compose instead of docker-compose and it worked excellent.

⚠️ Do not forget to add docker group to current user!

Info, tips & links

.env file contains sensitive data in the enviroment variables.
Never store production environment and any important data in the repo!

Before writing Dockerfiles read the following and understand the concept of docker-init:

In all the containers I have used envsubst to replace env variables in the config files.


MariaDB

This is the first service you should up, because for mandatory part you have dependency chain:

MariaDB -> Wordpress -> Nginx

I could not install MariaDB on alpine 3.14, so I used alpine 3.7 for this container.


Wordpress

Wordpress is working under php-fpm, so I proxied to wordpress:port with fastcgi_pass.

Go ahead and take a look at a useful site with a descriptions of wp-cli commands.


Nginx

I've used a bash script to generate certificates.

This script is called from the Makefile and it produces CA key, CA crt, server key and server crt files.
Certificates passed to containers through separate volume.

You can manually add CA certificate to the browser to avoid 'insecure' error. Add certificate to Mozilla Firefox

As for Nginx, ssl_protocols TLSv1.2 TLSv1.3; must be specified in config file.

In this project nginx is the entry point to all the services, except ftp.


Adminer

Adminer is working under php-fpm as well, so I proxied to adminer:port with fastcgi_pass. You can also start it under php and proxy with proxy_pass


Redis

Redis running in the separate container, and should be installed and activated as a wordpress plug-in.

It is OK for protected-mode no to be set in the redis.conf, as container is working only in the internal network
and has no access point from outside.


FTP

Port 21 and a range of passive ports are opened for FTP, see docker-compose.yml

As for ftp client, I used this called lftp.
lftp is a terminal client that supports a number of network protocols (ftp, http, sftp...).

Here is some examples of lftp usage:

# First, connect to some ftp server:
# lftp -u ftp_user ftp://mhufflep.42.fr

# ls               # List files
# put <file_path>  # Upload file
# get <file_path>  # Download file
# rm  <file_path>  # Remove file

For self-signed certificates with local CA, add this line to lftp config (/etc/lftp.conf on my system):

set ssl:ca-file "/etc/ssl/certs/ca-certificates.crt"

cAdvisor & Prometheus

The info about these services could be found on the official pages:

Both of them are builded directly from their github repos.

About

An introduction to docker-compose used to build and run containers with nginx, mariadb, wordpress, adminer, ftp, redis, cadvisor and prometheus

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published