boot2docker: Configure boot2docker terminal console with ConEmu

Tags

,

First, download the ConEmu installer at Github.
e.g. https://github.com/Maximus5/ConEmu/releases/download/v16.12.06/ConEmuSetup.161206.exe

Configure ConEmu:
In menu, click the Settings->Startup->Tasks.
Add a predefined task by clicking the + button.
Follow the information below:

Name: Boot2Docker
Task parameters:
/dir "C:\Program Files\Boot2Docker for Windows"
Commands:
"-new_console:C:c:\Program Files\Boot2Docker for Windows\boot2docker.ico" -new_console:n -new_console:t:Boot2Docker "-new_console:d:C:\Program Files\Boot2Docker for Windows" "%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "c:\Program Files\Boot2Docker for Windows\start.sh"

Note: Please check the directory path and modify them according to your system.
That’s it.

Docker: How to install docker machine in Windows

Tags

,

If you are running with Windows with git bash:

## change to root directory
$ cd ~  
$ if [[ ! -d "$HOME/bin" ]]; then mkdir -p "$HOME/bin"; fi && \
curl -L https://github.com/docker/machine/releases/download/v0.12.2/docker-machine-Windows-x86_64.exe > "$HOME/bin/docker-machine.exe" && \
chmod +x "$HOME/bin/docker-machine.exe"

Test the docker machine if it works

$ docker-machine --version
docker-machine.exe version 0.12.2, build 9371605

If it is working then let’s create our first docker machine name ‘dev’

$ docker-machine create --driver virtualbox dev
Creating CA: C:\Users\hax0r\.docker\machine\certs\ca.pem
Creating client certificate: C:\Users\hax0r\.docker\machine\certs\cert.pem
Running pre-create checks...
(dev) You are using version 4.3.28r100309 of VirtualBox. If you encounter issues, you might want to upgrade to version 5 at https://www.virtualbox.org
(dev) Image cache directory does not exist, creating it at C:\Users\hax0r\.docker\machine\cache...
(dev) No default Boot2Docker ISO found locally, downloading the latest release...
(dev) Latest release for github.com/boot2docker/boot2docker is v17.06.0-ce
(dev) Downloading C:\Users\hax0r\.docker\machine\cache\boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v17.06.0-ce/boot2docker.iso...
(dev) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(dev) Copying C:\Users\hax0r\.docker\machine\cache\boot2docker.iso to C:\Users\hax0r\.docker\machine\machines\dev\boot2docker.iso...
(dev) Creating VirtualBox VM...
(dev) Creating SSH key...
(dev) Starting the VM...
(dev) Check network to re-create if needed...
(dev) Windows might ask for the permission to create a network adapter. Sometimes, such confirmation window is minimized in the taskbar.
(dev) Found a new host-only adapter: "VirtualBox Host-Only Ethernet Adapter #3"
(dev) Windows might ask for the permission to configure a network adapter. Sometimes, such confirmation window is minimized in the taskbar.
(dev) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(dev) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: C:\Users\hax0r\bin\docker-machine.exe env dev

Next, login into a machine with ssh

$ docker-machine ssh

Heroku: Install heroku cli on Windows using npm

Tags

$ npm install -g heroku-cli
$ heroku --version
$ heroku login
Enter your Heroku credentials:
Email: sudogem@gmail.com
Password: ******************
Logged in as sudogem@gmail.com

$ ls -alh ~/.ssh
-rw-r--r-- 1 Arman Ortega 197121 1.2k Jul  3 22:00 id_boot2docker
-rw-r--r-- 1 Arman Ortega 197121  501 Jul  3 22:00 id_boot2docker.pub
-rw-r--r-- 1 Arman Ortega 197121 1.7K Jul  3 22:00 id_rsa_heroku
-rw-r--r-- 1 Arman Ortega 197121  407 Jul  3 22:00 id_rsa_heroku.pub
# We've found an existing ssh key for Heroku that we can use.

$ cat ~/.ssh/id_rsa_heroku.pub
ssh-rsa AAAAB3NzaC1yc....

$ heroku keys:add ~/.ssh/id_rsa_heroku.pub
Uploading C:/Users/armano/.ssh/id_rsa_heroku.pub SSH key... done

# Let's validate the connection
$ ssh -v git@heroku.com
...
...
debug1: Offering RSA public key: /c/Users/armano/.ssh/id_rsa_heroku
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to heroku.com ([50.19.85.132]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
PTY allocation request failed on channel 0
shell request failed on channel 0

Note: When executing the command just use Windows Command Prompt or cmder.

Git: Setup multiple github account on same environment/machine

Tags

Assume that we’ve already created a git repo

## Need to update the ssh config, see below:
$ vi ~/.ssh/config

# github account
Host *github.com   
  User git
  IdentityFile ~/.ssh/id_rsa_sudogem-github

# another github account
Host *github-slashd0t
  Hostname github.com
  User git
  IdentityFile ~/.ssh/id_rsa_slashd0t

Take note on the HOST ALIAS “github-slashd0t”.
## From your root directory of the project, we’ll add the origin of the repo

$ git remote add origin git@github-slashd0t:slashd0t/docker-mysql57.git

If there’s an existing remote origin, we’ll going to remove it and once its done..add it again.

$ git remote rm origin

## Set local git user & email for that repo

$ git config user.name "slash d0t" && git config user.email d3v0ps00001@gmail.com

## Test the ssh connection if it is using the correct git user.

$ ssh -vT git@github-slashd0t
....
....
Hi slashd0t! You've successfully authenticated, but GitHub does not provide shell access.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
....
....

https://code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts–net-22574

OpenShift: rhc commands

Tags

To list all openshift apps
rhc apps

$ rhc apps
angularApp @ http://angularApp-myusername.rhcloud.com/ (uuid: abc33456qwerty78900abce)
--------------------------------------------------------------------------
  Domain:     myusername
  Created:    Jun 26  8:28 PM
  Gears:      1 (defaults to small)
  Git URL:    ssh://abc33456qwerty78900abce@angularApp-myusername.rhcloud.com/~/git/angularApp.git/
  SSH:        abc33456qwerty78900abce@angularApp-myusername.rhcloud.com
  Deployment: auto (on git push)

  icflorescu-nodejs-8.1.2 (Node.js Auto-Updating)
  -----------------------------------------------
    From:    https://raw.githubusercontent.com/icflorescu/openshift-cartridge-nodejs/master/metadata/manifest.yml
    Website: http://www.nodejs.org/
    Gears:   1 small

railsApp @ http://railsApp-myusername.rhcloud.com/ (uuid: abc123456efbdced789011bacde)
--------------------------------------------------------------------------
  Domain:     myusername
  Created:    May 30  6:39 PM
  Gears:      1 (defaults to small)
  Git URL:    ssh://abc123456efbdced789011bacde@railsApp-myusername.rhcloud.com/~/git/railsApp.git/
  SSH:        abc123456efbdced789011bacde@railsApp-myusername.rhcloud.com
  Deployment: auto (on git push)

  ruby-2.0 (Ruby 2.0)
  -------------------
    Gears: Located with mysql-5.5, phpmyadmin-4

  mysql-5.5 (MySQL 5.5)
  ---------------------
    Gears:          Located with ruby-2.0, phpmyadmin-4
    Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/
    Database Name:  abcd
    Password:       qwerty
    Username:       asdf

  phpmyadmin-4 (phpMyAdmin 4.0)
  -----------------------------
    Gears:          Located with ruby-2.0, mysql-5.5
    Connection URL: https://railsApp-myusername.rhcloud.com/phpmyadmin/

To list all environment variables.
rhc env-list {APPNAME}

$ rhc env-list mywebapp
OPENSHIFT_MYSQL_DB_DBNAME=mywebapp

To set the environment variable.
rhc env-set OPENSHIFT_MYSQL_DB_DBNAME={MYSQLDBNAME} –app {MYAPPNAME}

$ rhc env-set OPENSHIFT_MYSQL_DB_DBNAME=tweetblog --app mywebapp

rhc tail -a {APPNAME}

Github API

Tags

Github API
complete reference: https://developer.github.com/enterprise/2.4/v3/

============================
Possible Triggers
============================
Any new issue
-triggers everytime any new issue is opened in a repository you own/collaborate on.
opt_type=ISSUES

Any closed issue
-triggers everytime any issue is closed in a repo you own/collaborate on.

New issue assigned to you
-triggers everytime a new issue is assigned to you.

New repository by a specific username or organization
-triggers everytime a new repository is created by the username or organization you specify.

Any new gist
-triggers everytime new snippets is created/updated

Any published release event
-triggers when a release is published.

Any pull request event
-triggers when a pull request is assigned, unassigned, labeled, unlabeled, opened, closed, reopened, or synchronized.
opt_type=PULL_REQUEST

Any push event
-triggers everytime a repo branch is pushed to.
opt_type=PUSH

Starred a repository
-triggers everytime a user stars a repo.
opt_type=WATCH

============================
Possible Actions
============================
Issues
* Create/Read/Update an issue
Any user with pull access to a repository can create an issue.

Repositories
* Create/Read/Update/Delete a repository
Create a new repository for the authenticated user.

* Create/Read/Update/Delete a release
Users with push access to the repository can create a release.

* Create/Read/Update/Delete a commit comment
* Create/Read/Update/Delete a file
This method creates a new file in a repository

* Create a fork
Create a fork for the authenticated user.

Git Data
* Create a blob
Supported encoding: “utf-8” and “base64”. Default: “utf-8”.
* Create a commit
* Create a Tag Object

Gist
* Create/Read/Update/Delete a gist
* Star/Unstar a gist

Organization
* Create/Read/Update/Delete a team
In order to create a team, the authenticated user must be a member of :org

* Add/Remove team member
In order to add a user to a team, the authenticated user must have‘admin’ permissions to the team or be an owner of the organization that the team is associated with,
and the user being added must already be a member of atleast one other team on the same organization.

* Add/Remove team repository
In order to add a repository to a team, the authenticated user must be anowner of the org that the team is associated with.
Also, the repository mustbe owned by the organization, or a direct fork of a repository owned by theorganization.

Pull Request
* Create/Read/Update a pull request

CREATE monitoring
curl -X POST http://localhost:3010/api/monitor/ \
-H “Content-Type: application/json” \
-d ‘{ “recipeId” : “7af2ecfdee0909096564a36af31c55e9”, “token”: “0e98ec3cb08ba332a2ec9aaf16813ece46fe8fcf”, “repo”: “test”, “owner”: “ortegaaa”, “event”: “watch” }’

DELETE monitoring
curl -X DELETE http://localhost:3010/api/monitor/ \
-H “Content-Type: application/json” \
-d ‘{ “token”: “0e98ec3cb08ba332a2ec9aaf16813ece46fe8fcf”, “webhookUrl”: “https://github.com/api/v3/repos/ortegaaa/test/hooks/102205” }’

How to deploy Node.js app using IBM Bluemix DevOps

Tags

How to deploy Node.js apps using IBM Bluemix DevOps
1. Create Cloud Foundry App -> Select Cloud Foundry Apps -> Select SDK for Node.js
2. Once the app was successfully created look for the Git repo and checkout it to your local machine.
3. To check the Git repo go to https://git.ng.bluemix.net/dashboard/projects
4. Checkout the source code and modified it. The source code contains a minimal boilerplate Node.js code.
5. Test it locally and once it works in your local then it is good to push to master branch.
6. On executing the git push command, the Bluemix will auto-deploy your app.

How to check the progress of your Build
1. Go to Services menu -> Click DevOps menu
2. Go to Pipelines -> then select the pipeline that you want to see. That’s it!

Docker common problems and its solution

Tags

Problem: When running any docker command, the error below is printed

$ docker version

Client:
Version: 1.12.0-rc3
API version: 1.24
Go version: go1.6.2
Git commit: 91e29e8
Built: Sat Jul 2 00:17:11 2016
OS/Arch: windows/amd64
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version: open //./pipe/docker_engine: The system cannot find the file specified.

$ docker ps -a

An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json?all=1: open //./pipe/docker_engine: The system cannot find the file specified.

Solution:
We need to configure the shell to be able to execute docker commands.

webdev@localhost ~
$ docker-machine env

export DOCKER_TLS_VERIFY=”1″
export DOCKER_HOST=”tcp://192.168.99.100:2376″
export DOCKER_CERT_PATH=”C:\Users\webdev\.docker\machine\machines\default”
export DOCKER_MACHINE_NAME=”default”
# Run this command to configure your shell:
# eval $(“C:\Program Files\Docker Toolbox\docker-machine.exe” env)
For cmd, use this command:

eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)

For cygwin, use this command:

$ eval $("C:/Program Files/Docker Toolbox/docker-machine.exe" env default)

For set permanent variable easily:
1.Right-click on the Windows Button
2.Select System, from the menu.
3.From there, select “Advanced system settings” → “Environment Variables”
4.Under the System Variables section, add all variables displayed when you ran the command: docker-machine env