Getting SimpleCov-summary (0.0.5) to work with SimpleCov (0.16.1) and Rails 5.2

Standard

If you run into issues with installing simplecov-summary using:

Here’s how to fix it:

Since Rails 5 removed silence_stream because it is not thread-safe. I found implementations of silence_stream but I got it to work by just removing it completely and I prefer to see these outputs at the end of my test run.

Rails 5.2 Has And Belongs To Many with UUID

Standard

When using UUIDs and you are creating a join table like so:

You will get a migration file like so:

You’ll need to modify it accordingly:

Then run:

And you should be good. Just remember if you are using UUIDs you might want to make sure all models you generate use UUIDs.

In config/application.rb:

And make sure your generated migrations have:

Enjoy!

Installing Jira Software Server

Standard

Assuming you have downloaded from Atlassian. If not read how to prepare for installs.

Follow prompts and make sure you enable the service option if you want Jira Software to autostart on bootup.

If you installed using sudo it’ll place the app in dir: /opt/atlassian/jira, which is good.

Note these files in case you don’t want it to be installed as a service or if something happens.

Preparing a Server for Atlassian Software

Standard

I’ve been a user of Jira before the kanban “agile” interface and it was still one suite with an agile plugin. I use both Jira Core (“task”) and Jira Software (“agile”). I use Core for task based projects and Software for well software based projects.

I actually use Core for home projects like: my daughters 3rd birthday, remodeling the garage, gardening task like cloning my chili plant or gardenias. I have a project with multiple task and sub-task.

Given: I have an over powered media server running Ubuntu 18.04 and I have a need to track my personal task and projects. And I thought it would be a fun weekend project.

When: I install Atlassian’s Jira Software Server, Jira Core Server, and Confluence Server (I will be also installing Bamboo Server and BitBucket Server at a later time)

Then: I will have access to Jira for any task or project and I can track progress. I will have also learned how to manage and use Jira from another point of view. Not just moving features across and completing them.

Continue reading

Updating Ubuntu 17.10 to 18.04

Standard

If you need to upgrade your Ubuntu to a new release.

Wait a few minutes/hours, you should have upgraded your server.

New Rails Project On Clean System

Standard

Creating a new Rails project on a clean system.

Install iTerm2. *My terminal of choice.

Install Xcode and command line tools.

Install Homebrew.

Install OhMyZSH. *My preferred shell.

Install rvm or rbenv or docker.

I prefer to use rvm on my development system and/or docker, I moved over from vagrant and vmware fusion. I prefer rvm on my dev system over rbenv. But I prefer rbenv over rvm on production servers if i’m not using docker.

Using MyNewProject as the project name.

1. Create the working directory.

2. Create the Rails app.

3. Done

Use your favorite text editor. Mine is Sublime and Vi.

Development Environment with Rails

Standard

Currently, I favor development with Docker because of the ease of deployment. I see the benefits when in a team environment using Docker, onboarding is much easier. Similar to using virtual machines you have images with your development environment all set up but with docker (containers) the footprints are somewhat smaller. I say that because the standard ruby base image isn’t exactly a lightweight it’s still around 700MB+ in size. But you could use Alpine Linux base images for the surrounding services ie database, Redis, elastic search.

I have experienced a few development environments so I’ll go through and list my point of view. Note: nothing here is the absolute best or de facto, just what I’ve used in real-world development teams. 

Continue reading

Creating an image with A Dockerfile

Standard

The Dockerfile

Simply a file or manifest that has all the commands needed to be run to create an image when you run ‘docker build’. You can find more information here: Dockerfile docs

Simple Dockerfile

Just to keep it simple a Dockerfile can be as simple as installing packages after setting up a server and creating some directories. Here’s an example:

Here is a Dockerfile I used for a virtual host apache image:
https://github.com/mfung/alpine_apache2_php7

Commands

Some commands when dealing with building an image:

 

Using Docker-compose

Standard

Commands for docker-compose

You will need a YAML file that contains your stack.

Stack file

A little more complex example: https://gist.github.com/mfung/9b0fd65ccc793c7b1ec44dfb2deb370d

Install & Using Docker (OSX, CoreOS, Docker-CM, Alpine Linux, Docker-Compose)

Standard
I recently decided to consolidate some of my websites onto one server. I also wanted to https (SSL) most if not all my websites. Before I would use CentOS or Ubuntu and Nginx as a reverse proxy with Nginx/Passenger serving my Rails apps and Apache/PHP serving my WordPress/PHP sites. Here’s how I installed docker, docker-cm and started using containers on my production servers.

I’ve known about Docker and I’ve used it indirectly, a Rails app i worked on used it in production but it was abstracted from us software engineers. So I installed Docker-CM on both CentOS, Ubuntu, and Docker on OSX to experiment.

OSX: https://docs.docker.com/docker-for-mac/install/

 

After spinning up some containers and learning some Docker commands.

Docker Commands

 

I started to research minimalist Linux distros for the host OS. I only need to be able to run Docker-CM, maybe a firewall, and some other minimal software on it because the heavy lifting would be done in each of the containers. While doing that I learned about Alpine Linux for the container image. I was using CentOS and Ubuntu images at first and while looking at host images and file sizes I realized I can be more efficient with the containers as well.

Docker Images

REPOSITORY TAG SIZE (MB)
alpine latest 4.15
centos latest 207.0
ubuntu latest 111.0
busybox latest 1.14

Now why I didn’t use BusyBox instead of Alpine. I just found alpine and apk easy and familiar. And their motto is “Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busy box.” I like security, I like lightweight, and I like Linux.

With all this playing around and researching, I found docker-compose and read up on creating a Dockerfile. I also ran across some important images:

postgres:10.1-alpine
nginx:alpine
jrcs/letsencrypt-nginx-proxy-companion
jwilder/docker-gen
WordPress (there are different flavors of alpine, apache, and different versions of PHP)

What I wanted in my ecosystem is Postgres (Phoenix, Rails, and my goto DB), MySQL (for my WordPress sites), Redis, MongoDB + R, Nginx Proxy, Apache Virtual Hosting not just 1 instance of WordPress per container.

Next