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.
php 8.0.x
including all extensions required by theLaravel 8.x
frameworknginx
lateststable
releaseMariaDB 10.5.x
NodeJS 16.x
(image only)Rocky Linux 9
(base image forphp
,nginx
and,node
services)
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.
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
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.
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.