0:00:24.900,0:00:29.920 VAMSEE KANAKALA: Hello everyone. Very good[br]afternoon. 0:00:29.920,0:00:32.880 I really enjoyed the lightning talks, thanks 0:00:32.880,0:00:37.800 everyone. And I hope you guys are slightly[br]awake. 0:00:37.800,0:00:41.960 So, this is slightly off the center topic,[br]so, 0:00:41.960,0:00:45.220 this is more about dev-ops rather than Ruby[br]or 0:00:45.220,0:00:46.620 Rails, per se. So I'd like to know who 0:00:46.620,0:00:51.620 all are already familiar with Docker, have[br]tried out 0:00:51.620,0:00:55.370 or just know what it does and stuff like 0:00:55.370,0:01:02.370 that. OK, not too many. Sorry about that.[br]So 0:01:02.909,0:01:05.760 I've been a web developer for eight, for quite 0:01:05.760,0:01:08.229 some time. And a good part of it is 0:01:08.229,0:01:12.000 Rails. Actually the, I actually remember the[br]days when 0:01:12.000,0:01:16.479 the fifteen minute video came out. So all[br]through 0:01:16.479,0:01:19.070 these years I have also kind of ended up 0:01:19.070,0:01:21.049 setting up servers for the Ruby teams that[br]I 0:01:21.049,0:01:25.619 worked with, and have been the Linux guy for 0:01:25.619,0:01:27.540 as long as I can remember, as in the 0:01:27.540,0:01:32.930 professional life of mine. And so I thought,[br]so 0:01:32.930,0:01:37.540 lately I've been observing what's happening[br]on the production 0:01:37.540,0:01:40.490 side of things, so I guess a bunch of 0:01:40.490,0:01:43.050 you- so how many of you have set up 0:01:43.050,0:01:48.040 your own Rails servers, maintained them? Oh,[br]quite a 0:01:48.040,0:01:50.210 few. OK. Then, this should be relevent to[br]what 0:01:50.210,0:01:53.210 you're doing. So the point of, so we're gonna 0:01:53.210,0:01:56.870 talk about zero downtime deployments with[br]Docker. So the 0:01:56.870,0:02:01.560 point of this is, so what is Docker? So 0:02:01.560,0:02:03.909 the first thing that Docker does is it basically 0:02:03.909,0:02:09.739 commoditizes LXC. LXC is Linux Containers.[br]So the containers, 0:02:09.739,0:02:14.230 you can think of them as something like chroot 0:02:14.230,0:02:17.280 jail, change root jail, you have in Linux.[br]So 0:02:17.280,0:02:19.790 what it, what it basically does is it gives 0:02:19.790,0:02:22.060 you a separate folder as a root, and you 0:02:22.060,0:02:25.620 can run off your processes from there, and[br]all 0:02:25.620,0:02:28.900 the children are only allowed to access that[br]part 0:02:28.900,0:02:33.269 of the directory, as a root directory. A container 0:02:33.269,0:02:38.439 extends this concept by giving you isolation[br]on the 0:02:38.439,0:02:40.989 memory level, it gives you isolation on network[br]level, 0:02:40.989,0:02:44.260 it gives you isolation on hard disk level.[br]So 0:02:44.260,0:02:51.260 LXC is a fairly old technology in Linux, but 0:02:51.340,0:02:54.599 it has been mostly in the realm of people 0:02:54.599,0:02:58.469 who understand Linux pretty well, or sysadmins[br]who are 0:02:58.469,0:03:01.549 trying to achieve something on the production[br]side. So 0:03:01.549,0:03:06.620 Docker basically makes this accessible to[br]all of us. 0:03:06.620,0:03:12.159 So it makes portable deployments across machines[br]possible, so 0:03:12.159,0:03:16.870 you can basically have, you have, I have,[br]suppose 0:03:16.870,0:03:21.239 a vagrant box, which runs Erlang?? [00:03:19][br]install, but 0:03:21.239,0:03:25.510 you can also, you can actually run production[br]systems, 0:03:25.510,0:03:29.150 production installs of, out of, say at 12[br]point 0:03:29.150,0:03:33.409 0 precise. So you get a lot of flexibility 0:03:33.409,0:03:38.950 of moving your production images around. So[br]there is 0:03:38.950,0:03:43.430 efficient and quick provisioning, so it saves[br]on a 0:03:43.430,0:03:46.549 disk, how much disk it uses, by doing copy-on-write 0:03:46.549,0:03:51.199 installs. I'll talk about it a little bit[br]later. 0:03:51.199,0:03:57.059 There's, it's near-native performance, it's[br]basically process virtualization. So 0:03:57.059,0:04:00.659 you're not, you're not doing hardware virtualization,[br]or, you're 0:04:00.659,0:04:04.189 not trying to support different OSs and stuff[br]like 0:04:04.189,0:04:08.169 that, so the way you, the speed at which 0:04:08.169,0:04:11.340 your Docker instant boots up is very quick.[br]So 0:04:11.340,0:04:15.739 you almost have no overhead at all. It also 0:04:15.739,0:04:20.339 has Git-like versioning of images. So you[br]have basically 0:04:20.339,0:04:23.460 a base image, which is Ubuntu, and you can 0:04:23.460,0:04:26.949 install something like emacs on it and you[br]can 0:04:26.949,0:04:29.440 commit it and it'll save it and it'll make 0:04:29.440,0:04:32.590 it into another image. Which'll also - I'll[br]show 0:04:32.590,0:04:34.850 you a little bit more about that. So that 0:04:34.850,0:04:39.240 enables a lot of reuse. So you can basically 0:04:39.240,0:04:43.280 push these images to a public depository that[br]Docker 0:04:43.280,0:04:46.800 maintains, index dot docker dot IO, so if[br]they're 0:04:46.800,0:04:50.440 public, if they're open for sharing, so you[br]can 0:04:50.440,0:04:53.139 push them out there and people can use your 0:04:53.139,0:04:58.650 own configuration how you, however you configured[br]your image. 0:04:58.650,0:05:03.409 And the major difference between how LXC operates,[br]or 0:05:03.409,0:05:07.090 how LXC is talked about and how Docker encourages 0:05:07.090,0:05:11.610 you to think about containers is that, so[br]LXC 0:05:11.610,0:05:17.310 was initially thought of as, you know, lightweight[br]servers, 0:05:17.310,0:05:19.960 which, where you install basically everything[br]and put them 0:05:19.960,0:05:22.500 up and treat them as, just like any other 0:05:22.500,0:05:25.759 server. Docker kind of encourages you to look[br]at 0:05:25.759,0:05:30.139 containers as an application. So you install,[br]say your 0:05:30.139,0:05:33.419 database mask in one container, you install[br]your app 0:05:33.419,0:05:38.110 server as another container, you install your,[br]your RDB, 0:05:38.110,0:05:45.110 you know, so, in another container. So, what[br]is 0:05:46.120,0:05:49.310 LXC? I actually wanted to take out this slide, 0:05:49.310,0:05:54.580 probably it's a little too advanced for this[br]talk. 0:05:54.580,0:05:57.479 But let - I'll try to cover this quickly. 0:05:57.479,0:06:01.680 So at the basic level, it provides OS-level[br]virtualization 0:06:01.680,0:06:06.210 for Linux. So compared to, say, what virtual[br]box 0:06:06.210,0:06:09.699 does for you, or KVM, or Zen, so these 0:06:09.699,0:06:14.520 are all hardware virtualization, so OS-level[br]virtualization - much 0:06:14.520,0:06:20.139 faster, much lightweight. Perfect for production[br]deployment, so. It 0:06:20.139,0:06:24.900 basically does this. So LXC basically provides[br]you one 0:06:24.900,0:06:29.439 process space, one network interface, and[br]your own init 0:06:29.439,0:06:32.900 framework. So your, you can be running on[br]Ubuntu, 0:06:32.900,0:06:37.560 which uses Upstart as- and your container[br]can use 0:06:37.560,0:06:41.159 systemD. That's not a problem at all. So the 0:06:41.159,0:06:44.389 basic isolation is achieved with cgroups.[br]Cgroups are control 0:06:44.389,0:06:49.509 groups. So what cgroups gives you is that[br]it 0:06:49.509,0:06:53.270 lets you put limits on the resource usage,[br]basically. 0:06:53.270,0:06:56.500 Whether it's network or off your disk or your 0:06:56.500,0:07:01.979 process usage, so cgroups gives you this nice[br]little 0:07:01.979,0:07:04.449 interface where you can do - this is definitely 0:07:04.449,0:07:06.280 the Linux geek- do not worry, you don't have 0:07:06.280,0:07:09.469 to worry about that. So the only catch is 0:07:09.469,0:07:12.560 that it shares the kernel with the host, so 0:07:12.560,0:07:16.069 you can do stuff like having an x64 image 0:07:16.069,0:07:20.310 and put it on i36 or vice versa. So 0:07:20.310,0:07:23.319 that's pretty much the only catch here and[br]it's 0:07:23.319,0:07:26.349 probably not very, not much of a catch at 0:07:26.349,0:07:29.030 all. So a typical docker image kind of looks 0:07:29.030,0:07:32.009 like this. At the most basic level you will 0:07:32.009,0:07:35.539 see the kernel, and you have cgroups, you[br]have 0:07:35.539,0:07:41.919 name spaces and device mapper. So Docker kind[br]of 0:07:41.919,0:07:45.909 achieves this git-like portioning through,[br]through a unioning file 0:07:45.909,0:07:52.490 system. Right now, debian-based installs use,[br]a UFS, which 0:07:52.490,0:07:55.249 is quite popular, but it has some limitations,[br]which 0:07:55.249,0:08:00.180 is, it's integrated into a debian kernel,[br]a debian-based 0:08:00.180,0:08:03.930 distros kernels, but it's not really available[br]in others, 0:08:03.930,0:08:06.469 like Santos and dev-hats ?? of the world.[br][00:08:06] 0:08:06.469,0:08:11.110 So recently they have switched, created a[br]storage IO 0:08:11.110,0:08:13.729 which kind of lets you swap out AUFS with 0:08:13.729,0:08:17.449 the device-mapper, and has plans for integrating[br]RFS and 0:08:17.449,0:08:22.009 BTRFS and stuff like that. So beyond that,[br]you 0:08:22.009,0:08:24.379 see the base image, which is shipped out of 0:08:24.379,0:08:29.150 docker registry, and you also have images.[br]So I 0:08:29.150,0:08:33.240 installed emacs and, committed, it becomes[br]a read-only- so 0:08:33.240,0:08:37.669 bootSF is basically read-only, and once you[br]boot up 0:08:37.669,0:08:41.529 that container you'll get a writable part.[br]So once 0:08:41.529,0:08:45.650 you commit it, it'll become, again, read-only.[br]We'll go 0:08:45.650,0:08:49.340 through that. Workflow class- So the basic[br]workflow, I 0:08:49.340,0:08:52.630 will do it now again, so you basically pull 0:08:52.630,0:08:56.340 docker images from the public registry and[br]you run 0:08:56.340,0:08:59.420 it on your host, and you add your own 0:08:59.420,0:09:01.480 changes on top of it, push it back to 0:09:01.480,0:09:04.190 share them, or you could also build it from 0:09:04.190,0:09:09.000 the ground up using debootstrap and tools[br]like that. 0:09:09.000,0:09:10.830 So you also have a docker file which lets 0:09:10.830,0:09:15.520 you build your own images. Apart from that,[br]you 0:09:15.520,0:09:18.960 can set up a private regist- repor- registry[br]- 0:09:18.960,0:09:22.810 sorry. So the idea of private registry is[br]that 0:09:22.810,0:09:24.460 you have your own work groups and you want 0:09:24.460,0:09:27.350 to share these images within your company[br]and they're 0:09:27.350,0:09:31.630 not really useful for the public usage. So[br]this 0:09:31.630,0:09:34.510 is a very public registry, private registry[br]comes in 0:09:34.510,0:09:37.570 and, this is just a simple Python app, you 0:09:37.570,0:09:39.610 can run it on your own server and set 0:09:39.610,0:09:42.320 it up. So, oh, you can also sign up 0:09:42.320,0:09:45.250 for something like quail dot IO, which also[br]lets 0:09:45.250,0:09:48.230 you push, well, you can have your own account, 0:09:48.230,0:09:50.890 pay for it, and push your private images there, 0:09:50.890,0:09:54.540 and it's locked up. So before we go, go 0:09:54.540,0:09:57.230 into the Docker file part, so let me show 0:09:57.230,0:10:04.230 you a simple - workflow. So you have images, 0:10:07.290,0:10:11.470 so you can probably ignore a bunch of these. 0:10:11.470,0:10:13.820 Look at the last ones, which is basically[br]- 0:10:13.820,0:10:20.820 should I move that a little bit? OK. So 0:10:24.150,0:10:26.210 at the most basic level, when you pull from 0:10:26.210,0:10:33.210 Docker, say, so it will try to, so, it's 0:10:36.580,0:10:39.400 not gonna pull anything really, it'll just[br]check for 0:10:39.400,0:10:42.470 the layers that are available on my system,[br]and 0:10:42.470,0:10:47.290 it'll just, adjust itself. So you see several[br]layers 0:10:47.290,0:10:51.290 there, so if you look at the Ubuntu part, 0:10:51.290,0:10:55.090 it's actually, the Ubuntu images actually[br]comprised of precise 0:10:55.090,0:10:57.280 and quantiles, and you can use any of those 0:10:57.280,0:11:00.650 to take of your container. So kicking off[br]a 0:11:00.650,0:11:07.650 container is probably as simple as - [br]the end. 0:11:11.280,0:11:13.530 You can give it, you have to give it, 0:11:13.530,0:11:16.950 I'm taking the Ubuntu image, a basic image,[br]and 0:11:16.950,0:11:20.580 I have to give it an entry point. So 0:11:20.580,0:11:25.510 it will drop me into a root prompt, and 0:11:25.510,0:11:31.190 basically I can do, I can run app, get 0:11:31.190,0:11:33.880 updates, and I can install my own stuff. I'll 0:11:33.880,0:11:36.860 just install a small, a very tiny package,[br]so, 0:11:36.860,0:11:43.860 in the interest of time. Wow. That takes-[br]So 0:11:47.570,0:11:51.020 the basic starter image is pretty much very[br]stripped 0:11:51.020,0:11:53.340 down, you don't have most of the components[br]that 0:11:53.340,0:11:54.950 you would need. So the idea is that it 0:11:54.950,0:11:57.370 should be very lightweight to deploy, and[br]you can 0:11:57.370,0:12:01.960 basically add your own, your own software[br]on top 0:12:01.960,0:12:05.270 of it and commit and push it up. So 0:12:05.270,0:12:12.270 let's say I install nano. There you go, right. 0:12:15.110,0:12:18.860 That shouldn't take too long. Yeah. So you[br]have 0:12:18.860,0:12:22.180 nano here, and if I switch to the other 0:12:22.180,0:12:29.180 window, you can see. Docker ps. So among the 0:12:35.380,0:12:37.800 other ones, are you- you can see the last 0:12:37.800,0:12:40.120 one, which is being run here, and if I 0:12:40.120,0:12:46.940 actually switch, use nano there, you can see[br]- 0:12:46.940,0:12:53.750 docker - So each of the, each of the 0:12:53.750,0:12:57.390 containers will have its own name, so you[br]can 0:12:57.390,0:13:00.020 do - cranky - you can also set the 0:13:00.020,0:13:03.130 names, which is a recent feature. But otherwise[br]it'll 0:13:03.130,0:13:10.130 just regen- it'll just generate - oh, sorry.[br]So 0:13:14.470,0:13:16.590 it, it gives you what is happening inside[br]the 0:13:16.590,0:13:18.970 container. So you have a basic idea of what's 0:13:18.970,0:13:24.400 running inside the container. So you can also[br]commit 0:13:24.400,0:13:30.260 this. So you exit it, and you see, so 0:13:30.260,0:13:32.380 cranky curie is on there, so you can do 0:13:32.380,0:13:39.380 something like docker commit cranky curie.[br]Sorry. So you 0:13:53.300,0:13:55.300 can commit it, and it'll show up in your 0:13:55.300,0:14:02.300 images. Oh, I have to give it a name. 0:14:04.050,0:14:11.050 Cranky_curie as varsee nano. So, docker images.[br]You'll see 0:14:14.180,0:14:16.780 the one on top. It has fancy name. And 0:14:16.780,0:14:18.790 you can push it, you can push it to 0:14:18.790,0:14:23.270 the public registry, the public registry kind[br]of looks 0:14:23.270,0:14:30.270 like this. So you can search for your own, 0:14:33.390,0:14:36.290 whatever images that you might need for your[br]deployment 0:14:36.290,0:14:41.700 and stuff like that. So I've, you know, I've 0:14:41.700,0:14:43.290 been playing around with it a little bit and 0:14:43.290,0:14:46.070 stuff like that. So this is the public depository. 0:14:46.070,0:14:48.940 You can install the same thing on your private 0:14:48.940,0:14:52.870 servers and secure it from outside. And you[br]can 0:14:52.870,0:14:56.300 have your own image. So that's basically the[br]workflow 0:14:56.300,0:14:58.880 that you would work with. And there's a second 0:14:58.880,0:15:00.890 part to it. What I've done so far is 0:15:00.890,0:15:04.670 the manual, so I've logged into a container[br]and 0:15:04.670,0:15:07.430 I've installed stuff in it. So you basically[br]automate 0:15:07.430,0:15:14.430 it with something called a Docker file. Oh,[br]sorry. 0:15:23.570,0:15:27.390 So Docker file, so is, it's very similar to 0:15:27.390,0:15:31.100 what you have reg file or make files in 0:15:31.100,0:15:35.430 your projects. So it's a default way to build 0:15:35.430,0:15:38.560 it from base image. Basically upload a file[br]script, 0:15:38.560,0:15:42.970 but definitely easier to maintain. And you[br]have directives 0:15:42.970,0:15:47.720 like from, run, command, expose. So from is[br]basically 0:15:47.720,0:15:51.240 which, based on which image do I want to 0:15:51.240,0:15:54.030 build my docker. And you have run, basically[br]has, 0:15:54.030,0:15:57.210 or app to get install commands, whatever is[br]done 0:15:57.210,0:16:00.180 manually. And command and entry point are[br]very similar. 0:16:00.180,0:16:03.440 So I've entered into the container through[br]bin bash, 0:16:03.440,0:16:07.110 so I've basically put that in entrypoint.[br]And the 0:16:07.110,0:16:10.700 command is what passes, you pass some options[br]into 0:16:10.700,0:16:12.780 that. So I'll show you a docker file anyway, 0:16:12.780,0:16:16.440 so that will, that should put this, all this 0:16:16.440,0:16:19.030 in context. So you have, you can even add 0:16:19.030,0:16:22.320 files, you can copy config files from your[br]host 0:16:22.320,0:16:27.210 system into your container. You can have volumes,[br]volumes 0:16:27.210,0:16:31.670 are basically mount points. You just mount[br]a whole 0:16:31.670,0:16:35.990 directory as either read-only or read-write,[br]it's up to 0:16:35.990,0:16:38.760 you. And on the whole there are about a 0:16:38.760,0:16:42.490 dozen commands. It's very simple to get started[br]with. 0:16:42.490,0:16:48.160 No nonsense. And doesn't need a lot of time 0:16:48.160,0:16:51.060 to learn the whole thing. So, and you can 0:16:51.060,0:16:55.100 create your own base images using debootstrap[br]in centOS, 0:16:55.100,0:16:57.810 it's, debootstrap is basically a building[br]tool with how 0:16:57.810,0:17:01.630 you build a base image. But in that other 0:17:01.630,0:17:04.409 distros you have, you know you can do it 0:17:04.409,0:17:08.970 with other tools So zero downtime deployment.[br]So why, 0:17:08.970,0:17:12.720 why do we need that? So the most important 0:17:12.720,0:17:17.650 part being, you have, you know, things like[br]continuous 0:17:17.650,0:17:22.669 delivery and continuous deployments, right.[br]So they're subtly different 0:17:22.669,0:17:25.140 from each other, they're very similar concepts,[br]of course 0:17:25.140,0:17:30.100 you have continous delivery where you send[br]stuff, you 0:17:30.100,0:17:33.690 deliver your software on a regular basis and[br]you 0:17:33.690,0:17:36.860 have tight communication loops with your clients[br]and all 0:17:36.860,0:17:38.920 that good stuff - ?? and stuff. [00:17:38][br]And 0:17:38.920,0:17:42.050 continous deployment is basically taking it[br]one step, and 0:17:42.050,0:17:45.270 I think Chad did a really good example of 0:17:45.270,0:17:50.950 that yesterday. So you know instead of making[br]your 0:17:50.950,0:17:53.440 deployments, say, once a week, or you know,[br]once 0:17:53.440,0:17:56.480 every few days, the idea is to make them 0:17:56.480,0:18:00.400 as continuously as possible with least amount[br]of angst 0:18:00.400,0:18:05.390 around making deployments. So you basically[br]have, I'm sure 0:18:05.390,0:18:07.920 you're all used to long deploys in Rails.[br]Migrations, 0:18:07.920,0:18:11.310 you know, when migrations are happening, you're[br]changing the 0:18:11.310,0:18:14.650 schema, other requests, you usually put in[br]a maintenance 0:18:14.650,0:18:18.910 page and when other requests comes in you,[br]if 0:18:18.910,0:18:22.100 you don't put up a maintenance page, you already, 0:18:22.100,0:18:24.890 you can get some errors and stuff like that. 0:18:24.890,0:18:28.280 And obviously you know about asset compilation,[br]it takes 0:18:28.280,0:18:30.810 way too long. So but these problems are not, 0:18:30.810,0:18:34.260 really not limited to Rails, per se. I'm sure 0:18:34.260,0:18:37.140 you have the same issues when you're deploying[br]Jangle 0:18:37.140,0:18:40.710 container, so Docker is basically a framework[br]diagnostic you 0:18:40.710,0:18:44.000 can run any apps on it, and. So I'm 0:18:44.000,0:18:47.740 trying to lay out a problem, so there are 0:18:47.740,0:18:50.220 two parts to this problem. So one is with 0:18:50.220,0:18:54.290 migrations and without migrations. Without[br]migrations it's usually a 0:18:54.290,0:18:57.880 little easier because you don't have to worry[br]about 0:18:57.880,0:19:01.630 making sure the databases are in sync and[br]stuff 0:19:01.630,0:19:03.770 like that. So with databases it's a more complex 0:19:03.770,0:19:07.280 scenario where you have to take a master DB 0:19:07.280,0:19:11.170 slave, DB, make sure they're sync, and you[br]have 0:19:11.170,0:19:15.360 something like ZooKeeper kind of keeping track[br]of who's 0:19:15.360,0:19:17.410 master, who's slave, and you switch. So I'll[br]try 0:19:17.410,0:19:22.180 to walk you through the simpler case, so we 0:19:22.180,0:19:26.070 can extend this to, you know, DB level. I 0:19:26.070,0:19:29.040 don't think I can cover other DB stuff here. 0:19:29.040,0:19:33.960 So you basically have a HaProxy. HaProxy is[br]basically 0:19:33.960,0:19:37.830 a reverse proxy but on steroids. So it's a 0:19:37.830,0:19:41.130 load balancer, to be exact. But what it does 0:19:41.130,0:19:43.070 is very similar to what engine x does for 0:19:43.070,0:19:46.430 you, you have like multiple instances, and[br]you are, 0:19:46.430,0:19:49.610 they're running on different multiple instances[br]of your app 0:19:49.610,0:19:54.020 server, they're running on different ports.[br]And basically enginex, 0:19:54.020,0:19:55.930 once a request comes enginex will do a round 0:19:55.930,0:19:58.790 up and allotment of you know the servers.[br]So 0:19:58.790,0:20:01.650 HaProxy does that, but also a lot more. It 0:20:01.650,0:20:05.030 also lets you do funky stuff like what I'm 0:20:05.030,0:20:07.300 gonna talk about, there's a back-up server,[br]and active 0:20:07.300,0:20:11.250 server, which you can use cleverly to do zero-downtime 0:20:11.250,0:20:15.030 deployments. But it also has, if you have[br]time, 0:20:15.030,0:20:17.700 I would suggest you go through the configuration[br]file, 0:20:17.700,0:20:20.010 which is very dense and long, but very interesting 0:20:20.010,0:20:24.320 stuff. So what we're gonna use, in HaProxy[br]here, 0:20:24.320,0:20:28.220 is that you have basically two types of, you 0:20:28.220,0:20:31.320 can set up two types of servers. And the 0:20:31.320,0:20:33.550 like, a bunch of active servers and there[br]are 0:20:33.550,0:20:36.320 like a bunch of back-up servers, and the idea 0:20:36.320,0:20:40.210 is that the back-up servers are not used until 0:20:40.210,0:20:42.830 all the active servers are down, right. So[br]the 0:20:42.830,0:20:45.490 request won't come through to back-up servers[br]until all 0:20:45.490,0:20:49.680 the active servers are down. So what we are 0:20:49.680,0:20:53.360 gonna, how we are gonna use that, sorry, the 0:20:53.360,0:20:59.090 slides are very basic, so. So, you basically[br]kick 0:20:59.090,0:21:02.770 off the deploy, kick off the image build with 0:21:02.770,0:21:06.610 docker, and you take down the back-up servers.[br]At 0:21:06.610,0:21:10.030 this point your HaProxy is still serving from[br]your 0:21:10.030,0:21:15.020 active servers, right. So now you bring up[br]the 0:21:15.020,0:21:18.000 new back-up server, new back-up servers with[br]your new 0:21:18.000,0:21:20.070 image, which is just being build when the[br]deploy 0:21:20.070,0:21:24.390 happened. So, and then you take down the active 0:21:24.390,0:21:28.790 servers. So after all the active servers are[br]down, 0:21:28.790,0:21:30.990 the requests will come in to the back-up ones, 0:21:30.990,0:21:34.130 right, so which is now serving your new code, 0:21:34.130,0:21:36.780 which has just been deployed. So after that[br]you 0:21:36.780,0:21:39.820 restart your active servers, you're back to[br]normal again. 0:21:39.820,0:21:44.040 So at the most basic level, so at least 0:21:44.040,0:21:47.200 you will definitely won't be able to do migrations 0:21:47.200,0:21:49.420 with this set-up. You have to go a little 0:21:49.420,0:21:51.980 bit advanced for that. But at least you'll[br]be 0:21:51.980,0:21:56.240 able to avoid frustrations with stuff like[br]long asset 0:21:56.240,0:22:02.130 recompilation, you know, long deploys that[br]you usually get. 0:22:02.130,0:22:05.270 So let me walk you through the whole thing, 0:22:05.270,0:22:11.970 quickly. So I was actually quite upset that[br]the 0:22:11.970,0:22:14.600 talk, the pamphlet which is being given, which[br]had 0:22:14.600,0:22:18.370 shortcuts for sublime and whim, but it doesn't[br]have 0:22:18.370,0:22:24.910 shortcuts for emacs. Which is, I object! So[br]the 0:22:24.910,0:22:27.250 idea is, OK let me start you off with 0:22:27.250,0:22:30.010 the simple docker file. So this should, this[br]should 0:22:30.010,0:22:37.010 - oh, OK. Yeah. Let me restart it. I'll 0:22:51.450,0:22:57.480 just show you on my- I think this is 0:22:57.480,0:23:04.480 a lot more easier to show you. So app 0:23:04.640,0:23:11.640 server, you have docker file. So at the most 0:23:17.809,0:23:20.380 basic level, I am picking it up from the 0:23:20.380,0:23:25.080 Ubuntu image, and basically running some adaptation[br]of my 0:23:25.080,0:23:30.440 source's list, and you have app-get update,[br]app-get install, 0:23:30.440,0:23:33.180 y. So let me run the deploy first, and 0:23:33.180,0:23:35.250 then I will talk about this, because I don't 0:23:35.250,0:23:42.250 think we'll have enough time to actually wait[br]afterwards. 0:24:00.680,0:24:05.300 OK. So this will, this will run the deploy 0:24:05.309,0:24:09.370 process in the background. Let me talk about[br]what 0:24:09.370,0:24:16.370 it actually does out here. OK. So let's get 0:24:28.670,0:24:31.400 back to our docker file. So what it does 0:24:31.400,0:24:33.600 - this is almost like the shell script that 0:24:33.600,0:24:37.600 you use for everyday automation, so, but it[br]adds 0:24:37.600,0:24:41.700 a little bit more fun to it, I guess. 0:24:41.700,0:24:45.580 So what I'm doing is pretty straightforward.[br]I'm installing 0:24:45.580,0:24:49.820 chruby, I hate RBM, especially for production[br]it sucks, 0:24:49.820,0:24:53.980 I mean, yeah. There are other opinions about[br]it. 0:24:53.980,0:24:55.900 But at least I have, I've thought it's the 0:24:55.900,0:24:58.340 easiest way to get started. So I'm basically[br]installing 0:24:58.340,0:25:03.290 some default gems, like bundler and puma,[br]and I'm 0:25:03.290,0:25:06.370 installing other dependencies. So the reason,[br]I am actually 0:25:06.370,0:25:10.710 splitting this into two docker files. So you'll[br]also 0:25:10.710,0:25:17.710 have stuff like, so. What I'm doing here is 0:25:21.440,0:25:24.150 that, so when I'm doing actually a deploy,[br]I 0:25:24.150,0:25:27.240 am only running this. So I'm picking up, I'm 0:25:27.240,0:25:30.220 installing all my dependencies in my earlier[br]image, and 0:25:30.220,0:25:32.610 I'm just reusing it for deploys I want, because 0:25:32.610,0:25:35.690 I want them to be pretty fast. So what 0:25:35.690,0:25:37.630 this does is pretty simple. It copies over[br]the 0:25:37.630,0:25:43.059 database configurations and it does a bundle,[br]and it 0:25:43.059,0:25:47.500 does a db migrate. I'm just using sqlite here, 0:25:47.500,0:25:52.380 so yeah. It exposes a port. So how the 0:25:52.380,0:25:55.460 containers talk to each other within a docker,[br]in 0:25:55.460,0:26:00.540 your host, is that through exposing these[br]ports. And 0:26:00.540,0:26:04.290 like I mentioned earlier, my entrypoint is[br]basically I'm 0:26:04.290,0:26:10.350 starting Puma there. And I'm running it in[br]a 0:26:10.350,0:26:16.070 ?? [00:26:07]. Yeah. So if you look at the, 0:26:16.070,0:26:23.070 if you. If you look at the deployment, I'm 0:26:29.480,0:26:36.220 sorry- Yeah. So I don't know how much of 0:26:36.220,0:26:39.080 this actually makes sense. I'll just show[br]you the, 0:26:39.080,0:26:42.910 our deployment code. Sorry, the cap file,[br]so that 0:26:42.910,0:26:49.910 should make a little bit of more, yeah. OK. 0:27:01.620,0:27:06.429 So if you see at the bottom, you'll see 0:27:06.429,0:27:10.179 that I am just doing a bunch of stuff 0:27:10.179,0:27:15.480 there, so I'm linking from my current deploy[br]to 0:27:15.480,0:27:22.410 the vagrant, sorry, the docker container build[br]directory. And 0:27:22.410,0:27:25.240 I'm starting from the back-end servers. So[br]I'll, I 0:27:25.240,0:27:29.679 should also show you the, my HaProxy configuration.[br]So 0:27:29.679,0:27:34.700 it starts with your ports set up and you 0:27:34.700,0:27:37.550 actually search for those docker containers[br]and take them 0:27:37.550,0:27:40.309 down. So the build takes a- a little long, 0:27:40.309,0:27:42.300 so I've kind of commented it out for now, 0:27:42.300,0:27:44.330 but I can show you outside if you want 0:27:44.330,0:27:47.440 to see how that works. And it's pretty simple. 0:27:47.440,0:27:49.520 So at the end of it I'm just restarting 0:27:49.520,0:27:52.660 all my containers, so you can basically look[br]at 0:27:52.660,0:27:58.510 them here. Docker ps a. You'll see that these 0:27:58.510,0:28:00.770 top ones are only up for two minutes. These 0:28:00.770,0:28:04.950 are recently deployed. So all through, if[br]you look 0:28:04.950,0:28:09.830 at your HaProxy page, so you basically have[br]two 0:28:09.830,0:28:14.630 active ones here, and two back-up servers[br]here. So 0:28:14.630,0:28:21.630 like, and I also should show you the HaProxy 0:28:28.470,0:28:35.470 stuff, right. So you can pretty much ignore[br]all 0:28:36.620,0:28:39.700 this stuff. The most important part is the[br]last 0:28:39.700,0:28:42.260 two ones. So as you can see the web 0:28:42.260,0:28:46.720 01 and web 02 are active servers, and web 0:28:46.720,0:28:49.740 03 and web 04 are back-up servers. So that's 0:28:49.740,0:28:53.900 all it takes. So you can basically segment[br]your, 0:28:53.900,0:28:58.030 the servers like that and go at it. So 0:28:58.030,0:29:05.030 that's basically it. So I hope- and, a couple 0:29:05.049,0:29:09.200 of helpful links if, sorry if it's not very 0:29:09.200,0:29:11.640 visible. There's docker dot io, where you[br]can find 0:29:11.640,0:29:15.110 all of the documentation and stuff, there's[br]haproxy - 0:29:15.110,0:29:17.470 go look at it if you are doing deployments 0:29:17.470,0:29:21.370 through your regular day-to-day developer[br]life. This is a 0:29:21.370,0:29:25.990 lifesaving tool to learn well. And there's[br]dockerbook, if 0:29:25.990,0:29:28.250 you're - it's written by James Turnbull one[br]of 0:29:28.250,0:29:32.600 my favorite technical authors. He's written[br]Pro Puppet, which 0:29:32.600,0:29:36.490 is still quite one of my favorite books. And 0:29:36.490,0:29:38.420 if you want to know a little bit more 0:29:38.420,0:29:43.270 about the Linux part of what Docker does,[br]like 0:29:43.270,0:29:46.620 the internals of Docker, you can listen to[br]Jerome 0:29:46.620,0:29:49.390 Petazzoni, who is part of the Docker team.[br]So 0:29:49.390,0:29:51.530 he's given a really good talk, in-depth talk[br]about 0:29:51.530,0:29:53.840 it, at our next conference you should look[br]at 0:29:53.840,0:29:56.410 the video. And there are like a bunch of 0:29:56.410,0:29:59.360 tools you can probably look at. There's Dokku[br]which 0:29:59.360,0:30:02.730 is a PaaS. PaaS is a platform as a 0:30:02.730,0:30:05.170 service, what- essentially what HaDokku does,[br]you can build 0:30:05.170,0:30:08.600 your own HaDokku [00:30:06] with the Docker.[br]And Flynn 0:30:08.600,0:30:12.080 dot io, CoreOS is also very import- very interesting 0:30:12.080,0:30:15.320 tool. CoreOS kind of bundles Docker with a[br]service 0:30:15.320,0:30:18.480 disovery thing, like, kind of like ZooKeeper,[br]but it 0:30:18.480,0:30:22.130 is called ATCD. And it bundle system ??[00:20:21][br]in 0:30:22.130,0:30:24.950 its framework, so if you're into deployments[br]this is 0:30:24.950,0:30:29.000 a very interesting ecosystem to look at. And[br]Quay 0:30:29.000,0:30:32.970 dot io I mentioned. It's, you can basically[br]upload 0:30:32.970,0:30:36.780 your private images there and get started.[br]So they're 0:30:36.780,0:30:39.450 like a bunch of tools. I don't know if 0:30:39.450,0:30:42.390 I have any time for questions, but you can 0:30:42.390,0:30:47.390 catch me. Sorry, but I'm available, you can[br]catch 0:30:47.390,0:30:54.390 me at any time. Thanks a lot.