YADI ROSADI

Programming, Linux and Anything

Hi,I'm Yadi Rosadi

Full-time Operation & part-time software developer. I do what im Interest for fun and profit

Up and Running a Ruby on Rails App with Docker on Centos 7

Docker Compose is a amazing tool for manage and running multi-container docker applications. it’s allow you to easily encapsulated your ruby on rails environment including database inside container. This tutorial will guide you through how to up and running a Ruby on Rails application with a Postgres inside a container.

In this tutorial i’m using docker version version 18.06.0-ce and docker-compose version version 1.22.0. You should have basic knowledge about it before continuing to the next step.

Getting Started

Create new project folder and cd into it. We will create new rails project with rails new, before running it, we need to create Dockerfile first

$ mkdir -p ~/Workspace/rails-docker
$ cd ~/Workspace/rails-docker
$ vi Dockerfile

and define basic environment in it.

FROM ruby:2.5-alpine

RUN apk update && apk add build-base postgresql-dev

RUN mkdir /app
WORKDIR /app

COPY Gemfile Gemfile.lock ./
RUN bundle install --binstubs

COPY . .

CMD puma -C config/puma.rb


Fixing Error when Generating Release with Reltool

I found this blog which describe how to build erlang project using rebar and then generating release with reltool : http://alancastro.org/2010/05/01/erlang-application-management-with-rebar.html. I’m following step by step and everything goes smoothly until the step when trying to run the release with reltool. I had got stuck during release generation, this error occours when i run command service with console sh mysample/bin/mysample console

{"init terminating in do_boot",{'cannot load',elf_format,get_files}}

Crash dump is being written to: erl_crash.dump...done
init terminating in do_boot ()

Read More >>


Fix Default Port(40000) Busy on Phoenix

If you have problem experienced when you run phoenix server and got error like this [error] Failed to start Ranch listener CoWall.Endpoint.HTTP in :ranch_tcp:listen([port: 4000]) for reason :eaddrinuse (address already in use) . It’s mean that, the default port(4000) has reserved with another process, so you need to release it or use another port.

If you want to known which process is listening on this port You can use this linux cmd lsof -i :4000 to find out more, See this article for examples: http://www.cyberciti.biz/faq/what-process-has-open-linux-port/. Below is the example one.


(erlang-1802)[yrsdi@mac co_wall]$ lsof -i :4000
COMMAND    PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
Google     274 yrsdi  103u  IPv4 0xa174d9f2406034c5      0t0  TCP localhost:54543->localhost:terabase (ESTABLISHED)
beam.smp  7640 yrsdi   20u  IPv4 0xa174d9f2438e60e5      0t0  TCP *:terabase (LISTEN)
beam.smp  7640 yrsdi   25u  IPv4 0xa174d9f2443e7bcd      0t0  TCP localhost:terabase->localhost:54543 (ESTABLISHED)

Use another port

$ PORT=4001 mix phoenix.server

or release it


$ kill -9 <PID>


Install & Setting up Elixir Environment

Introduction

Programming languages regularly release new versions. As a developer, I need to try that version without breaking our existing application in our local environment. The solution is using the version manager tool. version manager helps developers switch between versions easily, several languages have version managers (like SDKman for Java, NVM for Node.js, or Rbenv/RVM for Ruby, etc).

Too many tools in our local environment is another obstacle. in my case, I need one tool that can be handling multiple programming languages in multiple versions. so my choice is ASDF.

In this tutorial, you’ll learn how to install specific versions of Erlang/OTP and Elixir and use the ASDF as version manager.

Install asdf

asdf is a version manager tool that supports various programming languages including Ruby, Node.js, Erlang, Elixir and more. Before install asdf you need to install the curl and git utilities as prerequisites.

$ brew install coreutils curl git  # on macOS with Homebrew
$ sudo apt install curl git        # on Linux

After the prerequisites installed, now ready to install the ASDF:

$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf

Depending on your OS, in this guide I use OSX. if you are using OSX, open ~/.bash_profile and put this path. If you are on linux, put on ~/.bashrc

Read More >>


How to fix 'mix local.hex' failed

** (MatchError) no match of right hand side value: {:error, {:ssl, {'no such file or directory', 'ssl.app'}}}
    (mix) lib/mix/utils.ex:409: Mix.Utils.read_httpc/1
    (mix) lib/mix/utils.ex:354: Mix.Utils.read_path/2
    (mix) lib/mix/local.ex:107: Mix.Local.read_path!/2
    (mix) lib/mix/local.ex:86: Mix.Local.find_matching_versions_from_signed_csv!/2
    (mix) lib/mix/tasks/local.hex.ex:23: Mix.Tasks.Local.Hex.run/1
    (mix) lib/mix/dep/loader.ex:140: Mix.Dep.Loader.with_scm_and_app/4
    (mix) lib/mix/dep/loader.ex:98: Mix.Dep.Loader.to_dep/3
    (elixir) lib/enum.ex:1043: anonymous fn/3 in Enum.map/2
%

If you use version manager like kerl for installing erlang system, you need to re-configure openssl to add full path of it. in this case I build new erlang version and set openssl to kerl config

$ KERL_CONFIGURE_OPTIONS="--with-ssl=/usr/local/opt/openssl" kerl build 18.2 erlang-1802

Resosource : http://quabr.com/35170911/mix-deps-get-failed-seems-missing-ssl


Install & Setup Local Erlang Environment with Kerl on Mac OS X

To install erlang on Mac OSX is so easier, you just go to download from this site and installing it by one click or using homebrew by using brew install erlang command and tada your erlang will live on your system. But Installing by using it. It will force you to have only one version of the language to use at any point in time, when you need a specific language version of erlang for one of your projects, you will have to break. Versioned language management is the way to avoid the hassle of it.

Kerl is a versioned management tool to building and installing of Erlang/OTP instances. Here are Prerequisites, before installing it on Mac OS X.

  • XCode Developer Tools
  • Homebrew – Package Manager

Read More >>


Scastie - Online Tool untuk Debugging Scala code

Scastie adalah Scala pastebin yang merupakan salah satu tool yang bisa jadi pilihan untuk mendebug code scala secara online. Fitur-fiturnyapun cukup lengkap untuk keperluan debbuging. salah satu fiturnya adalah realtime update pada saat copy paste code, dan running code, memungkinkan untuk menghapus dan cloning paste, memungkinkan untuk menentukan versi scala, menyediakan beberapa template yang berguna (misalnya scalaz, Akka, bermain, scala 2.10) untuk lengkapnya bisa dibaca https://github.com/OlegYch/scastie

Read More >>