Docker Services For Development Infrastructure

Most of the web developers need at least three services running in their machine namely redis, mongo and mysql.

I have composed a simply docker-compose.yml file to run MySQL, MongoDB and Redis with Docker that too with a standard ports and authentication.

version: '3.2'
services:
    redis:
        image: redis:5.0.3
        restart: always
        network_mode: host
        ports:
            - 6379:6379
        command: redis-server --requirepass a_password
    mysql:
        image: mysql:5.7
        restart: always
        network_mode: host
        ports:
            - 3306:3306
        volumes:
            - type: bind
              source: ./mysql
              target: /var/lib/mysql
        environment:
            - MYSQL_ROOT_PASSWORD=a_password
        command: mysqld --sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
    mongodb:
        image: mongo:4.1.7-xenial
        restart: always
        environment:
          - MONGODB_USER="root"
          - MONGODB_DATABASE="some_db"
          - MONGODB_PASS="a_password"
          - MONGO_DATA_DIR=/data/db
          - MONGO_LOG_DIR=/dev/null
        volumes:
          - ./data/db:/data/db
        ports:
            - 27017:27017

Run

To run it, use following command:

docker-compose up -d

Why you weren’t hired!

Warning! Strong language, whole idea was to be heard!

Should it even be in your resume?

In the past three years, I am taken a lot of interviews. I realized that most of the developers who weren’t hired were not because they were less talented – but because our expectations from their resume didn’t match the level of knowledge they had. For instance, they will write “GO” and “GIT” in their resume but in an interview, I am told, they have worked on just a REST API and CAPP (Commit, Add, Pull and Push) in Go and Git respectively.

The Desire to be Hired!

They want to impress the interviewer and hence, they end up adding a lot of stuff. See, for me, I want knowledge! and I am sure it is for every interviewer. When I receive a resume, my expectations are set and I am generally very eager to speak to candidates. I am all excited and dreaming of the good happy ending to have a guy who knows what we are looking for. The desire here is to hire – I really want to hire you, but these high expectations are shattered into pieces right at the beginning of the interview when you just described what you have built. It is like saying I know Maths once you have learned how to divide! or English when you can barely form a word!

The Company Cup VS The World Cup

We have lived in technical problems – we have faced probably more fire than you might have seen in Game of Thrones. We have once paralyzed by the choice of our tech-stack. We have faced the wrath of hits. We have seen our database dying which wouldn’t revive after continuous CPR. This is World! And it Sucks! Now you come along and is full of confidence just because you are better than five developers in your company. You are forgetting that there is a world out there and it requires more than a REST API and CAPP!

The Reality Check!

After a couple of questions which is probably the toughest one – I have seen some candidates are still confident about a tech. After fifteen minutes, I am told that the interview is ‘tough’. Now you have forgotten the fact that you rated yourself 8-9 in MySQL and PHP. As long as it is PHP I think an interview is fine – It isn’t tough. Perhaps you don’t know your level. Ah ha – Your level was computed with a limited dataset – Your Current Company.

“I hate you” – you just said it

Unfortunately the tech can be quantified. It can be measured! There are multiple right answers but one is the best solution? No – only best solution is the only solution. We can measure the memory and cpu usage of your codes. We can measure number of queries you ran – fuck queries, we can even judge on your typing speed. Interview is a mirror! I can tell you where you stand but can you take it? Most of the interviewee couldn’t. As soon as I tell you “You are wrong” and You argued, it is over. It isn’t that we have a really nasty culture out here. But we know that sooner you are told you are wrong, sooner you can fix your codes! If you are arguing, we are loosing probably a couple of customers every minute! So attitude is a key. You are not hired probably because you live more than you should in denial! We can’t afford that.

Farewell!

So, please write what you really know in the resume. Ensure that level you are telling is measured with a bigger dataset. If you have attitude problem, I think there isn’t much you can do. Stay in your current company – consider yourself lucky!


Scheduler for AdonisJS without Command

AdonisJS is Laravel-like framework written for a Node. If you want to run a task like cron, there is a package called: adonis-scheduler

Assumptions / Requirements

I am assuming that you have already followed the installation steps of adonis-scheduler. Once you are done, following steps is what it takes to make ‘cron-less’ scheduler for your Adonis App

Running Scheduler without Command

Step 1 – Set up Scheduler

Create a file called scheduler.js in start folder with following content:

// start/scheduler.js

'use strict'

const Scheduler = use('Scheduler')
Scheduler.run()

Step 2 – Load with Server

Open server.js file and load the above file with preLoad(‘start/start-scheduler’)

new Ignitor(require('@adonisjs/fold'))
  .appRoot(__dirname)
  .preLoad('start/scheduler')
  .fireHttpServer()
  .catch(console.error)

This way, you don’t need pm2 setup and scheduler will not load with ace commands.

Cron syntax for JavaScript

Cron for JavaScript supports second as well as described following:

 # ┌────────────── second (optional)
 # │ ┌──────────── minute
 # │ │ ┌────────── hour
 # │ │ │ ┌──────── day of month
 # │ │ │ │ ┌────── month
 # │ │ │ │ │ ┌──── day of week
 # │ │ │ │ │ │
 # │ │ │ │ │ │
 # * * * * * *