React component propTypes and default props

I like to encapsulate my React container components in ES6 classes together with propTypes and default props. So no const MyClass.propTypes outside the class scope. This can be achieved by using static class members supported by by several Babel presets.

First, you’ll need to first install Babel package that provides support for static class members:

yarn add --dev babel-preset-stage-1

Second, enable this Babel preset in your .babelrc:

  "presets": [

Finally, you can define your class like a boss:

import React, {Component} from 'react';
import PropTypes from "prop-types";

export default class MyContainer extends Component {
    static propTypes = {
        defaultProp1: PropTypes.array,
        defaultProp2: PropTypes.bool,
        defaultProp3: PropTypes.object

    static defaultProps = {
        defaultProp1: [],
        defaultProp2: true,
        defaultProp3: {}

    constructor() {
        this.state = {...MyContainer.defaultProps};


Set permissions for files and directories in document root

When you need to setup several web sites or if you just experiment with  Docker, you may find useful these commands to set up the permissions for all files and directories in the document root recursive:

To change all the directories to 755 (drwxr-xr-x):

cd /document/root && find . -type d -exec chmod 755 {} \;

To change all the files to 644 (-rw-r–r–):

cd /document/root && find . -type f -exec chmod 644 {} \;

Originally posted by WombleGoneBad on StackOverflow.

Docker: Jenkins, Nginx and Let’s Encrypt auto creation/renewal

Today I’ve spent a few hours (ok, like six hours to be honest) to figure out how to get letsencrypt-nginx-proxy-companion work with oficial jenkins image and docker-compose. Although the readme points to an example of the config I was interested in, it seems to be outdated or I’m just doing something wrong. The problem is, that I wasn’t able to pass Jenkins  VIRTUAL_PORT to nginx config, so I kept seeing 502 Bad Gateway when I tried to reach Jenkins UI. Although I specified it in the environment vars. Meh. Strange thing is, that it actually worked  when I launched Jenkins container with docker run.

Anyway, I needed any solution at the end of the day, even if it wouldn’t be the one that uses docker-compose.


First I followed the instructions from here. And to spin up Jenkins container I created a shell script with following code:

docker run -d \
--name jenkinsci \
--expose 8080 \
-p 8080:8080 \
-p 50000:50000 \
-e \
-e VIRTUAL_PORT=8080 \
-v /absolute/path/to/jenkins_home:/var/jenkins_home \
--network=webproxy \

Make the script executable:

chmod +x

and you are good go. Be sure that jenkins_home directory on the host is writable by the nginx user, otherwise it will remain empty and you’ll wonder where is yours jenkins_home/secrets/initialAdminPassword.