INF397 Full Stack Technologies View Schedule Print

Development Processes

Principles:

Technologies:

Bash


    # Bash is a command prompt / shell

    #Get the current date and time
    date

    # get the current user name
    whoami # returns myName

    #Get the name of the current computer
    hostname #returns myServer

    #set an environment variable
    MY_VAR=value

    #print the value of an env. var
    echo $MY_VAR

    #set a global variable to the result of a command
    export MY_NAME=`whoami`

    #print the value of a var plus some text
    echo "my name is $MY_NAME"
  

Bash


    #get the current directory
    pwd #returns /usr/myName/

    # / (slash) is the root directory
    # ~ (tilda) is the user's home directory

    #The ls command takes a path
    #List files and directories in the root directory
    ls /

    #List all files in the user's directory as a list
    ls ~/ -al

    #Files and dirs begining with . (dot) are hidden
    #Print the file's name if it exists in the root directory
    ls /.hidden_file

    #Absolute paths begin with / (slash) and start from the root
    #Relative paths start from the current dir (or home dir with ~)
    ls /my_project #lists a dir under root
    ls my_project #lists a dir under the current dir
  

Bash


    # . (just dot) is the current directory
    # .. (double dot) is the parent directory
    # - (dash) is the last directory

    #Go to the root directory
    cd /

    #Go back to where you were before
    cd -

    #Go to the parent of the current dir
    cd ..

    #Go to a project under your home directory
    cd ~/my_project

    #Root is the parent of itself
    cd /../../../ #still in root
  

Bash


    #Create directory
    mkdir NAME

    #Copy files
    cp FILE1 FILE2 DESTINATION

    #move/rename file
    mv FILE1 FILE2 #renames FILE1 to FILE2

    #mv moves and renames file
    mv src/FILE1 dist/FILE2

    #delete files
    rm FILE1 FILE_N

    #delete directories with files inside
    rm -r DIR_NAME

    #use \ (backslach) to escape spaces in names
    cp my\ file\ name.txt myNewFileName
  

Bash


    #find text in a file
    grep "some text" FILE

    #Get currently running user processes
    ps

    #use | (pipe) to pass the output
    #of one process to another
    ps | grep "myApp"

    #use > (greater sign) to write the output to a file
    whoami > /my/path/user.txt

    #use >> (double greater sign) to append the output to a file
    cat todays_log >> combined_log

    #root is also the name of the super user
    #the sudo command runs commands as root
    #get processes started by the super user
    sudo ps

    #install python on debian/ubuntu
    sudo apt-get install python
  

SSH


    #Connect to a shell on another computer
    #ssh can use either passwords or crypto keys
    ssh USER@ADDRESS

    whoami #returns localUser
    hostname #returns myComputer
    #Your prompt should include user and host information

    #Use ssh to connect to another computer
    ssh remoteUser@remoteHost

    #We can now use bash on the remoteHost
    whoami #returns remoteUser
    hostname #returns remoteHost

    #Disconnect/Close the terminal
    exit #back to myComputer

    whoami #returns localUser
  

Docker: Overview

Package your application in a standardized containers

  • Container - lightweight process isolation mechanism
  • Dockerfile - container description as code
  • Docker CLI - shell commands
    • docker - build and manage containers
    • docker-machine - Virtual Machines for running docker
    • docker-compose - automate common docker commands

Containers vs Virtual Machines

Docker-Machine: shell commands


    #Check the version of docker-machine
    docker-machine --version

    #List locally available virtual machines
    docker-machine ls

    #Start a virtual machine
    docker-machine create -d virtualbox [NAME]

    #Start/Stop/Restart a virtual machine
    docker-machine start [NAME]
    docker-machine stop [NAME]
    docker-machine restart [NAME]

    #Delete a virtual machine
    docker-machine rm [NAME]

    #Connect to a virtual machine
    docker-machine ssh [NAME]

    #Apply a machine environment to your local git bash shell
    #You need to do this for your local docker to work
    eval $(docker-machine env [NAME])
  

Docker: shell commands


    #Check the version of docker and tools
    docker --version
    docker-compose --version

    #Get detailed information about docker
    docker info

    #List running containers
    docker ps

    #Lit both running and stopped containers
    docker ps -a

    #Run a container based on the hello-world image
    #This will download and run a hello world app inside a container
    docker run hello-world

    #Run a container exposing a port with -p host:container
    #This will download and run the nginx webserver inside a container
    #Exposing it on the VMs 6700 port
    docker run -p 6700:80 --name webserver nginx

    #Delete a container
    docker rm webserver

    #Build a container image based on ./Dockerfile
    docker build -t MY_APP_IMG .
  

Dockerfile


    #Select the base image for your application
    FROM node

    #Copy your project files to the container
    COPY my_app /

    #Execute commands in the container context
    RUN ["npm", "install"]
    RUN ["npm", "run", "build"]

    #Execute the main application process that will run in the container
    CMD ["node", "/server.js"]
  

Vagrant: Overview

Create and configure reproducible virtual machines

  • Boxes - Virtual Machine Templates
  • Provisioning - Setup Scripts
  • Vagrantfile - Configuration as ruby code
  • Vagrant CLI - shell commands

Vagrant: Client commands


    #Initialize a new Vagrantfile with examples and comments
    vagrant init

    #List locally available boxes
    vagrant box list

    #Start a virtual machine
    vagrant up

    #Stop a virtual machine
    vagrant halt

    #Restart a virtual machine
    vagrant reload [--provision]

    #Destroy a virtual machine
    vagrant destroy

    #Connect to a virtual machine
    vagrant ssh
  

Vagrantfile


    Vagrant.configure("2") do |config|
      config.vm.box = "ubuntu/trusty64"

      # Create a forwarded port mapping. In this example,
      # accessing "localhost:8080" will access port 80 on the guest machine.
      config.vm.network "forwarded_port", guest: 80, host: 8080

      # Create a private network access to the machine using a specific IP.
      config.vm.network "private_network", ip: "192.168.33.10"

      # Share an additional folder to the guest VM. The first argument is
      # the path on the host to the actual folder. The second argument is
      # the path on the guest to mount the folder.
      config.vm.synced_folder "../data", "/vagrant_data"

      config.vm.provider "virtualbox" do |vb|
         vb.memory = "1024"
      end

      # Enable provisioning with a shell script.
      config.vm.provision "shell", inline: <<-SHELL
          # install node js on the virtual machine
          sudo apt-get install -y curl
          curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
          sudo apt-get install -y nodejs
         SHELL
      end
  

Links:

Course Schedule:

week 1 03.02.2017 History of the web Fullstack Principles Development Processes Agile Processes DevOps Basics Git
week 2 10.02.2017 Frontend Overview Backend Overview Network Overview Testing JavaScript Overview JavaScript Tooling
week 3 17.02.2017 Web Architectures RESTful principles SOLID principles Web Components Continuous Integration
week 4 24.02.2017 Databases basics Using APIs Deployment Automation Monitoring In-class project consultations
week 5 17.03.2017 Project presentations
Final Test
Course Retrospective and Q&A