Week09
From Versioning to Deployment:
A Quick Dive into Conda, Git, and Docker
Piroon Jenjaroenpun, Man, PhD.
Cool terminal theme
MacOS
https://www.josean.com/posts/terminal-setup
Window WSL
https://blog.joaograssi.com/windows-subsystem-for-linux-with-
oh-my-zsh-conemu
Outline
• Conda: A package manager that simplifies the installation and management of
software dependencies, primarily for data science and machine learning.
• Git: A version control system that helps manage and track changes in code,
facilitating collaboration among developers.
• Docker: A platform for containerization that isolates applications and their
dependencies, ensuring consistent execution across different environments.
Basic of Conda
• Package, dependency and environment management
Package Dependent packages
Package
Package Dependent packages
• Conda quickly installs, runs and updates packages and their
dependencies.
https://conda.io/projects/conda/en/latest/index.html
5
Conda channel
• The locations where packages are stored.
• Conda will download the packages from channels and install them to
conda environment.
https://conda.io/projects/conda/en/latest/user-guide/concepts/environments.html
6
Conda channel
The installer
(conda/mamba)
Channels Environments
default
base
- Python
- Base package
Stored packages 7
Conda managing channels
Conda channels are the locations where packages are stored.
Conda environment
• a directory that contains a specific collection of conda packages that
you have installed.
• You can easily activate or deactivate environments
• You can easily add and remove bioinformatics package
https://conda.io/projects/conda/en/latest/user-guide/concepts/environments.html
9
Basic of conda environment
The installer
(conda/mamba)
Channels Environments
conda-forge
bioconda base samtools1.20
default High priority - Python - samtools v1.20
- Base package
samtools1.21
Low priority
- samtools v.1.21
Stored packages 10
Conda managing environments
Go to terminal
Basic of Git
Version Control System
A version control system that helps manage and track changes in code, facilitating
collaboration among developers.
Track History Work Together
Track changes Manage changes
Me You
V1.0.0
V1.0.0
V1.0.1
V1.0.1
V1.0.2
V1.0.2
Why GIT
• Free Version Control System
• Open Source
• Super Fast
• Scalable
• Cheap Branching/Merging
• All job descriptions for software developers should have
You will learn
• How to use GIT to track history?
• How to use Git for collaborative coding? Track and manage changes
Me You
V1.0.0
V1.0.1
V1.0.2
Install Git
• Debian/Ubuntu
For the latest stable version for your release of Debian/Ubuntu
$ apt-get install git
• macOS
Install homebrew if you don't already have it, then:
$ brew install git
https://git-scm.com/downloads
Configurating Git
Setting Setting Categories
• Name
System: the setting apply to all users in the
• Email current computer
• Default Editor
Global: the setting apply to all repositories of
• Line Ending the current user
Local: the setting apply to current repository
Git config
git config --global user.name "Piroon Jen"
git config --global user.email piroon.jen@mahidol.edu
git config --global core.editor "nano"
git config --global -e
Line Ending
WINDOWS macOS / Linux
abc\r\n abc\n
- \r = Carriage Return (CR) - \n = Line Feed (LF)
- \n = Line Feed (LF)
CR LF LF LF
true input
Windows macOS
Line Ending
• Window
git config --global core.autocrlf true
• macOS / Linux
git config --global core.autocrlf input
CR LF LF LF
true input
Windows macOS
Start to work with Git
$ mkdir git_test
$ cd git_test
$ git init
Git Workflow
Staging Area
add
Local directory
A special intermediate area .git directory
git add tao lion
Git Workflow
Staging Area Commit
• ID
• Message
add commit • Date/time
• Author
• Complete snapshot
Local directory
A special intermediate area .git directory
Review your change and make snapshot
git commit -m "add tao and lion"
Git Workflow
Staging Area
add commit
Local directory
A special intermediate area .git directory
git add tao
git commit -m "add wings to tao"
Git Workflow
Staging Area
add commit
Local directory
A special intermediate area .git directory
git add lion
git commit -m "remove lion"
Git store data
• Comporesses the content
• Doesn’t store duplicate content
.git directory
Real Example
Create tao and lion files
Real Example
Add tao and lion files to staging area
Git Workflow
Staging Area
add
Local directory
A special intermediate area .git directory
git add tao lion
Real Example
In case remove lion from staging area
Real Example
Re-add lion file to staging aear
Real Example
Commit tao and lion files and save snapshot in .git database
Both file still in staging area
Real Example
Check history
Real Example
Check history
Git Workflow
Staging Area Commit
• ID
• Message
add commit • Date/time
• Author
• Change history
Local directory
A special intermediate area .git directory • Complete snapshot
Review your change and make snapshot
git commit -m "add tao and lion"
Real Example
Modify tao by give it wings: git staging area show modified tao file
Real Example
Add the modified tao file into staging area and commit changes
Git Workflow
Staging Area
add commit
Local directory
A special intermediate area .git directory
git add tao
git commit -m "add wings to tao"
Real Example
Remove lion file in directory
Real Example
Apply the remove action to the staging area and commit the
removal of the 'lion' file.
Git Workflow
Staging Area
add commit
Local directory
A special intermediate area .git directory
git add lion
git commit -m "remove lion"
Real Example
Add tao and lion files to staging area
Real Example
Chang history
Git ignore
In case, you want to ignore files or folder from tracking system
Git ignore
In case, you want to ignore files or folder from tracking system
Git ignore
Git view log
Git view log
Unstaging files
Unstaging files
Unstaging files
Unstaging files
Discarding Local Changes
Discarding Local Changes
Restoring a File to an Earlier Version
Basic of Docker
In basic docker usage
• What is Docker
• Virtual Machines vs Containers
• Architecture of Docker
• How to use Docker
Docker is
• A platform for building, running, and shipping applications
Reasons
• One or more files missing
• Software version mismatch
• Different configuration settings
=/
Reasons
• One or more files missing
• Software version mismatch
• Different configuration settings
=
Docker run the same environment across
platform and machines
Virtual Machine vs Container
VIRTUAL MACHINE CONTAINER
An abstraction of a machine An isolated environment for
(physical hardware) running an application
Mac Machine
VirtualBox
Hypervisor VMware Container
Hyper-v (Window only)
Process / Application
VM VM VM
Docker Architecture
REST API
CLIENT SERVER or DOCKER ENGINE
Docker Hub
3 major parts:
1. Docker Host
2. Docker Client
3. Registry
Docker image and container
Docker Image:
• Definition: A Docker image is a lightweight, standalone,
and immutable package that includes everything needed
to run a piece of software, including the code, runtime,
libraries, environment variables, and configurations.
• State: Static (read-only).
• Purpose: Serves as a blueprint or template for creating
Docker containers.
Docker Container:
• Definition: A Docker container is an instance of a Docker
image. It is a runnable entity that is created from a Docker
image and can be started, stopped, and modified.
• State: Dynamic (read-write). Containers can run, pause,
and execute commands.
• Purpose: To run applications. Containers isolate the
application and its dependencies from the host system.
How to use Docker
• docker build
• Build from published image
• Build from Dockerfile
• docker images
• To list all available images
• docker push
• To push the image to registry (i.e. DockerHub)
• docker pull
• To pull the image back to local
• docker rmi
• To remove image from local
• docker run
• To run a Docker container
• Run with binding storage -v $PWD:$PWD -w $PWD
Assignments
• https://forms.gle/S7BGcqrcATkw6FCaA