Mini and Single Dockerized LEMP Stack

Open Source and opening the source is mandatory! At least for me since more than 10 years ago. A few days ago, when I decided to write again on my blog, I prepared a set of Dockerfiles to fire up a mini, single and of course robust LEMP stack based on Alpine as the foundation of docker images, NGINX, PHP FPM 7.x and MariaDB 10.x. Working with that is very easy and straight but a little tricky which I should mention in following but before everything you need to install the requirements:

First of all the project is available on my Github, so you can clone it with this command on your local machine:

git clone https://github.com/RoozbehShafiee/single_dockerized_lemp_stack.git

After cloning, you should define or modify a few environment variables for MariaDB and Nginx services in docker-compose.yml file.

For MySQL:

environment:
  - MYSQL_DATABASE=dbname
  - MYSQL_USER=username
  - MYSQL_PASSWORD=myPassword
  - MYSQL_ROOT_PASSWORD=rootPassword

and for Nginx:

environment:
  - DOMAIN_NAME=example.com
  - EMAIL_ADDRESS=my@email.com

Note that, this Nginx Docker image has built-in Let’s Encrypt and Certbot packages, so it’s not necessary to worry about your SSL certificates and they will be renew automatically every 3 months. So build and run the docker stuffs with docker compose command:

docker-compose up -d

Regarding to resources on your virtual machine (Preferably on Digital Ocean for personal or small scale usages) it takes a few minutes to build and run the containers (5 minutes on 1 core CPU and 1 GB of RAM). After firing up the containers try to place your PHP project files to the Nginx container with this command.

docker cp /path/to/project nginx:/data

Also you can change the volume in docker-compose.yml like below for Nginx and PHP-FPM services to place the project files in your desired path in Home directory or wherever you want.

volumes:
  - ~/data:/data

At this stage, this project is prepared for small scale PHP projects like a WordPress blog, as my blog is running up based on this project but I will try to add more functionality like compatibility and integrity to public cloud services such as AWS and supporting multi node cluster in future. So because this blog post might not be updated, watch the repository on Github for future changes.

 

a Munich based Cloud Architect and DevOps Engineer who gives cloud infrastructure and platform advises to enterprises and startups. Roozbeh leads engineering teams creating cloud, hyper-scale, and scale-out technologies and solutions.

Leave a reply:

Your email address will not be published.

Sliding Sidebar

Who’s Roozbeh?

Who’s Roozbeh?

a Munich based Cloud Architect and DevOps Engineer who gives cloud infrastructure and platform advises to enterprises and startups. Roozbeh leads engineering teams creating cloud, hyper-scale, and scale-out technologies and solutions.