03 Repeatable Dev Environments
03 Repeatable Dev Environments
Repeatable Development
Environments Visual Studio Code
Instructor:
John J Rofrano
Senior Technical Staff Member | DevOps Champion
IBM T.J. Watson Research Center
rofrano@cs.nyu.edu (@JohnRofrano)
1
@JohnRofrano
DevOps Principle of the Day:
“AUTOMATE EVERYTHING!”
Even the Development Team !!!
@JohnRofrano 2
Infrastructure as Code
Objectives
The objectives of this class are to:
- How to create customized
development environments with
Docker and Visual Studio Code
- Discuss other IaC tools for developers
- How to leverage Docker containers for
middleware deployment
- How to make your DevOps team
more productive
@JohnRofrano 3
Infrastructure as Code
• For each lab you will need to close the GitHub repo and change directory (cd) into it and
then start Visual Studio Code telling it to open the current directory (code .)
@JohnRofrano 4
Infrastructure as Code
@JohnRofrano 5
Infrastructure as Code
The Goal is
to Avoid
This
@JohnRofrano 6
Infrastructure as Code
What is Infrastructure?
@JohnRofrano 9
Infrastructure as Code
What is Infrastructure?
@JohnRofrano 10
Infrastructure as Code
@JohnRofrano 11
fi
fi
fi
Infrastructure as Code
Virtual
Machines?
@JohnRofrano 12
Infrastructure as Code 6 Core CPU
Keyboard & Mouse
Physical
Machines
32 GB Memory (RAM)
Before you can
understand Virtual
Machines you must Video Card (GPU)
understand Physical
Machines
Computer Motherboard
@JohnRofrano 13
Infrastructure as Code
HARDWARE
Physical Machine
@JohnRofrano 14
Infrastructure as Code
VirtualBox
@JohnRofrano 16
Infrastructure as Code
Do have the correct version Libraries and Frameworks (J2EE, Flask, Rails, .Net Framework)
of .Net Framework?
Do have the correct version Language Runtimes (Java, Python, Ruby, C#)
of C#?
@JohnRofrano 17
Infrastructure as Code
Software
Stack for
This Class
Our Microservice Application
@JohnRofrano 18
Infrastructure as Code
What is Vagrant?
@JohnRofrano 19
fi
Infrastructure as Code
@JohnRofrano 20
fi
Infrastructure as Code
Example
Vagrantfile
This will create:
Ubuntu 20.04 VM
2 CPUs
2 GB memory
Network IP address
Forward port 8080
Install git, python, and
pip
@JohnRofrano 21
Infrastructure as Code
Where did
ubuntu/ https://app.vagrantup.com/boxes/search
focal64
come
from?
@JohnRofrano 22
Infrastructure as Code
What is
Docker?
@JohnRofrano 23
Infrastructure as Code
What is Docker?
@JohnRofrano 25
Infrastructure as Code
• Docker can take your entire Software Stack and package it into an Image from which you
can create Containers (like Tupperware for your code)
image
Debian Linux 11 (Operating System)
@JohnRofrano
26
Introduction to Docker
@JohnRofrano 27
Infrastructure as Code
Redis Container
Docker Daemon
Hypervisor (VirtualBox)
@JohnRofrano 28
Infrastructure as Code
Docker for
+
Development
@JohnRofrano 29
Infrastructure as Code
@JohnRofrano 30
fi
Infrastructure as Code
• Create a devcontainer.json, which describes how VS Code should start the container and
what to do after it connects
• Optionally create Dockerfile to make and persist changes to the dev container, such as
installation of new software
• Optionally con gure multiple containers through Docker Compose.
• As you make changes, build your dev container to ensure changes take effect
@JohnRofrano 31
fi
Infrastructure as Code
.devcontainer/
!"" devcontainer.json
• Simplest devcontainer.json le
{
"image": "mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12"
}
https://code.visualstudio.com/docs/remote/devcontainerjson-reference
@JohnRofrano 32
fi
fi
Infrastructure as Code
EXPOSE 8080
@JohnRofrano 33
fi
fi
Infrastructure as Code
@JohnRofrano 34
Infrastructure as Code
Start with Python image
Remote
Containers
Add required packages
Example
Dockerfile
Establish a non-root user with
password-less sudo privileges
@JohnRofrano 35
Infrastructure as Code
@JohnRofrano 36
fi
Infrastructure as Code
@JohnRofrano 37
fi
Infrastructure as Code
VSCode
Example
Docker Development container
Compose
file
docker-compose.yml
Database container
@JohnRofrano 38
Infrastructure as Code
@JohnRofrano 39
Infrastructure as Code
@JohnRofrano 40
Summit of Innovation
Sea of Technical Debt
@JohnRofrano 41
Infrastructure as Code
Hands-On
“live session”
@JohnRofrano 42
Infrastructure as Code
Summary
@JohnRofrano 43
fi