Wednesday, January 1, 2020

Docker Commands

>docker ps
     list running containers (processes inside of docker) (docker status) (list of running apps)

>docker start/stop [first 3 chars of id, or all of it] or [name]

>docker run hello-world
    I didn't download it, but it automatically downloads it and starts it

>docker run -p 8081:80 nginx
    downloads and runs this web server on localhost:8081

>docker run -p 4000:4000 docs/docker.github.io
     gives you a local docs at localhost:4000, same as http://docs.docker.com/

>docker run -p 4000:4000 -it --name docs docs/docker.github.io
    --it is for interactive terminal which makes your command prompt able to kill the process (docker stop) when pressing ctrl-c.

>docker ps -a
     view all installed containers and their run status

>docker images
     view all downloaded images

View containers that are stopped (not visible using ps command):
>docker container ls -a

Use CLI window to view files in a running container:
>docker exec -it [container name] cmd
     this will give you a cmd prompt at root of the application in the container's file system

Save an image. I had created and started a container using VS 2019 just by adding docker support (right click on web project in solution explorer, Add/Docker support). It showed up in >docker ps and in >docker images. You can also use >docker container ls -a and you don't necessarily need the image id, you can use the ps and use the human readable value under the IMAGE column.
>docker save -o C:\Dev\Learning\Docker\CoreWebHelloWorld\image.tar 291a865d3b8a
     you have to use the image id, not container id, so go to >docker images to get the image id.


>docker load -i C:\Dev\Learning\Docker\CoreWebHelloWorld\image2.tar

Remove container.
>docker container rm [container id]

Docker Fundamentals

A docker image is a pre-packaged application or VM template.

Docker, the technology in 2 sentences:
    Container - like fast, lightweight virtual machines
    Docker - makes running apps inside containers easy

An image is like a stopped container or a template on how to build a container.

Workflow:
Write code > build > create (build) docker image > push to registry > start a container from the image and your app is now running.

You want to build your apps to avoid the "monolith" architecture. Modules within the app should be "microservices" or simply put, the app module pulled out of the monolith and placed into its own application architecture whether its a web service or console app and put into a container. That way if you want to update just step 4 of the Claim Payments orchestrator, we just have to deploy that one container and not anything else.

https://hub.docker.com/ - registry

Kubernetes
Orchestrates docker containers and nodes (like a load balancer for one of its many features)

Docker Desktop
Install:
https://hub.docker.com/?overlay=onboarding
Guide:
https://docs.docker.com/docker-for-windows/install/


Docker's Modernizing Traditional Apps program, put legacy apps into containers.
https://goto.docker.com/rs/929-FJL-178/images/SB_MTA_04.14.2017.pdf

Saturday, May 18, 2019

The Conceptual Model, the Key to Understanding Git

From Pluralsight course "How Git Works"
 
If you don't want to get into trouble, understand the conceptual model.
 
Layers:
Distributed revision control
Revision control system
Stupid content tracker
Persistent map (the core)
 
The entire object model:
Blobs
Trees
Commits
Annotated tags
 
A commit is a SHA'd object that stores the SHAs of trees and blobs as well as the parent commit, author and date and commit message.
 
A branch is just a reference to a commit. Nothing more.
 
HEAD is just a reference to a branch. Or a reference to a commit if you checked out a commit, in this case the HEAD is a detached HEAD.
 
Checkout changes HEAD to point to the branch being checked out, and the working area is changed to the files represented in the commit referenced in the branch object.
 
A tag is like a branch that doesn't move.
 
Detached HEAD:
Checkout any commit. Now you can work in a "detached way" like a spike. If you don't create a branch off a detached commit Git will garbage collect all the detached commits eventually.
 
Three Rules:
1) The current branch tracks new commits.
2) When you move to another commit, Git updates your working directory.
3) Unreachable objects (those that are not reachable via a branch, HEAD or a tag) are garbage collected.
 
Rebase:
When in doubt, just merge. Only rebase if you know what you're doing and are fully aware of any consequences.
 
 
 
Command reference:
git show-ref <branch>       this will show the contents of the branch file which is a reference to a commit but will show both the local branch and remote so you can see if there is a difference. If the commits are the same, then the local and remote are synchronized.
 
git cat-file -p <sha>
to show contents of a commit. Don’t need to be in the objects subdirectory.
But you do need to put the 2 char folder name as prefix to the file name
 

Monday, February 11, 2019

Git in Visual Studio 2017

Created new empty project in Git except for .gitignore file. No readme file was created.
Cloned in VStudio, and in master added a new test project.
The remote master history only shows the .gitignore add, as expected.
The local master history has same because no commits yet.
Now to commit and push to master by:
Commit All
Then switch to branches view and right click on local master and Push
This sent the new project to the remote master.
Created new local folder (VSGit2) for a second copy of VSGit repo, and cloned it from second instance of VS (we'll call this repo2 for this post)
Created a new branch "branchOne" of local master in repo1
Added a readme to remote master from GitHub interface and checked in to master. I verified this by viewing history in master from GitHub site.
But remote/master history from VS does not show the readme file.
 
Scenario:
Added a readme to remote master from GitHub interface.
Exercise: download and merge that readme file into local branchOne.
First lets bring down latest from remote/master to local master:
From local master, did a Fetch from VS. History now shows incoming readme.
Did a Pull, history now shows readme commit under "Local History."
And now VS remote master history shows the same thing.
branchOne does not have readme yet because that file was added to master in GitHub.
From merge dropdown/dialog, selected local master to merge to branchOne, unchecked commit.
Got a message saying I needed to commit. In changes area, I see the readme and I clicked "Commit Staged."
Scenario exercise completed.
 
branchOne is same now as local and remote master.
 
Moving to repo2, I do not see branchOne in remotes/origin, even after clicking refresh.
A history of remote/master does not show the readme commit.
 
Scenario:
repo1 now is up to date with master, now make repo2 up to date also, this time experimenting with the "Sync" functionality.
Exercise: Sync repo2 and see what happens, or "get latest"
Well, there is no Sync option.
Right-clicked on local master and Fetched. History now shows the incoming readme.
Pulled. History now shows readme, but no branchOne in local area. I do see it in remotes area.
Right clicked branchOne in remotes and selected "Checkout."
Now I see it in local. History does not show readme commit.
I could do a fetch and pull, but let's try a merge from local master which has all commits to local branchOne and keep commit checkbox checked.
Now readme file shows on file system and history shows all commits.
Scenario exercise completed.
 
History of remote/master shows all commits. I never had to fetch (I think, see above). I assume I could have or maybe should have. If so, then this merge and a fetch/pull does the same thing?
 
Scenario:
Bob (repo1) makes a change to branchOne's VSGitTestOne class. Then Bob commits and pushes and then creates a pull request that gets merged to master.
Meanwhile, Joe in repo2 has created a new local branch "feature1." Joe creates a new test class VsGitTestThree and commits locally only. 
Exercise: Joe in repo2 wants to keep working in feature1 but wants to merge Bob's work into his branch before continuing. So he must merge master into feature1.
Joe switches his local to master and fetches then pulls. History shows Bob's change and also the merge of his PR 3 to master.
Joe checks out feature1 branch and merges from master with commit after checked. feature1 history now shows all the master history plus its own commit of merge from local master.
Scenario exercise completed.
 
Bob and Joe are done with their branches.
 
Scenario:
Simulate Microsoft's release/deployment/hotfix branching strategy. See if this can be done without Azure.
Setup - release branch | PRx | hotfix PR | PRy and "cherry pick" merge of hotfix to release:
Bob and Joe are merged to remote master and it's the end of the sprint so let's create a release or deployment branch M1 off master:
In VStudio (didn't see how to do this in GitHub) did a fetch/pull on master to sync local from server. Then created branch releases/M1 w/ checkout. Then right clicked and Push Branch which brought it up to server.
Bob creates bobFeature1 branch off master and commits/pushes and pull requests to master.
An embarrassing typo is found and Bob creates bobTypo1 branch off master and fixes it, commits/pushes/pull requests, PR gets merged to master.
Joe creates joeFeature2 and commits/pushes/pull requests, PR gets merged to master. He does this without merging Bob's typo change, but there was no conflict during the pull request merge. (but somehow, Bob's typo change got into Joe's joeFeature2 branch. I didn't see when, maybe during the pull request?)
So now we have 3 PR's and we want to cherry pick the middle one into the M1 release branch.
 
 
 
from local branchOne, pull down that master change (new readme file)
While in branchOne, in Branches area in TS I pulled down the Merge link/dropdown and it brought up a merge dialog. In "Merge from branch:" box I selected local master. I got the message "Already up to date."
So I selected origin/master and unchecked "Commit changes after merging."
Again, "Already up to date."
Maybe merging
 
 
(no) I think the merge functionality is to merge between different branches, not the same branch.
 
Tried to create PR, but got "No commits between master and branchOne" which means nothing to merge into master from branchOne.
From local master, did a Fetch from VS. History now shows incoming readme.
Did a Pull, history now shows readme commit under "Local History."
And now VS remote master history shows the same thing.
 
 
Commit All - local only
Commit All and Push - local and push to remote
Commit All and Sync - local and push to remote and pull down any changes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Monday, October 31, 2016

Software in General Links

 
 
Happiness is a Boring Stack - C# SQL Server, etc doesn't break, but still keep up with the latest cool stuff.
 
 
 
 
 
 

Javascript Links

 
If you are new to JavaScript, start with the articles in the learning area and the JavaScript Guide. Once you have a firm grasp of the fundamentals, you can use the JavaScript Reference to get more details on individual objects and statements.
 
Getting st