Skip to content

grey-dev-0/docker-tf-lemp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Docker LEMP stack

This repository includes a terraform plan which can be used to build a dockerized LEMP stack, the main branch holds a single node stack plan, another branch that provides a scalable plan will be implemented later on.

Services included in this stack

  • php 8.0.x including all extensions required by the Laravel 8.x framework
  • nginx latest stable release
  • MariaDB 10.5.x
  • NodeJS 16.x (image only)
  • Rocky Linux 9 (base image for php, nginx and, node services)

Node image usage

The main purpose of the node image included in this plan is to run node commands within a php backend projects when necessary, e.g:

$ docker run --rm --volumes-from nginx -it -w /home/projects/example node npm install
$ docker run --rm --volumes-from nginx -it -w /home/projects/example node npm run build
$ docker run --rm --volumes-from nginx -it -w /home/projects/example node vue build --target lib --name some_library library.js

The --volumes-from option is used to inherit the php projects directory mounted to the nginx and php-app containers thus, any file changes applied by the npm command will instantly be reflected into those containers as well.

The image can be used to start a node server, it's recommended to add a container plan for it in the plan/containers.tf file.

Customization & Usage

To build and start the stack all you need is to have Docker and Terraform installed then, in terminal you write:

$ terraform init
$ terraform plan        # Optional
$ terraform apply 

Customizing Project(s) Location

To specify where your project(s) is located in your system and, where you'd like to mount it within the php-app container, please add or edit the existing volumes block found in the first container in plan/containers.tf file.

The volumes block is repeatable, so if you want to mount multiple locations from your system into the container feel free to add as much volumes blocks as you need.

Customizing Network Settings

The stack containers are bound to a network configured in the plan/networks.tf file, feel free to modify its IP address and, any other parameter as you see fit but, make sure that all containers in plan/containers.tf file follow the same IP range in case you've changed it, the IP address of each container is in the networks_advanced block under each container in the containers.tf file.

Credits & Attribution

About

Terraform plan of Dockerized LEMP stack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published