Hacking your workflow
Â
How to achieve more efficient web development sessions
Inconsistency & lack of proper automation cost
working hours = $$$
Sources:
Vagrant is free and open-source software for creating and configuring virtual development environments. It can be seen as a wrapper around virtualization software such as VirtualBox, KVM, VMware and around configuration management software such as Chef, Salt or Puppet
$ vagrant init hashicorp/precise32
$ vagrant up # provision
$ vagrant ssh
$ vagrant halt
$ vagrant destroy
Vagrant in the cloud
https://www.vagrantup.com
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu/trusty64"
# forwarded ports
config.vm.network "forwarded_port", guest: 80, host: 8080
# IP configuration
config.vm.network "private_network", ip: "192.168.6.66"
# Shared folders
config.vm.synced_folder "../blog", "/var/www/blog"
config.vm.synced_folder "./", "/opt/puppet-repo"
# Provider-specific configuration
# VirtualBox:
config.vm.provider "virtualbox" do |vb|
# Give the box 1GB RAM
vb.customize ["modifyvm", :id, "--memory", "1024"]
# 2 CPUs
vb.customize ["modifyvm", :id, "--cpus", "2"]
# Enable following symlinks
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
end
Consistency between local development & production server
Ability to use the same provisioning recipes on production
Prevents from bloating the host OS with many services
Production server changes can be tested locally before being destroying production
Provisioner with a simple scripting language
class system-update {
exec { 'apt-get update':
command => 'apt-get update',
}
package { 'git':
ensure => "installed",
require => Exec['apt-get update'],
}
}
Standalone or with agent
Source Control Management tool
http://git-scm.com/
I'm happy you're enjoying your simple workflow but...
Getting started
Exhibit A: Building the new facebook
$ git init
$ git remote add origin [email protected]:falexandrou/new-facebook-soon-to-be-billionaire
$ git add --all .
$ git commit -m "Initial commit - New facebook done, waiting to become a legend"
$ git push origin master
$ git clone [email protected]:employee-one/new-facebook-soon-to-be-billionaire worst-idea-ever
$ git remote add upstream [email protected]:falexandrou/new-facebook-soon-to-be-billionaire
$ git checkout upstream/master -b my-branch
$ git fetch upstream
$ vim NewFacebook.js
$ git commit -am "I still think this is a terrible idea"
$ git push origin master
Employee joins, nobody knows why
Branching
$ git checkout origin/master -b my-feature-branch
$ git br -m my-awesome-branch
$ git br -D my-older-branch
$ git checkout ab32bcff2da -b my-branch-from-commit
Submodules
$ git submodule add [email protected]:falexandrou/my-git-submodule
$ git update --init --recursive
Stash
$ git status
modified: src/less/some-file.less
$ git stash
Saved working directory and index state WIP on master: abc12345 fixes
$ git status
nothing to commit, working directory clean
$ git stash pop
modified: src/less/some-file.less
Dropped refs/stash@{0} (64ffabe91f396d6deafa777c8cbbecf7059c26c6b)
$ git status
$ git diff
$ git add --all .
$ git commit -m "Some commit message"
$ git push origin branch-name
...then probably open a "Pull Request"
FROM ubuntu
MAINTAINER Fotis Alexandrou <[email protected]>
# Update aptitude
RUN apt-get update
# Install assuming "yes" to prompts
RUN apt-get install -y nodejs
# Create our document root file
RUN mkdir /var/www
# Add the node.js app file
ADD app.js /var/www/app.js
# Run the server
CMD ["/usr/bin/node", "/var/www/app.js"]
Twitter: @falexandrou
GitHub: @falexandrou
https://www.falexandrou.com