Using Docker at Work for Local Development

At the company I work for we wanted to setup Docker so local developers do not have to do all this work to get their machines configured for any projects. We also wanted to get away from have documentation for different developer laptops. We use Macs, Linux, and Windows machines. So now I have decided to go down the path of learning how to set this up and get this working for everyone.

https://jcwebconcepts.files.wordpress.com/2018/06/be255-1ht5vmchg-au_qibivzvlqa.png?w=809

Before I started learning, what I thought what we were eventually going to get is, one set of files that would work no matter what operating system our devs were using. So then I started research about Docker. I started by going through Docker’s documentation. I took a course in Pluralsight about it. Then I started searching YouTube for Docker talks to get me in understanding the basics. I still have way more things to learn but I feel like I am going down the right path.

So now I was ready to figure out what I needed Docker to do for us. I know that I need 2 services. One service was for EmberJS and the other service is for our web server Nginx. So I started by creating a Dockerfile for the Ember service.

FROM node:8.11.1-alpine
LABEL maintainer="John"

ENV EMBER_VERSION=2.18.2 APP_DIR=/myapp

RUN apk add --no-cache \
  git && \
  yarn global add ember-cli@$EMBER_VERSION bower@latest && \
  mkdir -p $APP_DIR && \
  cd $APP_DIR

COPY ./docker/entrypoint.sh /entrypoint.sh

EXPOSE 4200 7357 8080 9222 7020
WORKDIR $APP_DIR
VOLUME [$APP_DIR]

CMD ["/entrypoint.sh"]

This will create a NodeJS image that has bower, yarn, and EmberJS. Now we are ready to build our docker-compose.yml file.

version: '3'

volumes:
  ember-bower_components:
  ember-node_modules:

services:
  ember:
    build: .
    container_name: ember-app
    ports:
      - 7357:7357
      - 4200:4200
      - 9222:9222
      - 49152:49152
    volumes:
      - .:/myapp
      - ember-bower_components:/myapp/bower_components
      - ember-node_modules:/myapp/node_modules
      - ./docker/entrypoint.sh:/entrypoint.sh
    tmpfs:
      - /myapp/tmp
    environment:
      - API_HOST=http://someapi
      - API_KEY=sdfdfdsfdsfdsfsdfsdfsdf
    command: ["sh", "/entrypoint.sh"]
  nginx:
    image: nginx:1.12.1-alpine
    container_name: nginx-app
    ports:
      - 8081:8080
    depends_on:
      - ember
    volumes:
      - ./docker/default.template:/etc/nginx/conf.d/default.template
      - ./dist:/usr/share/nginx/html:delegated
    environment:
      - SERVER_NAME=localhost
    command: /bin/sh -c "envsubst < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"

So this got the Mac and Windows guys working. They can run docker-compose up and get working on the code. If they needed to create a new component they just ran something like docker exec -it ember-app ember g component my-component. They continued to work just fine. So then I went fired up my Solus Linux and started it up. It worked just fine. So now I wanted to create a new component to test that out and it generated it. But when I opened the component and made some changes and hit save, I got a permission error.

So this is where I end this first part of the journey. Its now off to go figure a solution that will fix the Linux side, but also not break the Windows and Mac guys. So make sure to check back for part 2 that will talk about the solution I found. Any questions or comments, please leave a comment

Office Upgrade

So, when I moved into our new house 3 yrs ago, my only requirement was I have my own office. In my last house I was stuck in the basement. When I made videos, I would get the jokes about living in my moms basement. As you can see, all the cords where just all over the place. It was just so bad.

So after I had some back problems, I tied my hand at a standing desk at work. It was nice to have as it helped when my back go stiff. Then I started to work from home more often and at home I do not have one. So I decided it was time to get one. I ordered it and then I decided to re-arrange the office.

 

So not only did I get an motor operated one, I also decided it was time to hide the cables as well. So now its nicely tied and tucked away.

Image of how my Neovim looks like

My Switch to Neovim

For the longest time I have been hopping from editor to editor. I have used Notepad++, Sublime Text, Atom, and recently Visual Studio Code. I have known so many people who keep telling me to try and use Vim. They say you will love it. So, for the past 6 months I have been using Neovim. It has been a long challenge to not go back, but it is growing on me as an editor. Now I am not here to tell you that Vim is better than any other editor. I am not here to tell you that you should use it. I want to tell you why I enjoy using it and then you can make your own decision.

Neovim

So the hardest part for me in using vim/neovim was learning the keyboard shortcuts. If you are not a keyboard shortcut person, then using Vim is out of the question. I like to use them but never train myself in them so this is one of the first things I had to do. I had to start memorizing them. The problem I ran into was there was just way too many. Then a friend of mine told me that instead of just opening a help document and learning them all, he told me to learn a new command a week. He told me that when I find a new command to learn, write it on a sticky note and put it on my monitor. So that is what I did, I found that I was hitting w or e to get to the beginning or ending of a line. So the first command set that I need helping getting into muscle memory was Shift+I and Shift+A.

So as I was watching others on YouTube and reading articles, they recommend learning h,j,k,land to do so they recommended, https://vim-adventures.com/. So I did that and learned to become a master of those keys. Man did that save my fingers so much. So then I had to train myself to not use the arrow keys to move. To do this, in my vimrc I put in a snippet to echo “Stop being stupid!”, thanks Nick Nisi.

The other big mistake I made when I first started to learn vim, was to use someone elses vimrc verbatim. You should never ever do this, ever. You should start off with an empty or bare essential vimrc. Then when things are not what you need it to be, then add it to your vimrc. When I first started I did this and man it made things so confusing. Half of the plugins, I never used, others caused weird behavior that I was not expecting. So after awhile. So soon I ended up with my Neovim/vim look like this:

Image of how my Neovim looks like

So if you want to look over my vimrc, you may do so but remember, don’t just copy it and use it as your own as it may not be what you need. Take pieces of it. Any questions, please comment below and I will try to answer them

Site Upgraded

Its been a long time and I figured I should log in and see what needs to be upgraded. So I updated all the plugins and I even upgraded to WordPress 4.8. Working on my next tutorial, so keep an eye out for it

Dotfiles

Setting up a new computer can be a tedious and tiresome process. I am not the person that has an exact image of my machine, so when things go wrong I just load that image. I would never have something like that because when I am ready to re-install, I want to start as clean as possible.

At some point I went ahead and starting backing up my dotfiles in Github. This starting to make things easier but it was still a problem. I still had to install all the apps I needed to do things. Then the problem was, what and how do I install these things again. So then I watched a video by another developer by the name of Nick Nisi. He built a script to not only get his dotfiles but also it started moving things to where they need to be. Take a look at the video below where I talk a little more about this topic. You can view my current dotfiles here.

Elementary OS

So some of my Twitter followers have started to talk up, using a Linux OS called ElementaryOS. Its suppose to give you the look and feel of OSX. So after some many tweets, I have decided to install this in Virtualbox and give this a look over to see if its possible to replace my Windows/Mac environment. I have used Linux before, mostly and Arch/Ubuntu guy. So lets dig in and talk about some of things I liked and disliked.

Installer

As soon as the GUI came up for the installer I could feel the Ubuntu. Now there is nothing wrong with this at all. The install went very smooth and had no issues going through it

Playing Around

Got to say after logging in, I really liked the look. You can instantly tell that this is a nicely themed Gnome desktop manager. I love the keyboard remapping to open the application menu to Win key + spacebar. The dock at the bottom makes it look like a Mac desktop

Terminal

I really like the font and theme of the terminal application.

A picture of the terminal on Elementary OS
A nice transparent terminal with nice looking fonts

The Ugly

So there were some ugly things that came up The performance in Virtualbox was not good at all. Maybe this OS is just destine to not be virtualized.

The Verdict

I want to install this as a main OS and try to drive this and see how it goes. It has potential but really want to see how it works when you have a retina and non-retina display. That has been my biggest issue with all Linux distro. The support for multiple different DPI screens is a challenge to work with