Dockerising, a LEMP stack ( Nginx Php-fpm and Mariadb ) with docker-compose on Linux . Please check out this post to see how the same can be done with docker command line .
Installation of docker-compose is covered in detail on official site, do read through it . Pasting the quick howto for debian here.
sudo apt-get install python-pip
sudo pip install --upgrade pip
sudo pip install docker-compose
If you are following the last post you should now have the directory structure and conf files as below
First line mentions the version of docker-compose syntax we are using. The later lines mentions the services and options they use, you can cross-reference them with the docker commands used in the first post
Make the LEMP stack online.
docker-compose up -d
Above command will bring the 3 services mariadb, phpfpm and nginx online by deploying the respective containers . Phpfpm container will be deployed after building the image with Dockerfile, rest of the services will be containerised from the base images. A bridge network will be auto created by the docker-compose and all the services will be added to it so that they can talk to each other.
Above command will, download the latest mariadb image. run : Run it with the name mariadb. -v : Create a volume mount for /var/lib/mysql to host dir /root/lemp/mariadb/data. -e :Pass the mysql root password as environment variable. —network : Attach the container to bridge network internal. -d :Detach and run the container in background.
Create DB/grant privileges/restore database
docker exec -i mariadb mysql -uroot -pyour_secret_pass -e "create database tech_blog"
docker exec -i mariadb mysql -uroot -pyour_secret_pass -e "GRANT ALL PRIVILEGES ON techie_blog.* TO 'techie_user'@'%' identified by 'your_db_pass'"
docker exec -i mariadb mysql -uroot -pyour_secret_pass --force tech_blog < mariadb/tech_blog.sql
exec -i : executes commands interactively in a running container
Enable mysqli support on php-fpm.
As we are hosting a WP site on this stack we need to have mysqli support enabled for php-fpm, this can be achieved by creating a new image with mysqli support
RUN docker-php-ext-install mysqli
docker build -t php_fpm .
build -t : builds a new image and tags it as php_fpm:latest
With prototype 3 of Agri IoT, attempt is to proceed further by creating a actuator node that can be controlled from Openhab. Pro mini 3,3v 8Mhz is selected because of its small form, low power consumption and NRF24L01+ will work with it as a radio. A 4 CH 5V relay module is used to switch on/off devices and to power the whole setup a breadboard 3.3v/5v power supply is used Mysensors v2.0 API is used to build and connect the blocks. Prototype 3 actuator node setup is covered in this article, rest is in Agri IoT :: Prototype 2 : Gateway & Controller
Lessons learned the hardway : If your actuator node is disconnecting and staying of the grid it can be because of the noise from the relay module. The message similar to below in your node serial output denotes this.
Trying out Aquaponics in the limited space of balcony. This post tries to explain the basics, components needed and initial minimal setup to get the system in place. As you must be aware Aquaponics is the practice of growing fish and plants together. Fish excreta is rich with Ammonia which will be converted to nitrate that is good food for the plants. Conversion takes place in plant grow bed where bacteria grows. Water is cycled from the fish tank to the plant grow bed and back.
A 35 litre / 10 Gallon container is used to grow the fish and a 25 litre plant grow bed is used . Grow bed is placed on a level above the container and water is pumped into it with a submersible pump . Draining of the growbed back to the fish container is performed with an Auto siphon.
35 litre container for tank ( Fish tank volume should be larger than the growbed vloume )
25 litre barrel cut on top used as grow bed
9″ x 6″ HDPE sheet to cover the container ( Optional if you have a food safe container )
3/4″ PVC Standpipe
1 1/2″ Bell Siphon PVC pipe
1 1/2″ PVC cap
2 1/2″ PVC Gravel guard
3/4″ PVC tank connector
3/4″ PVC Female & Male adaptors to connect to tank connector
3/4″ L joints
Tape to insulate the PVC fittings
Points to note::
Fish tank volume should be larger than the growbed vloume or else a sump tank must be used
Make sure you have food safe container. To make sure used containers / barrels are food safe , they should have any of the below markings in the bottom
1″ Hole saw
.3″ drill bit
Clean the container and barrel. Wrap the container with HDPE sheet .
Grow bed preparation : Drill a 1″ hole using hole saw in the bottom on the Growbed barrel
Tank adapter : Connect the tank adaptor on the drilled hole, make sure the adaptor has valves that will seal the hole ( seals not in image )
Stand Pipe: Measure the depth of the grow bed and cut the 3/4″ standpipe so that it stays 2 inches below the surface. This is to prevent the water from reaching the surface of the growbed ( to prevent algae growth ). In my case growbed is 9 inch deep. the top of standpipe when connected to the tank adaptor is 7 inches from the bottom
Bell siphon: Cut 1 1/2″ pipe with length 9 inches for bell siphon and connect the cap to one end. The cap should be air tight, use PVC solvent to fix it. Other end of the pipe should have slits to allow water in. When placed on top of standpipe the bottom of the cap should be on level with standpipe
Growbed Outlet: Used 2 3/4″ pipe with length 7+ inches and elbow joint as growbed outlet. You should have enough outlet pipe length as this will help in starting the Autosiphon.
Pump and inlet :Submersible pump with 1100L/H output is used for the cycling water. Garden hose connected to the pump is used as inlet to the growbed. The whole setup assembled together is looking as below.
Testing : Switch on the pump , water should start flowing into the growbed . Once the water level reaches near to Siphon cap the water will drain back into the fish container . Water flow should stop when it reaches the slits of the Siphon.
Let the system continue on its flood and drain cycle, check the joints and make sure there is no leaks.