Latest / Talk Python To Me / #323: Best practices for Docker in production
Transcript
- 0:00You've got your Python API or app running in a Docker container.
- 0:03Great.
- 0:03Are you ready to ship it to that hosted container service and head off to production?
- 0:07Not so fast.
- 0:08Have you considered how you'll manage evolving the dependencies and addressing security updates
- 0:13over time?
- 0:14Not just for the base OS, but for the installed packages?
- 0:17How about your pip installed dependencies?
- 0:19Are you running as root?
- 0:21If you don't know, the answer is yes.
- 0:23We'll discuss these and many more issues with Itamar Turner-Trowing on this episode.
- 0:28It's Talk Python To Me.
- 0:29Episode 323, recorded June 14th, 2021.
- 0:34Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem,
- 0:53and the personalities.
- 0:54This is your host, Michael Kennedy.
- 0:55Follow me on Twitter where I'm @mkennedy.
- 0:58And keep up with the show and listen to past episodes at talkpython.fm.
- 1:01And follow the show on Twitter via at Talk Python.
- 1:04This episode is brought to you by Sentry and Linode.
- 1:08And the transcripts are brought to you by Assembly AI.
- 1:10Please check out what they're offering during their segments.
- 1:13It really helps support the show.
- 1:16Hi, all.
- 1:16I have a quick announcement before we dive into the interview.
- 1:19Over at Talk Python Training, we just released our latest course, Python-powered chat apps with Twilio and Syngrid.
- 1:25Have you ever wanted to create a chatbot using Python?
- 1:29In this course, we'll be building an ordering system for a tech-savvy bakery.
- 1:33Our customers can place orders over WhatsApp.
- 1:35And during the chat back and forth, we'll integrate data from our Flask API, answering questions such as, what's the menu?
- 1:42What does that cost?
- 1:44And so on.
- 1:44Then we'll integrate this into a sweet backend that sends receipts as PDFs over emails and allows our bakers to see new orders and then mark them as fulfilled and notify the customers when they're done.
- 1:56In short, it's cool tech and a super fun project.
- 1:59Oh, and one more thing.
- 2:01This course is free for everyone.
- 2:03So if this six-hour course sounds fun, just click the link in your podcast player's show notes and jump into the course.
- 2:08Now, on to the Docker best practices.
- 2:10Itamar, welcome to Talk Python To Me.
- 2:13Welcome back to Talk Python To Me.
- 2:14It's been some time.
- 2:16Feels like a year or so.
- 2:17I'm not sure exactly how long it's been.
- 2:19Last time we were on, we were talking about an entirely different topic.
- 2:24So you get two bits on the mind map connective sort of relationship of topics here.
- 2:30We talked about fill and profiling data science.
- 2:34That was fun.
- 2:34Yeah.
- 2:35I sort of have found myself talking about a bunch of different subjects and like some people are interested in both.
- 2:42Some people are interested in the other.
- 2:43And Docker is the other thing I've spent a lot of time sort of researching and writing about.
- 2:48Yeah, it's I think the data science profiling one was really interesting because profiling has all these challenges and much of it is more focused around profiling running applications or profiling code that's all in Python.
- 3:00And so if you need to profile like, say, Fortran code or other weird sort of mix and match libraries, then that was sort of that topic, right?
- 3:09Yeah, so feel as a memory profiler for Python and the kind of and specifically for batch processes like data science, scientific computing.
- 3:17And so if you're doing scientific computing, they'll there'll be a bunch of code in Fortran and C++ and Rust.
- 3:22And so you want to access that memory, like sort of profile memory across all the languages you're using.
- 3:30Yeah, because if you've got some big glob of C code, Python thinks it's just a pointer, that little tiny pointer to some, but it turns out to be huge.
- 3:37Yeah, so people can check out that episode.
- 3:39They're interested.
- 3:40And yeah, just give us an update on what you've been doing since then.
- 3:43I've actually been trying to turn feel into a sort of make an alternative version of it that you can run in production.
- 3:48Profilers often have performance overheads of feel take like 40% performance off the top.
- 3:54Trying to make something that will run with like 1%, 2% overhead.
- 3:58So you can run on production and just always get reports about your memory usage for any job.
- 4:03So if it's like six hours in it, it crashes out of crashes or just uses too much memory, go back and look at that.
- 4:10Oh, that would be fantastic.
- 4:11We have that for like profiling in terms of performance.
- 4:14On some systems, you can plug them in and they'll kind of give you real time.
- 4:19How is my app doing in terms of, you know, here's where it's spending its time or it got slower.
- 4:25Maybe it's even just measuring like request response.
- 4:28But memory profiling has typically been pretty intensive, right?
- 4:33So that'd be cool if you could get it down to that level.
- 4:35Yeah, and this is a very good pen.
- 4:39Both Phil and this project are very good.
- 4:41Pandemic projects.
- 4:42It's like really, it's quite difficult to do.
- 4:45And it's like, but it's something that is sort of completely under my control.
- 4:48Like we'll get to Docker and Docker is like, there's this giant ecosystem and they all have
- 4:53differing opinions about how you do things.
- 4:54And like everything's so broken around the edges.
- 4:57Whereas here it's like, I have a box and it's a very complicated box, but it's under my control.
- 5:04And so I can do so.
- 5:04It's kind of relaxing in an environment where the world is not under my control.
- 5:10It's been a crazy time, hasn't it?
- 5:13Yeah.
- 5:13Yeah.
- 5:13I feel like we're getting used to it.
- 5:15It's odd, but you know, people just get used to whatever water they swim in eventually, I guess.
- 5:20Yeah.
- 5:21Yeah.
- 5:21Let's talk about Docker a little bit.
- 5:24So it hasn't been that long since I had, that's, I also want to shout out quick episode 274 is when
- 5:31we talked about Phil, people want to go back and check that out.
- 5:33But I had Peter McKee from Docker over there to come and talk about sort of what is Docker, you know, give us an update on Docker, the company and like sort of set the stage for Python developers, right?
- 5:46To kind of get going on the dev side and just start using Docker.
- 5:49So that was episode 308 and that was fun.
- 5:51But then recently you gave a talk at PyCon called Zero to Production Ready, a best practices process for Docker packaging.
- 6:00And so I thought that was really interesting and wanted to have you on the show so we could dive into Docker best practices for Python, but also your focus is really on production, not necessarily development, right?
- 6:13Yeah.
- 6:13Maybe we start there.
- 6:14Like what's Docker look like for software development as a, I just need to make my stuff run so I can code it and test it out versus, I don't know, zero downtime Kubernetes or whatever it is you're trying to do type of thing.
- 6:26What do those two worlds look like and maybe tell folks about when they should care about what are the advantages or whatever.
- 6:32Yeah.
- 6:32So what Docker gives you is a sort of package that contains all the files you need for the file system, contains Python.
- 6:41It contains all the system libraries you need to run your Python extensions.
- 6:45It contains all your Python dependencies, contains all your code and contains a script to launch your code.
- 6:52And so as a starting point, this is useful for development because if you're say on macOS or in Windows and you're deploying to Linux, you can run something locally that is the same on across different computers.
- 7:05Even if you are on Linux, like I have one machine that's Fedora 33, I have another machine that's Ubuntu, like they're different in a bunch of subtle and lots of subtle ways.
- 7:17And so by having a Docker container when I'm developing, I can have a completely consistent environment.
- 7:24And then know that that environment when I, when I then take that code and run in production, it'll be exactly the same there.
- 7:29Right.
- 7:29I had a, somebody reach out to me a little while ago and ask something to the effect of, I've got a bunch of different developers on my team and I want to make sure that they all have the same version of Python in the same packages.
- 7:42Right.
- 7:42And that's a legitimate thing that you might want to do.
- 7:45You might want to make sure that those are exactly the same.
- 7:47I think maybe in general, there's probably more of a concern about that than an actual problem there.
- 7:54You know, a lot of times either these things are going to basically work or they're going to utterly fail.
- 7:58I think one of the scenarios maybe where it matters more is data science, where there's slight changes in algorithms, which might lead to different, you know, ways.
- 8:06You train the model, which might lean to different, like it could, those kinds of changes, but say in like web apps or UI apps or something like that, it's, it's either just going to work or it's going to completely break.
- 8:16That said, you know, this situation you're talking about with Docker for development, like kind of solves that, but to a much bigger degree.
- 8:23Right.
- 8:24Cause you could specify in this image, we have exactly this version of Python compiled in this way.
- 8:30We have these libraries installed with this version.
- 8:34We have these environment variables set and this subsystem of Linux installed as well, but not that other way.
- 8:41You can completely control it way more than just, I want the same version of Python, right?
- 8:45And you can then go further with something like Docker compose or compose lets you start up a little network of containers.
- 8:52And then it's very easy to say, okay, I want to spin up Postgres or I want to spin up Redis.
- 8:57Whereas traditionally this would be a pain in the ass with Docker and Docker compose.
- 9:01You can spin up a little, all your dependency servers really easily.
- 9:04So then even if you're not using Docker for your own code, you can use Docker for the services
- 9:09you depend on to really easily spin them up.
- 9:11Right.
- 9:11I need Redis running in this way and I need Postgres in that way.
- 9:15And I just need them all configured and to be able to talk.
- 9:18So Docker compose up, right?
- 9:20Something like that.
- 9:21Yeah.
- 9:21Yeah.
- 9:22Docker compose is a way to sort of run a little network of services, makes that really easily.
- 9:26Yeah.
- 9:27Another big advantage before we get off of the development side of things is onboarding new
- 9:32people and new hardware, right?
- 9:34If you've got something really complicated like that and you get somebody on the team, instead
- 9:38of spending a lot of time trying to get their system put together in the right way, you just
- 9:43go, sell Docker, do this.
- 9:45Yeah.
- 9:45There's, there's open source projects where like you can set up the development environment
- 9:49that will also provide a Docker file to just let you run some tests easily, just because
- 9:55you're a ongoing, you're only submitting one patch.
- 9:58You want to run some, like some tests on it.
- 10:00You don't want to go the whole thing.
- 10:02So it's very nice when they provide a way to run the code in Docker.
- 10:05Yeah, absolutely.
- 10:06That said, I don't generally do my development in Docker.
- 10:09I just, just have virtual environments and roll with that.
- 10:13So it's not always required.
- 10:14A couple of thoughts from folks out in the live stream.
- 10:16Kim Van Wick.
- 10:17Hey Kim.
- 10:18Says Docker Compose is an excellent way to make sure all the developers are using the same
- 10:22tools and versions.
- 10:23And it's just much easier to pass around a YAML file.
- 10:25Yeah.
- 10:26Compose is like, I remember when Compose first came out and it was called Fig, I think.
- 10:31And it was, it took Docker from something really neat to something really useful.
- 10:36Yeah.
- 10:36Right.
- 10:37The promise of Docker is that I can have all these different, if I want to run, like we just
- 10:42described, I want to run Redis.
- 10:43I want to run maybe a Celery backend.
- 10:45I want to run Postgres.
- 10:47And then my dev code is going to run and talk to all that.
- 10:50Well, keeping those all up to date, you know, start making sure they all build those files
- 10:55and they all run and maybe they run in the right order.
- 10:57Well, that all of a sudden isn't fun anymore.
- 10:59But if you can create a Compose file and just say, here's the set of containers that needs
- 11:03to work together, bring them all up in the right order and make sure they're all up to
- 11:07date, you know, got their recent build and so on.
- 11:09Like that's a whole nother level of the promise of containers.
- 11:12Yeah.
- 11:13Also, I don't know if you know anything about this.
- 11:15I'll maybe take a wild guess here.
- 11:17But Daniel Chen out in the live stream also says, question, is there in Windows, is there
- 11:22any difference between WSL 2 for the Docker backend compared to Hyper-V or is Hyper-V more
- 11:28for backwards compatibility legacy support?
- 11:30I, in general, don't use Windows that much.
- 11:33But basically, there's two, like, since you're running Linux and Windows is not Linux, you
- 11:38need to have some way of running Linux.
- 11:40In the past, the way you do that, you would run a virtual machine.
- 11:43This is what it does in macOS 2, I believe.
- 11:44Windows subsystem for Linux is a way to transparently run Linux applications on Windows and Docker supports
- 11:52it these days.
- 11:53I suspect they would be faster, but that's just a guess.
- 11:56So I don't have a good...
- 11:58Yeah, that's my thought as well, that they would be a little more integrated.
- 12:00Probably you could more easily do things like mount Windows file system folders from your
- 12:07Docker container.
- 12:08I don't know.
- 12:08Maybe you still can't with the others.
- 12:09Probably you can.
- 12:10But...
- 12:10I'd expect to be faster at least, yeah.
- 12:12Yeah.
- 12:12It seems like if you want to run on Linux, you're probably...
- 12:16I think you're probably closer.
- 12:16It's definitely more lightweight.
- 12:18Hyper-V would be running a full-on Linux VM and then hosting Docker in that, I'm pretty
- 12:23sure.
- 12:23Yeah.
- 12:24Yeah.
- 12:24Cool.
- 12:24All right.
- 12:25Well, hopefully our guesses there, Daniel, are helpful.
- 12:27All right.
- 12:28Well, let's talk about your talk that you gave at PyCon.
- 12:32I mean, giving talks today at conferences, like we started the show off, like it's a weird
- 12:36world, right?
- 12:37I'm giving a talk and both doing a live stream podcast on a conference tomorrow at the Manning
- 12:44Developer Productivity Conference.
- 12:46How can I do that?
- 12:47We record it.
- 12:48We publish it.
- 12:49And then we have a live Q&A afterwards.
- 12:51So the presentation of my recording will be during the Python bytes recording tomorrow,
- 12:56but then the live interactive bit will be actually after.
- 12:59So yeah, that's the commerce world we live in.
- 13:01And so PyCon this year was virtual.
- 13:05You put together a really nice presentation sort of in this format.
- 13:09And yeah, like I said, I got a lot out of it and I liked what you covered there.
- 13:14Yeah.
- 13:14And so the starting point is you have the service, now you want to run it in production.
- 13:18And this is a very dramatic departure from running things locally, because locally, the
- 13:25thing you're prioritizing is basically your feedback loop, like your development feedback
- 13:31loop.
- 13:31Like if you're a web developer, you do like it and you save your code, like can you reload
- 13:36the page to have the new stuff running?
- 13:37Other applications of feedback loops are a little different.
- 13:40But like your goal is just as quickly as possible to interact with your code.
- 13:45When you're in production, you have to worry about a whole bunch of other issues because
- 13:48it's actually, you have users who are going to be interacting with the software or the data
- 13:54it's emitting will be used in the real world.
- 13:56It's no longer just something you're working on.
- 13:59It's a thing that actually has some, the output actually has some weights and meaning, some
- 14:04importance.
- 14:04You have to approach it in a different way.
- 14:06So some of the things that come to mind here would be downtime, you know, in a perfect
- 14:11world, zero downtime in a reasonable world, a couple of seconds of downtime in the world
- 14:17of some bizarre web companies that I cannot, I literally cannot understand eight hours of
- 14:23downtime because we're deploying the new version of the site.
- 14:25So Sunday it'll be down.
- 14:26Like what?
- 14:27I just literally, I got this a while, you know, a couple of months ago for something
- 14:32I was using.
- 14:32There's going to be hours of downtime for a site.
- 14:35That's just, do, do, as you said, do you upgrade to the new version of the site?
- 14:39That should be a button folks.
- 14:40That should be not long.
- 14:41Anyway, one of the things is downtime, right?
- 14:43You want to focus on that and you don't care about that at all with development.
- 14:47I mean, you want it to be somewhat responsive, but it doesn't matter if it's down for a moment.
- 14:53This portion of Talk Python Army is brought to you by Sentry.
- 14:55How would you like to remove a little stress from your life?
- 14:58Do you worry that users might be having difficulties or are encountering errors in your app right
- 15:03now?
- 15:03Would you even know it until they send that support email?
- 15:06How much better would it be to have the error and performance details immediately sent to
- 15:11you, including the call stack and values of local variables and the active user recorded
- 15:16in that report?
- 15:17With Sentry, this is not only possible, it's simple.
- 15:20In fact, we use Sentry on all the Talk Python web properties.
- 15:24We've actually fixed a bug triggered by a user and had the upgrade ready to roll out as we
- 15:30got their support email.
- 15:31That was a great email to write back.
- 15:32We saw your error and have already rolled out the fix.
- 15:35Imagine their surprise.
- 15:36Surprise and delight your users today.
- 15:38Create your Sentry account at talkpython.fm/sentry.
- 15:42And if you sign up with the code talkpython2021, it's good for two months of Sentry's team plan,
- 15:48which will give you up to 20 times as many monthly events as well as other features.
- 15:53So just use that code talkpython2021 as your promo code when you sign up.
- 15:58Another one that you made a big deal out of that can matter is security.
- 16:03You don't want to be in the newspaper or the news website front pages for leaking the largest
- 16:10data breach ever or something like that, right?
- 16:12Yeah, that's embarrassing.
- 16:13Basically, once you're packaging for production, you're at the intersection of a whole bunch
- 16:18of processes.
- 16:18This is where it starts getting complicated.
- 16:20You're coding, and then you have this image, and then you might want to run some tests with
- 16:24it, maybe integration tests, and you're going to deploy it.
- 16:27And then when you deploy it, you might be upgrading an existing package, existing server.
- 16:32It's a server.
- 16:32It's a batch process.
- 16:33Things are a little different.
- 16:35So there's deployment, and then things might go wrong in production, and then you might
- 16:39have some sort of feedback mechanism, and maybe you're going to try to reproduce the
- 16:42bug locally.
- 16:43So all of these different technological organizational processes have some interact in some way with
- 16:50your packaging.
- 16:50And so it basically makes it a lot more complicated.
- 16:54And then you add into it all the different technologies that are intersecting in packaging.
- 16:58There's a lot of details to get right, and it gets complicated very quickly.
- 17:01Another area that you want to get into has to do with making sure that you're running
- 17:07the latest version, but you're not necessarily every deployment just grabbing the latest version.
- 17:14So you need some way to inject stability, and you need some way that that stability doesn't
- 17:19lock in computer vulnerabilities or any of those kinds of issues.
- 17:24It also allows it to keep growing, right?
- 17:26Yeah.
- 17:26And this is sort of one of the more significant examples, but an example of the bigger picture,
- 17:33which is packaging is a process.
- 17:35And so it's not just about writing some configuration files.
- 17:39It's going to interact with the way you write code, and it's a thing that parts of it are going
- 17:44to continue over time.
- 17:45So when you're packaging for production, you're not just writing a few config files and calling
- 17:50it a day.
- 17:50You actually need to think about, need to set up these ongoing processes for things
- 17:55like security updates and for things like dependency updates.
- 17:58Right.
- 17:58It's one thing to get it running on a cluster, a container cluster.
- 18:01It's another to say, and here's how we're going to keep this software healthy and running
- 18:06over time, right?
- 18:08Yeah.
- 18:08You need to sort of think through the implications of what you're doing, and it's not just a
- 18:13one-off thing.
- 18:13It's an ongoing thing.
- 18:14Yeah, absolutely.
- 18:15All right.
- 18:16Let's dive into some of the details.
- 18:18So it turns out I discovered today, as I was pulling up your website, that you've actually
- 18:23written a whole bunch of stuff about production-ready Docker packaging, and that you're actually
- 18:29working on a handbook.
- 18:30I end up doing this a lot as well.
- 18:32I end up, I'll spend a month doing tons of research and examples and thinking about a course,
- 18:38and I'm like, oh, there's a couple of nice presentations or conference talks I could pull
- 18:42out of here.
- 18:42And yeah, it's a good way to do it, right?
- 18:45So you've been thinking a lot about this, not just for this talk, but beyond, right?
- 18:48Yeah.
- 18:49I'm sort of spending two years on it so far.
- 18:52Like, I have three different products up there.
- 18:56I've done training.
- 18:56There's like a lot of articles these days.
- 19:00It just adds up.
- 19:01And yeah, I've spent a lot of time looking into this because it turns out it's, I should say,
- 19:07I don't like Docker packaging.
- 19:10Okay.
- 19:11This isn't a thing I'm doing because this is fun.
- 19:14It's not actually fun.
- 19:16It's kind of a pain.
- 19:17It's just, it's very useful and it's very easy to get it wrong or to miss things.
- 19:23And so what I've been trying to do is sit and say, here's this really useful thing.
- 19:28Here are the details you need to get right.
- 19:30And now that I've written it down, you don't have to waste your time trying to figure this
- 19:34out because much of it is not, it's really useful, but it's not like, you don't feel like
- 19:39you're a better person for having figured this out.
- 19:42It's just, it's the getting, it's an obstacle.
- 19:45And I'm trying to get people past those obstacles that can use this useful technology.
- 19:48Yeah.
- 19:49Well, there's a lot of stuff that you talk about that is not necessarily something that
- 19:52would be front of mind, like security, like how to manage the versioning over time and
- 19:57so on.
- 19:58But I think also it would be quite satisfying to have, you know, take something that's janky
- 20:03and maybe it does have that like one hour banner on Sunday, we're going to be down from three
- 20:07to four upgrading our site and, and be able to remove that and say, no, we just deploy a
- 20:12couple of times a week now.
- 20:13We don't think about it because it's git push prod and then wait 30 seconds.
- 20:19And then prod is now the new one.
- 20:20Right.
- 20:21Yeah.
- 20:21I think that's a very good feeling.
- 20:22Yeah.
- 20:23And there's a bunch more you need to do that than what I talk about.
- 20:26I'm talking about one piece.
- 20:27There's also the deployment process and that there's having good observability and
- 20:31logging, even just the packaging part of it.
- 20:33Like there's a lot of details to get right that can make it a lot easier.
- 20:36Yeah.
- 20:36So the way you started the presentation, your first thought for this was that packaging,
- 20:42this whole Docker as production, packaging your app and Docker for production is an iterative
- 20:48process and maybe also layers, right?
- 20:51Like, so you sit, you don't necessarily start with the whole, well, we want zero downtime.
- 20:56You start with, can we make it run in Docker?
- 20:58Yeah.
- 20:58And you don't have to do it as an iterative process.
- 21:01Like if you can manage to keep all this in your head, which honestly, I can't, but there's
- 21:05too many details.
- 21:06Or if I were to start Dockerizing something, I would probably do a bunch of it in one go
- 21:11because I remember some of it.
- 21:12But if you're doing this at your job and you probably are like someone's, there's going
- 21:17to be an emergency or someone's going to pull you over or there's going to be a bug that
- 21:21you have to fix.
- 21:21And so you're going to get pulled away at some point.
- 21:23And so what you'd like to do is build your packaging in a way where if you're interrupted,
- 21:29you have to stop, you have to put it on hold.
- 21:31You can put it aside and know you're a good stopping port and you want to sort of prioritize
- 21:35the most important ways.
- 21:37So if you run, like you may just run out of time budget, like you just have limited time
- 21:42and you want to do the highest priority things first.
- 21:44And if you ever have more time, you can-
- 21:46Well, it sounds like what you're describing is a little bit of what happened to the software
- 21:50development side of things when it went from waterfall to agile or waterfall to something
- 21:55better, right?
- 21:56So many projects used to say, well, what we're going to do is we're going to build it until
- 21:59we're going to work on it for six months.
- 22:01And it's not going to be actually usable in any meaningful way until that six month point.
- 22:06And then maybe it drags on and it goes over budget and gets canceled.
- 22:09And there's just all sorts of, you know, you get no user feedback.
- 22:12There's all these kinds of problems trying to build software.
- 22:14So it doesn't surprise me that there would be lots of advantages to trying to apply that
- 22:19same sort of iterative thinking.
- 22:20Like, let's make sure that each step along the way, we have something that's useful and
- 22:25more useful than it was before.
- 22:26Yeah.
- 22:27And also, even if you know you have the time budget to do all of it, having a good understanding
- 22:32of the priorities means you can focus on the really important things.
- 22:36Yeah.
- 22:37Like large images are very visible.
- 22:39Like it's very easy.
- 22:40Like you can look at your image and say, why is this two gigabyte?
- 22:42Like this is ridiculous.
- 22:44And then you can go into this rabbit hole of like trying to make your image smaller.
- 22:48And that's a fine thing to do.
- 22:50But if you deploy an image that's insecure and nice and small, that's not the best trade-off.
- 22:57I would venture to say that your organization would not praise you for your efforts to make
- 23:03it small.
- 23:04But rather, they would be pretty upset about the security problems, right?
- 23:07Yeah.
- 23:07Yeah.
- 23:07And so like security seems like a high priority, like automation's high priority.
- 23:13And the order you might actually do it, it might be slightly different depending on your
- 23:17particular domain you're working on.
- 23:19Right.
- 23:19But yeah, you want to think about.
- 23:21It's a bit of a priority stack, right?
- 23:23Like what is most important to me or what is most foundational to the whole, this whole
- 23:27packaging and Docker process.
- 23:29Yeah.
- 23:29So you actually put up some six points that you thought were sort of stages in your talk.
- 23:35Yeah.
- 23:35Get something working.
- 23:36That's just, can you use Docker at all?
- 23:38Obviously, if it doesn't work, it's not going to be useful.
- 23:40And then number two, even before continuous integration, security.
- 23:43I can see that people would overlook that, but that's not trivial, right?
- 23:47Yeah.
- 23:48And like security is sort of a never ending thing, like, because you have to deal with security
- 23:54updates.
- 23:54But if you want to, like, you don't need complete automation to like spin up a server somewhere
- 24:01and test something.
- 24:02Like if you're using Heroku, you can like push a Docker image to Heroku and spin up a server.
- 24:06Yeah.
- 24:06You could manually do a git push.
- 24:08Yeah.
- 24:09You can push stuff.
- 24:10But, and then try it out.
- 24:12But if it's talking to like a production database and it's not secure, that's the problem.
- 24:17And packaging is only one small part of the security and most of it's going to be application
- 24:22security, but it still comes into it and it's still important.
- 24:25Right.
- 24:25Right.
- 24:25Little Bobby tables is still a problem, even if it's running in Docker.
- 24:29Yes.
- 24:30That's right.
- 24:31Okay.
- 24:32So number two is security.
- 24:33And then number three is continuous integration.
- 24:36So making sure that like when we check in code that it's tested in Docker, guessing the tester
- 24:43run, the system, something of a Docker compose up type of thing happens and it's all good.
- 24:48Then correctness and debugability.
- 24:51So correctness is obvious, right?
- 24:53It needs to work.
- 24:54It needs to have fresh data.
- 24:55It can't have like stale caches and weird things like that.
- 24:58But debugability is interesting.
- 25:00Maybe you want to focus on that for just a sec?
- 25:02Sure.
- 25:03So the idea is that like once you have automated builds, you might start actually running things
- 25:08for product in production for real.
- 25:09Or even if not, you're going to have, if you're building an image for every pull request, now
- 25:14you have a bunch of images.
- 25:15And so someone files a bug.
- 25:17How do you know what version of your code, like which Docker image, do they know which Docker
- 25:20image they were using?
- 25:21What version of the code it matches to?
- 25:22If something crashes, like, are you going to get actual, are you going to get logs that someone
- 25:27can report or not?
- 25:28If you don't go to the effort of exporting the volume that has where the logs get written,
- 25:33every new deploy gets a new fresh set of logs.
- 25:36Yeah.
- 25:36So yeah, like logging to standard out or standard error is the other way you deal with logs in
- 25:42Docker.
- 25:42But you need to like put some minimal thought into like, where are my logs going to go?
- 25:47Yeah.
- 25:47Another thing that gets really tricky around that kind of stuff, I feel, has to do with
- 25:52the fact that there's just so many moving parts a lot of times.
- 25:54You know, you've got your Celery Docker container.
- 25:57You've got your Redis Docker container.
- 25:59You've got your Postgres Docker container.
- 26:01You've got your app Docker container.
- 26:03You're doing microservices, like who knows how many.
- 26:06And then all of those things have logs.
- 26:08Do you use anything, any of the services that try to bring all those logs into one place?
- 26:13Not a huge amount of experience on any particular one.
- 26:16I have, or I've built a system like that, which these days I wouldn't recommend using, but
- 26:22it's more for this point only for scientific computing.
- 26:24Yeah.
- 26:24But before the log as a service, log aggregation as a service was a thing.
- 26:30Yeah.
- 26:30I've worked on like airline reservation system.
- 26:32I had one of these.
- 26:33And this was a like eye opener for me being able to see logs going between five services
- 26:38in like multiple different protocols.
- 26:41So you could make debugging vastly simpler.
- 26:44Yeah.
- 26:44So you really like anything that lets you trace across services with a tracing ID will
- 26:51make your, like once you have more than one service, it'll make your life much easier.
- 26:54However, I, my recommendation is avoid microservices unless your company has 500 people or something
- 27:02like that.
- 27:02Yeah.
- 27:03It's an amazing architectural design pattern when there, there needs to be autonomy for
- 27:09different parts of the application.
- 27:10Like this team works on the front end little bits here.
- 27:13This team works on the user authentication and identity part APIs.
- 27:18And, but you know, looking at the most recent PSF JetBrains survey, that is not the number
- 27:25of employees, number of people on a team type of description for most Python developers.
- 27:30It's like a handful of folks all working on a lot of it.
- 27:34Right.
- 27:34Yeah.
- 27:34And if you look at the companies that are doing microservices successfully at scale,
- 27:38they will have a team of, you know, three to five people working on one service.
- 27:42So if you have a team of five people, 20 services, you are doing like a hundred times more services
- 27:48per developer than the big companies.
- 27:50Yeah.
- 27:50And that's a lot of complexity you've just added to your life and it is often unnecessary.
- 27:56Yeah.
- 27:56Here, let's, I'll pull up the survey.
- 27:59So Python developer survey 2020 results.
- 28:02If you search in that for team, not team city, employment work, working in a team versus
- 28:07working independently, about half the people work on a team.
- 28:10But if you look at the team size, 75% are two to seven.
- 28:13Yeah.
- 28:13That should be one microservice.
- 28:15Yeah.
- 28:15It's really microservices.
- 28:17And there are applications that are actually, there are distributed systems where you actually,
- 28:21it makes sense to do more, but like any time you make something more distributed, you
- 28:26are adding a vast amount of complexity.
- 28:28And so if you can avoid it, avoid it.
- 28:31Yeah.
- 28:31Well, here's the way that I think about it.
- 28:32I think about microservices.
- 28:35They have a tons of value and they move where the complexity of your application lives.
- 28:41So what you end up with is very simple, relatively simple, small, easy bits of code.
- 28:47But what you also end up with is a much more complex deployment DevOps coordination story.
- 28:53So when I think about microservices, the farther you go towards microservices, the more you're
- 28:57taking the code complexity of a large app and architectural patterns and separation.
- 29:02And you're saying, well, we don't need any of that.
- 29:03Let's make it real simple.
- 29:04And we move that complexity to coordinating a bunch of services that are always up, that are
- 29:09debuggable across services and versioned and all those things.
- 29:13And when I think about that for me, I'm way better at software complexity than I am at deployment
- 29:18complexity.
- 29:18So I'm more successful not putting it where I don't have my experience or skillset.
- 29:23You know?
- 29:23It's actually software complexity too, because if you call a function, you're going to call
- 29:28a function.
- 29:29If you send a message to another service, it may never arrive.
- 29:32It may be delayed arbitrarily.
- 29:34Yeah.
- 29:35And so the communication becomes and the reliability of a thing you're calling, the switch from a
- 29:42function within the same process to remote service is a sort of huge increase in unpredictability
- 29:48and sources of error.
- 29:49That's a good point.
- 29:50Because as for many things that could go wrong with, say, calling some function or a
- 29:55sort of class level method, not having it get called is not one of the things you'd have
- 30:00to worry about.
- 30:01Yeah.
- 30:02Right?
- 30:02You might crash because the file system isn't there, isn't accessible.
- 30:06The database isn't there.
- 30:07But it's not that you couldn't even call it, right?
- 30:09That's going to happen.
- 30:10Yeah.
- 30:10Before we move on, Kim says, FileBeat, Logstash, Prometheus, and Protainer.
- 30:16Oh, Protainer.
- 30:17I've never heard of that one.
- 30:18Can all help with logs from Docker in various ways.
- 30:20Awesome.
- 30:20Good resources to check out.
- 30:22Okay.
- 30:22Last one on your quick hit list before we dive into some of the details is faster builds
- 30:27and smaller images.
- 30:28I think we skipped reproducible builds.
- 30:31Who needs reproducibility?
- 30:32Yeah.
- 30:32Let's go with reproducibility.
- 30:33Yeah.
- 30:34And so this is the static versus dynamic change of dependencies that you talked about,
- 30:39where on the one hand, you really don't want every time you reinstall your application to
- 30:44get the latest dependencies because a new version of Django comes out.
- 30:48You don't want your code to suddenly start running on it just because it came out.
- 30:52Right.
- 30:52And maybe you're not aware, right?
- 30:53Because you have the older version of Django, as you suggest, and you're working on it.
- 30:58You git push.
- 30:59It goes to CI.
- 31:00And then that ideally is going to like some sort of continuous delivery and it's grabbed
- 31:05just the latest, which is not what you had.
- 31:07And then it runs with it.
- 31:08Like that could be bad news.
- 31:09Yeah.
- 31:09This happens a lot of like dev tools.
- 31:11And then like, oh, I'm going to go check if there's been a new release today.
- 31:15And the matter is less.
- 31:16But when it's your actual production software, that's not, oh, I wasted 20 minutes figuring
- 31:21out a failed build.
- 31:22It's my code is acting weird in production.
- 31:25On the other hand, if you just freeze all your dependencies and never change them, then
- 31:29at some point you're going to be running on a version of software from two or three or
- 31:34five years ago.
- 31:35Like I've, the extreme cases, like there are organizations still running on Python too.
- 31:40And this is, becomes very problematic because upgrades become more and more terrifying the more
- 31:48you put them off.
- 31:49Because it's not just like Django.
- 31:51It's like, you have to upgrade Python and Django and three other major libraries you depend
- 31:56on.
- 31:57And it's, it's like this project.
- 32:00And it's a project that's not features or bug fixers or anything.
- 32:04It's just risk.
- 32:05But if you put it off more, then it's more risk.
- 32:07And so you need a process that's ongoing.
- 32:09So you need both in the short term to be, make sure your builds are identical, reproducible
- 32:14and long or mostly identical.
- 32:16And then the longterm you need the process to continuously update so that upgrades are
- 32:21not this terrifying thing.
- 32:22They're just a standard part of your development process.
- 32:24Yeah.
- 32:24I had Carlton and Will on from Django chat a while ago talking about deployment.
- 32:29And we came up with the idea that there are basically two types of applications.
- 32:33There's ones that you're going to continue to add features to, and you're going to care
- 32:37about, and you have a, maybe a team dedicated to it.
- 32:40And for those, you never want to be that far from the latest thing.
- 32:43Just like you described, the farther you get, the more frightening and the more potential
- 32:47problems you have if we take on the latest, right?
- 32:50Because if you're on Django 2 and it's Django 4.5 is out in some future world, you're like,
- 32:56well, we finally need to move to get that because the other one's gone fully unsupported.
- 32:59Well, that's like you said, as a project.
- 33:01Because if you're always kind of just in dev, sort of rolling into later one and then deciding
- 33:05to roll that out, like that's a much smaller challenge.
- 33:08So those should absolutely stay there.
- 33:10Also, we talked about a set of apps, a type of app that falls into the, please don't
- 33:16touch it.
- 33:16And if you do touch it and break it, it's now your baby.
- 33:19It's some horrible legacy code.
- 33:22The person who created it probably doesn't work at the company anymore.
- 33:25Nobody really likes it.
- 33:26It's not important, but it needs to be there.
- 33:29Like it's some internal app or something, right?
- 33:30Like maybe those, you just freeze those in time.
- 33:34They're very likely not public facing or something.
- 33:37But certainly if you care about continuing to work on this thing and adding features to
- 33:41it and it matters, then keep it not too far.
- 33:44That's the tension.
- 33:45You don't want to just constantly ship the latest thing because maybe that's a major release of
- 33:50some library, but at the same time, you don't want to freeze it.
- 33:54This portion of Talk Python To Me is sponsored by Linode.
- 33:57Visit talkpython.fm/Linode to see why Linode has been voted the top infrastructure
- 34:02as a service provider by both G2 and TrustRadius.
- 34:05From their award-winning support, which is offered 24, 7, 365 to every level of user,
- 34:11to the ease of use and setup, it's clear why developers have been trusting Linode for
- 34:15projects both big and small since 2003.
- 34:18Deploy your entire application stack with Linode's one-click app marketplace or build
- 34:24it all from scratch and manage everything yourself with supported centralized tools like Terraform.
- 34:28Linode offers the best price-to-performance value for all compute instances, including GPUs
- 34:34as well as block storage, Kubernetes, and their upcoming bare metal release.
- 34:39Linode makes cloud computing fast, simple, and affordable, allowing you to focus on your
- 34:44projects, not your infrastructure.
- 34:46Visit talkpython.fm/Linode and sign up with your Google account, your GitHub account,
- 34:52or your email address, and you'll get $100 in credit.
- 34:55That's talkpython.fm/Linode, or just click the link in your podcast player's show notes.
- 35:00And thank them for supporting Talk Python.
- 35:02Quick comment back to the monolith.
- 35:07Tolines says, can you speak to microservices versus monolith, in particular for ML applications?
- 35:14I think that's a little bit different.
- 35:16I haven't really thought of it from an ML perspective.
- 35:17You got thoughts?
- 35:18My decent, a decent rule of thumb is, are you working on a web application where there's
- 35:23hundreds of developers working on that application?
- 35:25And the answer is yes.
- 35:27Then someone in the organization is going to bring up microservices.
- 35:32Anything smaller than that, just don't think about it.
- 35:37Once you're small enough, I tend to feel the same way about Kubernetes.
- 35:42There's a lot of technologies for a company with 5,000 people or 500 people or 50 people
- 35:48or five people or one person.
- 35:50Each organizational size, you're going to want different technologies because different
- 35:54architectures because, when I say applications, we'll have 500 developers or five developers
- 35:58because your ability to specialize, your ability to build infrastructure are different.
- 36:03And so if it's a thing that an organization that has thousands of developers working, like,
- 36:08are you building Pinterest?
- 36:10Probably not.
- 36:11Then the technology sources Pinterest makes may not be relevant to you.
- 36:15Yeah.
- 36:15I think maybe another consideration is how much is part of that functionality shared?
- 36:19Are you building an API that has some models that make some prediction that a whole bunch
- 36:24of your company and different apps and websites and such might need?
- 36:28And, you know, maybe that's its own thing.
- 36:30But if it's only being shared in one place, maybe not.
- 36:34There's an interesting article that was from 2019.
- 36:37Might be worth people checking out.
- 36:39It's called Give Me Back My Monolith from Craig Kirsten's.
- 36:44Anyway, I'm not going to go into it here, but it's kind of an interesting read.
- 36:48People can check that out if they want.
- 36:49All right.
- 36:50We talked about faster builds and small images now.
- 36:52We're there.
- 36:53Tell us about that.
- 36:54People who are new to Docker, haven't done a lot with Docker.
- 36:56There's a lot of things you can do to result in a smaller, physically a smaller image size,
- 37:04right?
- 37:04A smaller file on disk.
- 37:06Yeah.
- 37:06It's very easy to get a giant image in Docker because the Docker image format is basically
- 37:12in many ways like a Git history.
- 37:14So every time you make a change, it's not overriding.
- 37:17It's adding.
- 37:18So there's a history there.
- 37:19The history is always there.
- 37:20So if you delete a file, it doesn't make the Docker image any smaller if it was added in
- 37:25a previous layer.
- 37:25Right.
- 37:26If it was added in a different layer, that's right.
- 37:27Yeah.
- 37:28If you structure things right, there's a bunch you can do to make your images smaller.
- 37:31And similarly, Docker has a bunch of features to allow you to not have to run pip install
- 37:39every single time you rebuild your image because the dependencies haven't changed.
- 37:42So it can just cache those files for you, but you have to set it up right.
- 37:46So it does that.
- 37:47And you can go from a half an hour build to a one minute build depending on how you built
- 37:54your Docker image.
- 37:55So LP Linux being my current favorite example, although maybe that's going to get fixed over
- 37:59the next year.
- 38:00One of the things that's super interesting about that as well is the ordering as well as the
- 38:04grouping of those commands can really matter.
- 38:08So for example, if the first thing that you do in your Docker file is to copy over your source
- 38:14code, then the next thing to do is to do an apps update, apps upgrade.
- 38:19Then the next thing to do is to install the dependencies and so on and so on.
- 38:24Right.
- 38:24Every time any file that you're working on, even like an unrelated CSS file changes, everything
- 38:30below that has to be rebuilt.
- 38:31Right.
- 38:31And if you make a point to say, well, let's reorder that.
- 38:34So the very last thing we do is copy our files over.
- 38:37Then as you make changes, like you won't, those other layers will just be up to date.
- 38:42And one cool trick that I've seen that you can make that even better is somewhere in that
- 38:46intermediate bit.
- 38:47You could even copy your requirements or pyproject.toml file over and then install those and then
- 38:53copy the rest of your code over, which looks like a stupid duplication.
- 38:57Like, why are you just copying this one file?
- 38:58You already copied it in the next one, but you can cache that pip install, pip compile step,
- 39:04make it faster.
- 39:04Yeah.
- 39:05But basically, if you understand how Docker caching works, then you can sort of structure
- 39:11Docker file in the right way.
- 39:12And then you get caching.
- 39:14Then you need extra steps to get it working in CI, but you can get a much faster build.
- 39:18So it'll work.
- 39:19The fast scene is super clear.
- 39:20Tell us about smaller though.
- 39:21What do you really focus on for smaller?
- 39:23So some of it is just things where various packaging tools are optimized for development
- 39:29by default.
- 39:30So if you do pip install and you do something like NumPy, this can be, or if you're, let's
- 39:35say, let's go, the big packages, like things like TensorFlow, like these packages, some of
- 39:41these packages are hundreds of megabytes.
- 39:42Like they're just huge.
- 39:44So you download the package and then it unpacks it and installs all the files.
- 39:49And then by default, pip will keep a copy of that downloaded file in a directory.
- 39:53Probably the intermediate build output.
- 39:55The wheel file you downloaded.
- 39:57Potentially all that stuff.
- 39:58Yeah.
- 39:58It'll keep a copy of the wheel file.
- 40:00The idea is like you might be doing another virtual end in another two hours.
- 40:07And so when you do pip install, this time it can just, it doesn't have to download it.
- 40:10It can just use the cache version.
- 40:11And for development, that's great.
- 40:13But for a Docker image, you are never going to call pip install again.
- 40:18So keeping this file is just like an extra 400 megabytes of this space.
- 40:22And so there's a command line option for pip install.
- 40:25It says --no cache there.
- 40:27Yeah.
- 40:27And then it doesn't keep a copy.
- 40:28And now you're, you haven't, you're free to put a bunch of space by adding, which can be
- 40:34fairly considerable if you're doing certain, especially for data science tools.
- 40:38Right.
- 40:39You add it up across all the dependencies and their transitive dependencies and so on.
- 40:43Right.
- 40:43Yeah.
- 40:43That's like just not storing files you don't need.
- 40:46One of the mind shifts you got to get into to work with this stuff is you will never, ever
- 40:52change the Docker configuration.
- 40:54Right.
- 40:55It's not like, oh, there's updates to Linux.
- 40:57So I'm going to go in and like app update it, or there's an update to my requirements.
- 41:00So I'm going to reinstall the requirements.
- 41:02You recreate a new Docker image and you throw away the old Docker image.
- 41:05Right.
- 41:06So there's a lot of the things that are there to make that next step.
- 41:09Right.
- 41:10Pip installing, again, work well are just liabilities and negative effects on your Docker image.
- 41:16Right.
- 41:16Yeah.
- 41:17Because Docker images are sort of designed to be treated as immutable artifacts, which is
- 41:23sort of great.
- 41:24But also like you're dealing with a whole bunch of tools that don't really have that assumption.
- 41:28And so you have to figure out ways to make those two conflicting goals work together.
- 41:33Yeah.
- 41:33Another interesting thing that Peter brought up, Peter McKee in the other episode we did
- 41:39not too long ago, was intermediate frameworks and all sorts of stuff.
- 41:43It doesn't apply super well to the Python space, but maybe there's certain aspects, especially
- 41:49in the data science side that might.
- 41:51So for example, if you're going to install like the development setup for Python, not
- 41:55just the ability to run, but to do pip installs and do all sorts of things.
- 41:59The example he gave was if you're going to have something that runs in Go, well, one of the
- 42:04steps you might install might do is like, well, we're going to install the Go compiler and
- 42:08all that business.
- 42:08And we're going to compile the artifact.
- 42:10And then you would try to run it.
- 42:11It's like, you create a separate container that will take the code and compile it and
- 42:16give you the binary, just copy the binary without the compiler back in there.
- 42:20So maybe there's some techniques like that.
- 42:22I don't know.
- 42:22I mean, I don't see it quite as well in Python because we can't fully package it up as reliably.
- 42:27But yeah.
- 42:28So a common, so this happens a bunch if you're compiling your own custom C extensions.
- 42:33Yeah.
- 42:34So one way you can deal with that is like, you can have a thing that generates wheels and
- 42:38then like you build your Docker image, you just download the compiled wheel.
- 42:41But if you want to do it in your Docker image, you're going to have to install a compiler,
- 42:45but then you don't, that compiler package is going to be in your final image.
- 42:49So it just makes your image bigger.
- 42:50You don't need GCC.
- 42:51And so you can use a multi-stage build, which is probably what he was describing.
- 42:56Yeah.
- 42:56So the one easy way to do that is you create a virtual env, install all your code, and then
- 43:02you copy just the virtual env into a new Docker image.
- 43:06And then the new Docker image just has the resulting self-contained virtual env, doesn't
- 43:10have any of the compilers that you needed to build it.
- 43:11Right.
- 43:11No matter what else might've been over there.
- 43:14Yeah.
- 43:14Yeah.
- 43:14Maybe you could even use something like PEX if you really cared to like compile that or
- 43:18to bundle that into a zip and then run that directly.
- 43:20I'm not sure, but possibly.
- 43:22Yeah.
- 43:22Tim out there in the live stream says, dash dash, no cash dir has made my evening.
- 43:27Thanks.
- 43:27I never thought about it.
- 43:28The intermediate files from pip only from app.
- 43:30Yeah.
- 43:31Then also Docker on build option can help a bit with that scenario.
- 43:35Yeah.
- 43:36But not including the dev tools.
- 43:36Okay.
- 43:37That's cool.
- 43:37I may have deprecated on builds, but I could be misremembering.
- 43:41That would be too bad because I just learned about it.
- 43:43Okay.
- 43:45Those are the six things that you talk about in this iterative process or this layered process.
- 43:49It's like step one, your first deliverable or your first package of this as Docker sprint
- 43:55would be get something working in either the single container or the suite of containers
- 44:00from Docker Compose.
- 44:01Step two is make sure they're secure.
- 44:03Step three, getting them running in CI.
- 44:04Step four, make sure that they're correct and debuggable.
- 44:08Number five is reproducibility with that balance of not exactly the latest, but not super old
- 44:14and stale.
- 44:14And then finally fast builds and small images.
- 44:17Yeah.
- 44:17And then along the way, there's a whole bunch of different things you can do depending what
- 44:22tools you're using and like what's your priorities are.
- 44:25And yeah.
- 44:26Can maybe give some examples if we have time.
- 44:28Yeah, absolutely.
- 44:29We got a little bit of time.
- 44:30I thought that'd be fun.
- 44:31So we could dive into just get something working, which is like a hand line of a couple of lines
- 44:38in Docker, like see Docker symbol.
- 44:39Yeah.
- 44:40Yeah.
- 44:40You choose a base image, copy your code and run pip install and say, this is what I want
- 44:45you to run when you start up.
- 44:46And for many applications, I'll do the trick.
- 44:48So I'm always wondering what is a good container base to start from, right?
- 44:53So you have this Python 3.9 Slim Buster version as the base.
- 44:59Yeah.
- 44:59There's a bunch of different options, right?
- 45:00What do you think?
- 45:01So the first thing is you want a, these are all based on Linux distributions typically.
- 45:06So you want a Linux distribution that's some sort of long-term support where like they are
- 45:10both guaranteeing backwards compatibility in terms of like binary ABIs, but also in terms
- 45:16of features, but they're also doing security backboards.
- 45:19So like Debian stable, Ubuntu long-term support, Red Hat Enterprise Linux, they all are going
- 45:24to give you this stability guarantee.
- 45:27They'll say, we'll give you a stable operating system with security updates to it.
- 45:31So you want something that's based on one of those probably.
- 45:33And then you need to, you typically are going to want a up-to-date Python.
- 45:37And these distributions will sometimes like backport, new versions of Python.
- 45:43And so you can use that.
- 45:44So you can say, I'm going to use like Ubuntu long-term support from 2020.
- 45:50And like it has Python 3.8 and maybe they just added 3.9.
- 45:54I'm not sure.
- 45:54I saw something to that effect.
- 45:56And then you can go with that.
- 45:57Or Docker maintains these things for the official, in quotes, Docker images for Python.
- 46:04And basically what they do is they take Debian stable and then they compile all the different
- 46:09versions of Python for it.
- 46:10So you can get 3.7 or 3.8 or 3.9 and 3.10 when it comes out, regardless of what's in Debian
- 46:14stable.
- 46:15So it's Debian stable plus an extra Python.
- 46:17So Python colon 3.9 is Debian stable plus 3.9.
- 46:22Then they have two variants.
- 46:24One has a bunch of extra packages and one has fewer.
- 46:27One with fewer packages is the dash slim.
- 46:29And then the dash buster is which version of Debian you're using.
- 46:33And the reason you don't have to specify that, but like maybe like at the end of the year,
- 46:38maybe early next year, there's going to be a new version of Debian stable.
- 46:41And so you don't want overnight to go from Debian 10 to Debian 11 as your base image.
- 46:46You would probably want to just at least do that consciously, right?
- 46:51And so saying dash buster means I want to stick to Debian 10 buster.
- 46:56And for those who don't know, Debian Linux releases are based on Toy Story characters.
- 47:00Nice.
- 47:01So Buster is one of them, right?
- 47:03Yeah.
- 47:03And I don't remember what the next one is.
- 47:07There's Debian unstable, which is named CID.
- 47:09It's always Debian unstable and it's always CID.
- 47:12They never release it.
- 47:13That's cool.
- 47:14All right.
- 47:14So in this example, it's the Docker file says from Python colon 3.9 dash slim dash buster,
- 47:21which means all the stuff that you described there.
- 47:24And then you copy your files over, you run pip install to install the dependencies.
- 47:29And then you just basically start your app as the entry point.
- 47:32And that is, hey, we got something working.
- 47:34This is probably an oversimplification.
- 47:36There might be a database thing that also needs to start up and run its bits and so on.
- 47:41But yeah, that's pretty much it, right?
- 47:43It's pretty simple.
- 47:44Typically pretty simple to just get everything's working because it's just install some packages
- 47:49and then tell it to run the scripts when you run a container.
- 47:52Yeah.
- 47:52It's pretty much whatever you need to do to get a new machine set up to run this,
- 47:57do that in this file and you're good to go.
- 47:59Yeah.
- 47:59And I guess seeing a comment on the chat and I should add that as far as I can tell,
- 48:04Docker on build is not deprecated, but I'm not sure.
- 48:08So maybe.
- 48:09All right.
- 48:10All right.
- 48:10I'll have to look into it.
- 48:11Sounds good.
- 48:12So getting it working is super straightforward.
- 48:15Yep.
- 48:15But getting something secure is interesting.
- 48:18Let me go back.
- 48:19I think we might be skipping around a bit,
- 48:20but you're talking about having that version specified there of Slim Buster.
- 48:25I know how we'll get new dependencies for the Python code up there.
- 48:30And if there's some kind of security problem,
- 48:32what will probably happen is Dependabot on GitHub will send me a PR that says,
- 48:37warning, warning, your version of web framework has such and such CVE.
- 48:41We've created a PR.
- 48:42You accept it.
- 48:43You push it back to the right branch.
- 48:45That kicks off the whole process and everything goes again, right?
- 48:49That keeps like the flow of the somewhat fresh code and dependencies going through your system.
- 48:55However, how do I keep that same thing happening for Linux, right?
- 49:00Suppose Linux has some security vulnerability in the version that I've got,
- 49:04or I've got Nginx running and it has something like that I need to update.
- 49:08Like, what is the trigger that helps me know?
- 49:12Like, what is the process that helps me know?
- 49:14Oh, you need to, even if this is a somewhat stable, stale project that we haven't touched for a month,
- 49:19you need to somehow go give it a kick to like force it to get the latest and do that again.
- 49:23Because there's no auto app upgrade running there.
- 49:27Yeah.
- 49:27So one thing to note is some people assume that the Debian,
- 49:31like the official Python or even official Debian or whatever,
- 49:34the official base images from Docker get security updates every time they come out.
- 49:38They don't.
- 49:39Some of them get updated fairly frequently.
- 49:42Some of them, like the CentOS one, which I guess people are probably switching away from,
- 49:46but for a while it was a lot of people probably using it.
- 49:49The CentOS base image will not be updated for months at a time.
- 49:53And so they are relying on, and the Debian ones,
- 49:57well, I have seen them like lag on security updates by two weeks.
- 50:00So Debian has released a new security update, but the Docker image hasn't been updated.
- 50:04Which is not ideal because you're telling all the hackers,
- 50:07here's the problem that you can just go look for in systems that lag on getting their patches.
- 50:11Yeah.
- 50:12And so you as someone who is creating a Docker image cannot rely on the base images to be up to date.
- 50:18You need to install security updates when you build your Docker image.
- 50:22But what's that look like?
- 50:23The step two is apt update, apt upgrade, dash Y, or something like that?
- 50:28Yeah.
- 50:28apt get update, and then apt get minus Y upgrade.
- 50:31You can add a few more command line options to make your image smaller.
- 50:34But yeah, it's basically you do an upgrade.
- 50:36But there's a problem.
- 50:38Docker has, as we talked about, has this caching thing,
- 50:40where if you rebuild an image and nothing's changed, it will just use a cache layer.
- 50:45So when you rebuild your image, if you are using caching to speed up builds,
- 50:48it'll look at Docker apt get, look at the apt get update, apt get upgrade,
- 50:51and say, well, this is unchanged.
- 50:53Same command.
- 50:54And so it'll just use a cache layer.
- 50:56Yeah.
- 50:56And you absolutely will very likely be doing that.
- 50:59Because it's like five minutes versus three seconds to restart and build and test your app.
- 51:04So everyone is going to be using the caching.
- 51:06Maybe not CI, CD, but everywhere else.
- 51:09I mean, you probably typically will want it in CI, CD too.
- 51:12And so the result is that if you've set up caching to speed things up,
- 51:16that caching will ensure you don't get security updates.
- 51:19And so basically what you have to do is just have this process where once a day or once a week,
- 51:26or in response to CVs coming out, you rebuild your image from scratch without caching.
- 51:31So you can just say every night at 3 a.m. when no one's working,
- 51:35we are going to rebuild our image from scratch without caching.
- 51:40And so our image will always have the latest security updates.
- 51:45And then if you're in a system that has continuous deployment,
- 51:47you can then just automatically deploy that.
- 51:50Wait, how do you make the little banner that says you're going to be down Sunday from 3 to 5
- 51:53when you do that part?
- 51:54Just kidding.
- 51:55Yeah.
- 51:56So this is easier if you have a process that you trust enough to do automatic deploys like anytime you want.
- 52:02But you basically have to rebuild your image from scratch without caching,
- 52:07either whenever a security update comes out or just on a regular basis and redeploy if it's a server,
- 52:14because you have these immutable artifacts that if you're running a VM,
- 52:19like you can just have like a cron job that installs security updates nightly.
- 52:24Like there's unattended upgrades package in Debian.
- 52:26For Docker images, you can't do that.
- 52:28And so you have to rebuild from scratch with security updates and then redeploy.
- 52:32And this is an ongoing process.
- 52:34Yeah, I'm glad you pointed out the caching because it's not enough to go out and say,
- 52:38oh, every once a day or once a week, we'll just do a Docker build.
- 52:42Oh, it's up to date.
- 52:43Actually, we're good.
- 52:43Yeah, no.
- 52:44Not so much.
- 52:46Yeah.
- 52:47Yeah.
- 52:47And that's why I brought this up because I think it's tricky.
- 52:49Like there's a natural flow that like kicks that refresh cycle off for code,
- 52:53but not for the infrastructure itself, unless you think about it.
- 52:57Yeah.
- 52:58So you need to explicitly think about and set up these processes,
- 53:01either some way to get notified of CVs
- 53:03or you can probably, if you have a bunch of registries, have security scanners.
- 53:09They'll scan your images for security problems.
- 53:12And so you can run those in a schedule, maybe.
- 53:14Honestly, the easiest though is probably just do a forced rebuild 5 a.m. or something.
- 53:19Yeah.
- 53:19And that next time every developer that comes in and runs the command Docker compose up,
- 53:24going to do a Docker build.
- 53:25It's going to see the things out of date and it'll just trigger a let's get the fresh.
- 53:28Yeah.
- 53:29Yeah.
- 53:29And it turns out security scanners are also have some,
- 53:33bad defaults.
- 53:34So you'll get,
- 53:36there's a lot of security problems that are not really problems.
- 53:39Like the upstream maintainer has closed it as won't fix,
- 53:42or it's not going to get fixed in Debian stable until the next release of Debian stable.
- 53:47And so the Debian maintainers are basically have decided that it is not worth fixing.
- 53:50And so there's nothing you can do.
- 53:51Most security scanners will flag those.
- 53:53And so you'll run a scanner on an updated image and it'll say,
- 53:56you have 60 security vulnerabilities.
- 53:59But you,
- 53:59if you turn on the flag that says only tell me about security vulnerabilities that I can actually fix,
- 54:04that actually have updates from Debian.
- 54:05And then you run that and it'll say you're fine.
- 54:08And that is probably a much more realistic assessment of your risk because it's like,
- 54:11there are bugs that are never going to be fixed because the GLAB C maintainers have said,
- 54:16no,
- 54:17won't fix.
- 54:18This is not our problem.
- 54:19It's like,
- 54:19it's not a real bug.
- 54:20Yeah.
- 54:21I suspect you could also get notified about things that like are not observable really.
- 54:25So,
- 54:25oh,
- 54:26there's a problem in the system,
- 54:27but we actually have a firewall blocking that port and we have no interaction with it.
- 54:32Right.
- 54:32It's like,
- 54:32how much do you worry about those kinds of things?
- 54:34You may as well upgrade and redeploy because maybe one day your firewall will fail,
- 54:38but like there's a whole bunch of just like utter noise if you don't configure your securities
- 54:43kind of correctly.
- 54:44Yeah.
- 54:44All right.
- 54:45Wrapping up this bit of the topic,
- 54:46Kim says forced rebuild is a great for your own images based on Debian or other OS.
- 54:50You probably still need some kind of scanning.
- 54:52Yeah.
- 54:53If you're not able to build it yourself.
- 54:54Yeah.
- 54:54Makes sense.
- 54:55All right.
- 54:55We got a little bit of time to touch on a couple of things.
- 54:57One of the areas stage two was security.
- 55:01You always want different layers.
- 55:03I talked about a firewall.
- 55:04We're talking about security updates and patches,
- 55:07but there's layers of security you want.
- 55:09And one of the very straightforward ones is you probably don't want to run this as root.
- 55:13And like certain systems will even warn you about this.
- 55:16So if I try to pseudo brew something on my Mac,
- 55:19it'll complain.
- 55:20Like you should never,
- 55:20ever run brew as root.
- 55:21What are you doing?
- 55:22Are you crazy?
- 55:22Stop doing that.
- 55:23I think uWSGI might warn that you're running this root.
- 55:26If you look at the logs when you started up.
- 55:28So when I run Docker and I just get that simple,
- 55:31get started one,
- 55:32what does that run as?
- 55:33Yeah.
- 55:33So by default,
- 55:34Docker runs as root.
- 55:35Oh,
- 55:36okay.
- 55:36That kind of makes sense because all these system packages are designed to be installed as
- 55:40root.
- 55:41And so if you're going to install system packages or install security updates,
- 55:44you have to be a root by default.
- 55:45But as soon as you've,
- 55:47you've switched to like installing your Python code,
- 55:49you should stop being root and create a new user and switch that user because otherwise
- 55:54your application will be running as root and root inside a container is more restricted,
- 55:58restricted, but it's still not as restricted as a normal user.
- 56:02And different runtime systems might take more aggressive steps to restrict what you can do.
- 56:08And so sometimes it might be okay, but just a good best practice.
- 56:11You're, you don't know where your things are going to run.
- 56:13Things might change around.
- 56:14Just don't run as root.
- 56:15What you're saying is basically,
- 56:16if you run as root in a Docker container and somebody takes over your container,
- 56:20well, the worst thing they can do is like crash around inside of the container.
- 56:24It's not like they now have full access to the machine, but, you know,
- 56:28maybe those rights are propagated onward.
- 56:30Like maybe they can do something else to, I don't know,
- 56:33decrypt something that then gets them further in the network.
- 56:37Like there's, there's challenges that could happen, right?
- 56:38So it is much easier to escape a container and onto the host if you're running as root,
- 56:45because you, like in Linux, security access is granted by these things called capabilities.
- 56:51And if you're root, you have a little bit more capabilities.
- 56:54It gives you a larger attack service on Linux kernel.
- 56:57And so if there's a bug in the Linux kernel, it's easier to take it over if you're root.
- 57:01There are other things you can do to like restrict all capabilities to containers,
- 57:05even if you're running as a normal user.
- 57:06So like if you're running the ping utility, for example, it gets a little bit of extra,
- 57:11it gets an extra capability often.
- 57:13So it can do a ping.
- 57:15And then if there's a bug in the ping command, then you can sort of,
- 57:20and you can insert code into it somehow,
- 57:22then it'll execute it with elevated privileges and you can do more stuff.
- 57:25And so.
- 57:25Yeah.
- 57:26You don't want that.
- 57:27Yeah.
- 57:28And so you want to like run as a normal user that will restrict the attack surface on the Linux kernel,
- 57:33like removing all capabilities or restrict the attack surface even more.
- 57:38And you do these things.
- 57:39And for many applications, it won't really matter too much,
- 57:42but it's very, it's not a lot of work.
- 57:45And it's like a little bit more assurance that if someone does somehow take over,
- 57:49you'll limit the damage they can cause because they're only restricted to this container.
- 57:53Yeah.
- 57:53Okay.
- 57:54Good advice.
- 57:54And that uses the add user Docker command.
- 57:56Very cool.
- 57:57And then let's see, what was the next one here?
- 58:00We talked about the security updates.
- 58:02Like that's, that's a challenge.
- 58:04So what do I need to think about for continuous integration automated builds,
- 58:08specifically with regard to Docker?
- 58:10Is there anything special?
- 58:12Like.
- 58:12So first it's just doing the actual work of automating it.
- 58:15So like you really, it's really nice if every time you push to your Git repository,
- 58:20every time you pull it across, it builds a Docker image for you.
- 58:23Because then like you can test it.
- 58:26Maybe you can write additional tests to actually use a Docker image,
- 58:29do integration tests, that sort of thing.
- 58:30Yeah.
- 58:30Like for example, there was a really cool framework or library.
- 58:34I can't remember exactly what it is.
- 58:36We talked about it on Python Byte.
- 58:37That instead of trying to mock out, say your database or,
- 58:41it was mostly databases.
- 58:43There's a Docker, there's like a testing library you can use that will bring up a Docker container
- 58:48running Mongo or Postgres or something,
- 58:51and then fill it with test data.
- 58:52And you just connect those things and say,
- 58:54yeah, you can talk to the database.
- 58:55You don't care.
- 58:56It's test data.
- 58:57Might as well.
- 58:57Yeah.
- 58:58Testing with a real database is so much easier these days.
- 59:00It'd just be the default.
- 59:01Like you shouldn't be, if you're didn't deploy with Postgres,
- 59:04you shouldn't test with SQLite because like they're different enough
- 59:07that there'll be bugs that you're going to miss.
- 59:09Yeah.
- 59:10And so once you have that automation of like building for every pull request,
- 59:14you don't, you start having this issue where you don't want the image you built
- 59:19for the feature one, two, three branch to overwrite your production image.
- 59:23That would be awkward.
- 59:24But you would still like continuous integration to do its job and say,
- 59:27you checked in this thing.
- 59:29It was okay or not okay.
- 59:30Yeah.
- 59:31And it's useful to have like images uploaded for every pull request that you can download
- 59:35and maybe play around with it.
- 59:36But you don't want feature branches images to interfere with your production image.
- 59:40One easy way to do that is to name your Docker images based on the Git branch.
- 59:46So like you can just use the Git branch as the part after the colon, the tag.
- 59:50So it can be like your image colon main, if it's the main branch or your image colon feature
- 59:55one, two, three, it's the feature one, two, three branch.
- 59:56Yeah.
- 59:57That works really well with like Git flow feature branch style programming as well.
- 1:00:01I created an issue.
- 1:00:02Then I create a branch named something along those lines.
- 1:00:05Then I create a PR along those lines.
- 1:00:07And oh, guess what?
- 1:00:08Here's the container that goes with that thing, right?
- 1:00:10Yeah.
- 1:00:10And you can also do things like name your Docker image based on the Git commit.
- 1:00:14So you can sort of go from Git commit to corresponding Docker image really easily.
- 1:00:18Yeah.
- 1:00:18Yeah.
- 1:00:19That's a really cool idea.
- 1:00:19I did find that package, by the way, in case people are interested.
- 1:00:22It's called test containers dash Python.
- 1:00:25Anyway, the idea is you just say like with my SQL container, do your tests.
- 1:00:30And it like literally creates a Docker container with your test data and all that stuff.
- 1:00:34So people can check that out.
- 1:00:35That's kind of cool.
- 1:00:36All right.
- 1:00:36Well, we're getting a little bit short on time here.
- 1:00:39What else do you want to throw out for people who are thinking about a lot of these best practices?
- 1:00:44We touched on a lot of them, but I know there's plenty more to go.
- 1:00:47Like for example, faster builds.
- 1:00:49You talk about, say, pre-compiling the PYC files.
- 1:00:53Yeah.
- 1:00:53That's more for that actually do slower builds, but it'll give you a faster startup.
- 1:00:57That's what I mean.
- 1:00:58Yeah.
- 1:00:58Sorry.
- 1:00:58Since this comes up a bunch, Alpine Linux is not a thing you want, is often not a thing you
- 1:01:04want to use for your Docker base image.
- 1:01:07And the reason is Alpine Linux is highly recommended for if you want small images.
- 1:01:11And it's kind of nice because you install, like installing the Alpine packages somehow, I don't
- 1:01:15know what they do, but it's vastly faster than like installing Debian packages.
- 1:01:19And you get small images and it's kind of nice.
- 1:01:22Problem is Alpine Linux uses a different standard C library than most Linux distributions.
- 1:01:27Most Linux distributions use Glybcy.
- 1:01:29Alpine uses Musil or Musil.
- 1:01:32I don't know how to pronounce it.
- 1:01:33And binary wheels are compiled by default on Linux for Glybcy.
- 1:01:39And so if you install Python packages on Alpine Linux, you will not get binary wheels.
- 1:01:45You're going to have to compile them from scratch.
- 1:01:46And so what happens is people say, oh, I'm going to use Alpine Linux.
- 1:01:49It's going to make my images smaller.
- 1:01:51And they try to install like a Postgres package, which is pre-compiled and doesn't work.
- 1:01:55They're like, okay, so now I'll install a compiler and I'll install the Postgres headers.
- 1:02:00Now you have this image that has compiler and Postgres headers in it, and you have to compile
- 1:02:05stuff.
- 1:02:05And like when you get to like data science or scientific computing, you're like compiling
- 1:02:10these massive packages that take a really long time to compile and all your builds are super
- 1:02:14slow.
- 1:02:15And you can do a whole bunch of work to then use a multi-stage build so your image is small.
- 1:02:21And then you can use caching so the builds are fast.
- 1:02:23And then, but, or you can just use a different Linux distribution and use binary wheels.
- 1:02:28Don't cause yourself the challenge.
- 1:02:30Just use something else, huh?
- 1:02:31But there is a PEP that I believe was accepted to start the process of building wheels for Alpine.
- 1:02:38And I've started seeing some packaging tools who started adding support.
- 1:02:42And so it may be that in a year or two, it'll be just like everyone builds binary wheels for
- 1:02:48like many Linux, just the Glibsie.
- 1:02:50People might start building wheels, binary wheels for Alpine.
- 1:02:53And when that happens, there'll be much less of an issue.
- 1:02:56But until then, avoid using Alpine Linux as your base image.
- 1:02:59Yeah.
- 1:03:00You want to close it out with a PYC thing?
- 1:03:02Sure.
- 1:03:03So when you start up a Python program, it loads in your Python source files and then compiles them.
- 1:03:09And compilation here is not really the same as compiling a C extension.
- 1:03:12It's basically a one-to-one translation.
- 1:03:14It compiles them to bytecode and writes them out as PYC files.
- 1:03:17And then the next time you start, it can just load the PYC file and that will make your application
- 1:03:22start up quickly.
- 1:03:23And so if you're doing some sort of like, many applications, it doesn't matter.
- 1:03:27If you're doing like a serverless kind of thing where like you want things to start up
- 1:03:32really quickly, like having to compile the PYC is, it's going to add some startup time.
- 1:03:37I guess any times where the container lifetime, the life cycle is short, right?
- 1:03:41Let's say with a web app, you would start it and it would run for hours.
- 1:03:44And so it doesn't matter, right?
- 1:03:45Yeah.
- 1:03:46So it's like it took you another 20 milliseconds to start off.
- 1:03:49It's going to be run for three days.
- 1:03:51But if you're doing like a serverless thing where like 20 milliseconds might be a significant
- 1:03:56chunk of the latency of your service.
- 1:03:58So when you build your Docker image, you can pre-compile all your PYC files and then it'll
- 1:04:03be in the image and you won't have, then your startup will be faster.
- 1:04:05And the reason you have to actually think about this is that Docker images are immutable.
- 1:04:09So like your container starts up, it compiles and writes the PYCs, but those PYCs never make
- 1:04:14it to the original image.
- 1:04:15Every time you start the image, it has the same immutable artifact, unlike your local home directory.
- 1:04:20And so if you really want the fastest startup, you can make your image a bit larger and compile
- 1:04:25the PYCs.
- 1:04:26Basically that becomes a step in your Docker build files to compile the PYCs ahead of time.
- 1:04:31Yeah.
- 1:04:31Okay.
- 1:04:31Awesome.
- 1:04:32Great advice.
- 1:04:33Many, many tips.
- 1:04:33I think we're going to have to leave it there.
- 1:04:36We're getting basically running out of time, but yeah, really nice talk.
- 1:04:39I'll link to your talk that you did at PyCon and thanks for coming here and sharing the audio
- 1:04:43version with us.
- 1:04:44Thanks for inviting me.
- 1:04:45Of course.
- 1:04:46Before you get out of here though, there's the final two questions.
- 1:04:48If you're going to write some Python code, what editor do you use?
- 1:04:50I use SpaceMax, which is kind of like they took Emacs and they configured it like 20 years.
- 1:04:56That's like you're jumping 20 years into the future.
- 1:04:58It's like it's Emacs, but with all the things you need pre-configured to actually have a
- 1:05:03nice development environment.
- 1:05:04And it has VI bindings and Emacs bindings.
- 1:05:07I use the Emacs bindings.
- 1:05:08But if you like Vim, you can use the VI bindings.
- 1:05:10Yeah.
- 1:05:11Cool.
- 1:05:11Their subtitle and sub-subtitle is a community-driven Emacs distribution.
- 1:05:16The best editor is neither Emacs nor Vim.
- 1:05:18It's Emacs and Vim.
- 1:05:19I honestly don't use the Vim bindings at all.
- 1:05:22I'm using it for like, it does all the IDE stuff you want out of the box.
- 1:05:27So it's just, it's a much more modern experience.
- 1:05:30Okay.
- 1:05:30Really cool.
- 1:05:31And then notable PyPI package?
- 1:05:33Py03, which is a way to create Python extensions in Rust.
- 1:05:38I've used it to create both for Phil, my memory profiler, but also I wrapped some Rust library
- 1:05:45with it.
- 1:05:45It's really, really nice way to create fast, safe extensions for Python.
- 1:05:51And it comes, there's a packaging tool called Maturin, M-A-T-U-R-I-N, which was probably the
- 1:05:57nicest Python packaging I've experienced I've ever had.
- 1:05:59Like you add like three lines, like you had a PyProject line file, which is like three
- 1:06:05lines.
- 1:06:05You add like a tiny bit of metadata and now you can build wheels and you can pip install
- 1:06:09and it just works.
- 1:06:11And it's just amazingly smooth development experience.
- 1:06:15That's fantastic.
- 1:06:16Yeah.
- 1:06:16So basically if you're going to write a C extensions, maybe reconsider that and write
- 1:06:21them in Rust and use this possible.
- 1:06:23Yeah.
- 1:06:24It's like Rust is like, gives you the same performance that you would get from C or C++, but it's
- 1:06:31much safer.
- 1:06:31And as someone used to write C++ long ago, like I, I've learned it in the, over the past
- 1:06:38couple of years.
- 1:06:38And it's like, it is the language I always wanted C++ to be.
- 1:06:42Yeah.
- 1:06:42I hear you.
- 1:06:43I did a lot of C++ as well.
- 1:06:44I was always bringing in these things like smart pointers and other stuff.
- 1:06:47It's like, why does it have to be hard?
- 1:06:49Can't we just like make this better?
- 1:06:50It's not a simple language because if you want performance, you need to do work.
- 1:06:53And it, the way it has a very different paradigm, but it's really lovely language.
- 1:06:57You'll write much safer code and Py03 makes it really nice to write Python extensions.
- 1:07:02Yeah.
- 1:07:02Cool.
- 1:07:03Cool.
- 1:07:03And then Talden's out there has a interesting comment.
- 1:07:05Is that like an isotope?
- 1:07:07I think it's a reference to like oxidization, like O3, but.
- 1:07:12Yeah.
- 1:07:12Yeah.
- 1:07:13Because it rusts.
- 1:07:14And there's a lot of oxidizing happening.
- 1:07:15Yeah.
- 1:07:16Around.
- 1:07:17There's also PyOxidizer.
- 1:07:18Yeah.
- 1:07:18There's another project.
- 1:07:19There's another project.
- 1:07:19Yeah.
- 1:07:20That's like a completely different project, but yeah, it's another rust pun.
- 1:07:25Packaging.
- 1:07:26Yeah, exactly.
- 1:07:26Very, very cool.
- 1:07:27All right.
- 1:07:28Final call to action.
- 1:07:29People are interested in this.
- 1:07:31They want to go deeper.
- 1:07:31You've got some various things that you can find on your website, pythonspeed.com slash
- 1:07:36Docker.
- 1:07:37Yep.
- 1:07:37Where do they go?
- 1:07:38What do you tell them?
- 1:07:38Yeah.
- 1:07:38So if you go to pythonspeed.com slash Docker, there's a whole bunch of free articles about
- 1:07:43various best practices.
- 1:07:44If you're specifically interested in the process that we covered today, there's a PyCon talk,
- 1:07:49but also if you go to pythonspeed.com slash Docker process, it's also linked on that page.
- 1:07:54It's like an introduction to Dockerizing for production.
- 1:07:57It's basically like a little mini ebook I wrote that's about 10 pages, but it goes over
- 1:08:02this process that we talked about today and sort of prose and talks about sort of the
- 1:08:06decisions you have to make and how it integrates your organizational processes.
- 1:08:09That's super cool.
- 1:08:10Yeah.
- 1:08:11And on that site, the slash Docker, it has a bunch of articles and it has a very small
- 1:08:15scroll bar and a lot of stuff below it.
- 1:08:17So yeah, there's a lot of things going on.
- 1:08:19People can go check out for more resources there, right?
- 1:08:21Yeah.
- 1:08:22And I have a bunch of paid products if anyone's interested about Docker packaging from intro
- 1:08:26to much more detailed one.
- 1:08:28And if you use the code talkpython, you can get a 15% discount.
- 1:08:32Oh, fantastic.
- 1:08:33Awesome.
- 1:08:33Yeah.
- 1:08:34So be sure to do that.
- 1:08:35Thank you so much for being on the show and sharing a lot of your hard-earned Docker experience.
- 1:08:40Yeah.
- 1:08:40Thanks for inviting me.
- 1:08:41You bet.
- 1:08:42Great to talk to you.
- 1:08:42You too.
- 1:08:43Bye.
- 1:08:43Bye.
- 1:08:45This has been another episode of Talk Python To Me.
- 1:08:47Our guest in this episode was Itamar Turner-Trowing.
- 1:08:50It has been brought to you by Sentry, Linode, and Assembly AI.
- 1:08:54Take some stress out of your life.
- 1:08:56Get notified immediately about errors in your web applications with Sentry.
- 1:09:00Just visit talkpython.fm/sentry and get started for free.
- 1:09:04And use the promo code talkpython2021 when you sign up.
- 1:09:09Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual machines.
- 1:09:15Develop, deploy, and scale your modern applications faster and easier.
- 1:09:18Visit talkpython.fm/Linode and click the Create Free Account button to get started.
- 1:09:23Transcripts for this and all of our episodes are brought to you by Assembly AI.
- 1:09:27Do you need a great automatic speech-to-text API?
- 1:09:30Get human-level accuracy in just a few lines of code.
- 1:09:32Visit talkpython.fm/assemblyai.
- 1:09:35Want to level up your Python?
- 1:09:37We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:09:41Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:09:46And best of all, there's not a subscription in sight.
- 1:09:49Check it out for yourself at training.talkpython.fm.
- 1:09:52Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
- 1:09:56We should be right at the top.
- 1:09:58You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 1:10:03and the direct RSS feed at /rss on talkpython.fm.
- 1:10:08We're live streaming most of our recordings these days.
- 1:10:10If you want to be part of the show and have your comments featured on the air,
- 1:10:14be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:10:18This is your host, Michael Kennedy.
- 1:10:20Thanks so much for listening.
- 1:10:21I really appreciate it.
- 1:10:22Now get out there and write some Python code.
- 1:10:24I'll see you next time.
- 1:10:45Thank you.