#100DaysOfWeb in Python Transcripts
Chapter: Days 97-100: Docker and Docker Compose
Lecture: Keep your Docker DRY (refactoring)

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's review our two dockerfiles we've created so far. Hideaway our movie service. So here we're both basing them on Ubuntu, right?
0:09 They're the same, and if I switch back you can see it doesn't really make any changes or deviations, until we get to line 11.
0:18 Same here. So what I would like to propose is that we have one more thing I would call this a base_server, for our project.
0:30 And I'm going to put the dockerfile over here, like so. And on this one, we're going to take away the stuff that is extra
0:40 is added for each one of those and we're going to build it. So let's copy this path over here. Now, when I say docker build, now remember
0:56 we were giving it, let's say we'll say base_server. So we give it a name so that we can reliably refer back to it.
1:07 And it says, hey, we already built that. We know about all of these things. And what we can do over here then is we can say
1:13 you know what, we don't need to repeat ourself here this one is just based on the base_server. Same thing as over here, just based on the base_server
1:22 it's just that delta. Now we got to rebuild those other two and at first, it's going to be more work because it's got to reinstall Nginx
1:29 and do all of it's things but in fact, it's going to make it a lot better so that we have this sort of commonality
1:36 across all of our servers, and what not. So it's kind of pre-configuring it for us, right? So let's go do that. So we look at docker images.
1:47 We have now this base_server we can refer to. So at docker build, front end like that now it's based on the base_server, not on Ubuntu
2:01 and it looks good, and do a build, like that? Everything's going, guess we can do one more test.
2:18 Run the front end. Run the back end, and hit it one more time just to make sure I didn't break anything and sure enough, there it is working away.
2:33 You can see it interacting and it gives me the server side output there. Obviously the front end is working, and we have Java.
2:39 Ah, coffee, can we go for that. Javascript, that's what it's going to say. I really doubt that that's a thing, I was hoping
2:46 for some coffee reference, but there we have it. It looks like we were able to clean that up a little bit. Now it's annoying, we have to remember
2:53 to first build the base_server and then build the other things. That's one of the things, one of the challenges
2:59 that will be solved when we get to docker compose that will allow us to treat these three different containers and container images as one whole unit.
3:08 But for now, manually, we've removed some of our repeated specifications and code and moved it down to a base image.


Talk Python's Mastodon Michael Kennedy's Mastodon