Categories
Express.js Node

Node.js & Express.js fundamentals

What is Node.js

Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.

As an asynchronous event driven JavaScript runtime, Node is designed to build scalable network applications. This is in contrast to today’s more common concurrency model where OS threads are employed. Thread-based networking is relatively inefficient and very difficult to use. Furthermore, users of Node are free from worries of dead-locking the process, since there are no locks. Almost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks, scalable systems are very reasonable to develop in Node.

Categories
Docker

How To Build a Local Development Environment Using Docker

So let’s talk a little bit about development environments, shall we?

We developers are always trying to find the best solution when it comes to creating the best development environment, but that’s not always easy. Things are changing very fast nowadays and if you work on more than one project, things can get a little confusing.

About three years ago I thought I had the best solution for this problem using VirtualBox and Vagrant. I could start up a linux box in minutes and changes made in a project’s box would not affect other project’s environment. That was a nearly perfect solution when it worked. Most of the times things got out of hand when the projects got to big and complex and sometimes it was nearly impossible to recreate exacly the production environment using only one VM, and that’s when this solution failed.

Categories
Server Configuration

Connecting PHP to a MySQL inside a Docker container

If you ever had connection problems between PHP and a MySQL database in a Docker container, this article is for you.

I just went though this setting up this site. My linux box on AWS runs a couple of Node.js websites and I just wanted to install this WordPress site on the same server. I already had a Nginx server acting as a proxy and a MySQL server running on the server inside a Docker container so it would be very simple install php-fpm and configure another website on Nginx and use the same db server to kick off a WordPress site.