forked from mikeckennedy/talk-python-transcripts
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path026_Full_Stack_Pythons_Guide_To_Deployments_UPDATED.vtt
3038 lines (2025 loc) · 104 KB
/
026_Full_Stack_Pythons_Guide_To_Deployments_UPDATED.vtt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
WEBVTT
00:00:00.001 --> 00:00:03.700
So you've built this amazing Python web app, and now what?
00:00:03.700 --> 00:00:06.920
You want to put it online, of course, but that's a whole different skill set.
00:00:06.920 --> 00:00:17.740
Well, today you're in luck because Matthew McKay is here to tell us all about deploying Python web applications on episode number 26, recorded Monday, August 17, 2015.
00:00:17.740 --> 00:00:28.940
I'm a developer in many senses of the word because I make these applications, but I also use these verbs to make this music.
00:00:28.940 --> 00:00:33.460
I construct it line by line, just like when I'm coding another software design.
00:00:33.460 --> 00:00:36.660
In both cases, it's about design patterns.
00:00:36.660 --> 00:00:38.160
Anyone can get the job done.
00:00:38.160 --> 00:00:39.680
It's the execution that matters.
00:00:39.680 --> 00:00:41.140
I have many interests.
00:00:41.140 --> 00:00:42.320
Sometimes it can flake.
00:00:42.480 --> 00:00:49.340
Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
00:00:49.340 --> 00:00:51.440
This is your host, Michael Kennedy.
00:00:51.440 --> 00:00:53.440
Follow me on Twitter where I'm @mkennedy.
00:00:53.440 --> 00:00:59.920
Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.
00:00:59.920 --> 00:01:03.720
This episode is brought to you by Hired and OptBeat.
00:01:03.720 --> 00:01:08.580
Thank them for supporting the show on Twitter via at Hired underscore HQ and at OptBeat.
00:01:08.980 --> 00:01:14.780
That's right, OptBeat has joined the show as a periodic sponsor, and they have a huge announcement for you later in the episode.
00:01:14.780 --> 00:01:17.860
I have a little news for you this week.
00:01:17.860 --> 00:01:22.940
First, Import Python, the newsletter, guys, have created a free job board.
00:01:22.940 --> 00:01:28.840
So whether you're hiring or looking for work in Python, check out importpython.com slash job board.
00:01:29.220 --> 00:01:32.880
The past two episodes have been with book authors, as is this one as well.
00:01:32.880 --> 00:01:39.360
And for each episode, I've given away a book to one lucky listener who's already signed up as a friend of the show.
00:01:39.360 --> 00:01:44.080
I want to say congratulations to Kristen Wedmark from Sweden, who won Fluent Python,
00:01:44.080 --> 00:01:47.860
and Keith Ord from Georgia, who picked up Effective Python.
00:01:47.860 --> 00:01:51.020
Do you want to win a book just like Kristen and Keith?
00:01:51.020 --> 00:01:55.800
Well, be sure to sign up at talkpython.fm as a friend of the show, and you'll be in the running.
00:01:55.800 --> 00:01:57.480
Now let me introduce Matthew.
00:01:58.380 --> 00:02:02.800
Matthew McKay is a Twilio developer evangelist based in San Francisco, California,
00:02:02.800 --> 00:02:05.980
where he builds open source applications in Python and Swift.
00:02:05.980 --> 00:02:12.740
Matt spoke at EuroPython on FullStackPython and PyCon about virtual ENTs and web app deployments.
00:02:12.740 --> 00:02:19.100
He created the Underwear Library hosted on PyPI and writes FullStackPython to help fellow developers learn how to build
00:02:19.100 --> 00:02:21.680
and deploy their WSGI-powered web applications.
00:02:21.680 --> 00:02:24.180
Matt, welcome to the show.
00:02:24.180 --> 00:02:25.800
Thanks for having me, Michael.
00:02:25.800 --> 00:02:27.320
Yeah, I'm really glad you're here.
00:02:27.440 --> 00:02:31.620
We're going to talk about some awesome deployment stuff based on your new book that you wrote.
00:02:31.620 --> 00:02:37.560
So before we get into deployments and that sort of thing, let's start from the beginning.
00:02:37.560 --> 00:02:38.480
What's your story?
00:02:38.480 --> 00:02:39.900
How do you get into programming in Python?
00:02:39.900 --> 00:02:41.520
Yeah, sure.
00:02:41.520 --> 00:02:43.480
So I've actually been programming for a long time.
00:02:43.480 --> 00:02:45.820
I took four years of computer science in high school.
00:02:45.980 --> 00:02:50.900
I was very fortunate to have extensive computer science classes in high school.
00:02:50.900 --> 00:02:55.240
And I'm a strong believer that that needs to be expanded throughout the United States.
00:02:55.240 --> 00:03:01.460
And then through that, I got into computer science in college at James Madison University.
00:03:01.700 --> 00:03:05.480
And then I did my master's in computer science at Virginia Tech.
00:03:05.480 --> 00:03:14.140
So I've studied computer science for a long time, got a great foundation, and then became a professional programmer as soon as I graduated from college.
00:03:14.140 --> 00:03:22.260
So that pretty much led me into the Java world, which was a bit away from where I am now with the Python scene.
00:03:22.260 --> 00:03:24.560
Was your education in Java?
00:03:24.560 --> 00:03:27.760
Is that how you ended up down that path in the beginning?
00:03:27.760 --> 00:03:28.260
Yeah.
00:03:28.260 --> 00:03:32.000
Well, it was a combination of C, C++, and Java.
00:03:32.000 --> 00:03:40.840
I think most people go into C++ and they learn a lot about the underlying data structures and pointers and all that stuff.
00:03:40.840 --> 00:03:49.560
And I just found at the time when I discovered Java that it was great to not have to think about a lot of the lower level details.
00:03:50.560 --> 00:03:56.280
And so for me, I just kind of naturally gravitated towards Java also because that's where all the jobs were going.
00:03:56.280 --> 00:04:04.060
And so I sort of grabbed onto that and had enough experience in the different languages that I could kind of switch back and forth when necessary.
00:04:04.060 --> 00:04:05.300
Yeah, very cool.
00:04:05.300 --> 00:04:09.240
Okay, so you got a job in Java and somehow you made your way over to Python.
00:04:09.240 --> 00:04:19.720
Yeah, so the gist is I was doing Java development on actually a military project for the Department of Defense.
00:04:20.540 --> 00:04:24.740
And I just realized that we had so many Java developers on our team.
00:04:24.740 --> 00:04:30.340
And I would go home at night and I was like, I was still trying to learn more and more about programming.
00:04:30.760 --> 00:04:42.200
And when I came across Python and I started teaching myself Python, I realized in a couple hours of working on side projects, I felt more productive than an entire day at the office.
00:04:42.760 --> 00:04:48.820
And I just thought, wow, this is something that I think is really powerful as a language, as an ecosystem.
00:04:49.540 --> 00:04:51.500
And I wanted to hang my hat on that.
00:04:51.500 --> 00:05:00.840
So I started getting on projects that were more based in Python, or I would, for example, write scripts that were in Python for a Java project.
00:05:00.840 --> 00:05:02.860
And that was kind of my introduction to that world.
00:05:02.860 --> 00:05:04.260
Yeah, that's really cool.
00:05:04.260 --> 00:05:07.340
That's both exciting and somewhat regretful.
00:05:07.440 --> 00:05:18.080
Like, why didn't you do it earlier is one of the feelings I personally had coming from C++, which I spent a lot of time working on and perfecting to just leave in the dust.
00:05:18.640 --> 00:05:21.480
Yeah, but it makes you appreciate it, right?
00:05:21.480 --> 00:05:31.340
I mean, every time you don't have to handle pointers or you have a built-in data structure, a dictionary, or a list, you really appreciate that you don't have to resize that array.
00:05:31.340 --> 00:05:34.560
You can use the built-in data structure, and it's so much more productive.
00:05:34.560 --> 00:05:35.380
Yeah, absolutely.
00:05:35.380 --> 00:05:38.380
All that stuff is way more appreciated, at least from my perspective.
00:05:38.380 --> 00:05:38.920
Yeah.
00:05:38.920 --> 00:05:40.160
Awesome.
00:05:40.160 --> 00:05:42.320
So why don't you tell me a little bit about Fullstack Python?
00:05:42.320 --> 00:05:43.680
Sure.
00:05:43.680 --> 00:05:55.060
So a few years ago, 2012, I was working on a bunch of different Python projects, consulting projects, and I was working with many junior developers, and they kept asking me questions.
00:05:55.060 --> 00:06:05.180
They would send me an email, and I would write these long, detailed emails about how a WSGI server operates or what the difference between Django and Flask was.
00:06:05.180 --> 00:06:10.800
And one of my colleagues said, you really should actually publish this.
00:06:10.800 --> 00:06:15.100
It's like, you should put it out there, at least just on a website where other people can read it.
00:06:15.100 --> 00:06:17.900
And that was pretty much the start of Fullstack Python.
00:06:17.900 --> 00:06:22.220
I took a Christmas break where I had a week off, and I just started writing.
00:06:22.220 --> 00:06:34.440
And I pretty much pulled in a lot of what I had from emails to just create this original site that I just kind of added to day by day, and it just kept growing.
00:06:34.440 --> 00:06:39.880
So that was the very origin of the site was, hey, people might be interested in this information.
00:06:39.880 --> 00:06:43.140
And lo and behold, I started getting readers.
00:06:43.140 --> 00:06:44.880
So that was the very beginning of it.
00:06:44.880 --> 00:06:53.080
So how many articles or topics did you have out of your email before you had to start writing for Fullstack Python?
00:06:53.960 --> 00:07:09.720
Yeah, so a lot of it was just around web frameworks, and especially around deployments, because I would deploy a lot of applications to just a basic server, because many of the consulting engagements I was on, they didn't have existing Python projects.
00:07:10.120 --> 00:07:14.040
So they needed someone who was a quote unquote, full stack developer.
00:07:14.040 --> 00:07:16.140
I know that's like a much maligned term.
00:07:16.140 --> 00:07:18.200
A lot of developers don't like the term full stack.
00:07:18.200 --> 00:07:20.660
But I felt like it actually really did apply.
00:07:20.660 --> 00:07:22.400
And I'm kind of stuck with the name now.
00:07:22.400 --> 00:07:24.160
And I don't know, I kind of like it.
00:07:24.160 --> 00:07:33.280
So yeah, so I basically that was the original quote unquote, full stack was the web frameworks and the deployments and the servers and that sort of thing itself.
00:07:33.280 --> 00:07:34.760
Yeah, that's really awesome.
00:07:34.760 --> 00:07:37.660
Your book that you wrote, what's the title?
00:07:38.700 --> 00:07:41.260
So it's the full stack Python guide to deployments.
00:07:41.260 --> 00:07:42.120
Right.
00:07:42.120 --> 00:07:49.860
So this is basically taking all of your guidance and stuff around the Python web frameworks and just focusing on the deployment side of the story.
00:07:49.860 --> 00:07:53.440
So it kind of assumes that you're a competent developer, you've written this web app.
00:07:53.440 --> 00:07:54.680
And now what, right?
00:07:54.680 --> 00:07:55.940
Yeah.
00:07:55.940 --> 00:07:58.500
So I really recommend this to people.
00:07:58.500 --> 00:08:04.600
The way that this came about was I kept getting emails from people who were reading full stack Python.
00:08:04.600 --> 00:08:06.060
And they're like, hey, this is really great.
00:08:06.060 --> 00:08:06.960
Love full stack Python.
00:08:07.280 --> 00:08:08.520
But it's super high level.
00:08:08.520 --> 00:08:10.660
And you link to all these tutorials.
00:08:10.660 --> 00:08:14.480
But they're all sort of just they're different tutorials.
00:08:14.480 --> 00:08:15.780
They're mixed and match.
00:08:15.780 --> 00:08:26.980
And it was really hard for someone to just without any knowledge of deployment, just get started and figure out without reading 50 different articles, like how to actually do a deployment from start to finish.
00:08:27.480 --> 00:08:31.140
And some of these things are super well, I wouldn't say they're super basic.
00:08:31.140 --> 00:08:33.540
Like if you don't know how to do them, I wouldn't feel bad about it.
00:08:33.540 --> 00:08:40.400
But it's just something like walking through provisioning a virtual private server that can be super confusing the first time you do it.
00:08:40.520 --> 00:08:47.040
So in the book, I actually walk through like, here's how you provision a server on Linode and actually start it up.
00:08:47.840 --> 00:08:49.620
Yeah, that makes total sense.
00:08:49.620 --> 00:08:55.420
It's, you know, I do professional training for developers for part of my job.
00:08:55.560 --> 00:09:03.860
And I get questions like, how can I even host my pyramid web app or, you know, whatever type of web app you've created.
00:09:03.860 --> 00:09:10.400
Like some people who live and breathe the web world, it's like, well, obviously you create this kind of server or that kind of server.
00:09:10.520 --> 00:09:18.740
But if you're maybe like a data scientist or you're transitioning or you've been in Q&A and you're starting to become a developer, like those are hard choices.
00:09:18.740 --> 00:09:27.460
And I think part of the guidance of just, hey, look, choose this type of hosting over that type of hosting alone is actually really valuable.
00:09:27.460 --> 00:09:28.420
Yeah.
00:09:28.420 --> 00:09:30.740
And I think you completely touched on it.
00:09:30.740 --> 00:09:40.460
If you're a data scientist or you're a coding bootcamp graduate or you're just out of undergrad or maybe an intern, you've never been exposed to these concepts before because they're not things.
00:09:40.460 --> 00:09:42.540
That are typically taught in computer science program.
00:09:42.540 --> 00:09:45.460
And often deployments are not touched on in a coding bootcamp.
00:09:45.460 --> 00:09:50.600
And so just the fundamentals, just the foundational level of how do you get a server?
00:09:50.600 --> 00:09:52.340
How do you create public private keys?
00:09:52.340 --> 00:09:54.140
That's completely unknown.
00:09:54.140 --> 00:10:00.060
And that's pretty much how I wrote the book was I don't assume that you know any of this stuff.
00:10:00.060 --> 00:10:01.560
And we're going to walk through it step by step.
00:10:01.560 --> 00:10:02.880
Yeah, that's really cool.
00:10:02.880 --> 00:10:05.520
I think that's a good place to start.
00:10:05.520 --> 00:10:09.620
You have this picture on deploypython.com.
00:10:09.620 --> 00:10:11.100
I read at the bottom of the homepage.
00:10:11.100 --> 00:10:17.620
And it's kind of like a visual architectural based version of a table of contents.
00:10:17.620 --> 00:10:18.460
Yeah.
00:10:18.460 --> 00:10:19.180
It's really awesome.
00:10:19.180 --> 00:10:20.600
I really love that picture.
00:10:20.600 --> 00:10:21.080
I saw it.
00:10:21.080 --> 00:10:31.000
So it's got like a server and a virtual machine and all the various moving parts sort of sketched out in architecture, but also showing the chapters.
00:10:31.000 --> 00:10:33.700
And you kind of make your way through this architectural diagram, right?
00:10:33.700 --> 00:10:35.240
Yeah, exactly.
00:10:35.240 --> 00:10:38.260
So I start each chapter with the same diagram.
00:10:38.560 --> 00:10:42.220
And I highlight there's a specific color for each chapter.
00:10:42.220 --> 00:10:47.620
So like, for example, I think it's chapter three with the operating systems is like a shade of yellow.
00:10:48.120 --> 00:10:50.800
And so I highlight here's what we're working on in this chapter.
00:10:50.800 --> 00:10:57.020
And the idea is you start out with this like kind of high level conceptual idea of roughly what we're working on.
00:10:57.540 --> 00:11:03.060
And maybe that's on your own server or that's a hosted service like GitHub or something like that.
00:11:03.060 --> 00:11:07.480
But you at least have an image in your mind of what we're going to be working on.
00:11:07.480 --> 00:11:12.080
And I think for people that are just starting in this space, it actually can be super confusing.
00:11:12.080 --> 00:11:14.700
Like, well, okay, I have a Git repository.
00:11:14.700 --> 00:11:17.860
But is that like local on my computer?
00:11:17.860 --> 00:11:18.880
Or is that on GitHub?
00:11:18.880 --> 00:11:20.080
And how do they relate?
00:11:20.080 --> 00:11:23.620
And where does the virtual private server sit?
00:11:23.620 --> 00:11:28.340
So that's what I tried to clarify a bit with the picture that's on deploypython.com.
00:11:28.340 --> 00:11:30.360
It's just here's all the things we're going to walk through.
00:11:30.360 --> 00:11:31.540
And here's how they look.
00:11:31.540 --> 00:11:36.760
Yeah, I think it's great to have a visual way to see what you're going to learn like that architecturally.
00:11:37.160 --> 00:11:47.920
Yeah, I mean, actually, that came from a lot of this came from a talk I gave at Europython in Berlin in 2014 called Full Stack Python, where I pretty much had a picture like this.
00:11:47.920 --> 00:11:53.120
And I walked through conceptually what the full stack of a Python deployment is.
00:11:53.120 --> 00:11:59.420
And the feedback from people was like, that talk would have been really hard to follow if not for the visuals.
00:11:59.420 --> 00:12:02.700
So I thought, okay, obviously, these visuals are powerful.
00:12:02.700 --> 00:12:04.340
And I should continue on with that.
00:12:04.460 --> 00:12:08.440
And I've been trying to add even more to them to fullstackpython.com as I go along.
00:12:08.440 --> 00:12:09.360
Yeah, that's excellent.
00:12:09.360 --> 00:12:12.120
And I'm sure that talk is actually on YouTube somewhere, right?
00:12:12.120 --> 00:12:13.480
Yeah, yeah, it totally is.
00:12:13.480 --> 00:12:17.440
If you do Europython, Full Stack Python, my talk comes up.
00:12:17.440 --> 00:12:24.440
Actually, if you do Google for Full Stack Python, Kate Hedleston gave a really great talk as well at PyCon.
00:12:24.440 --> 00:12:30.160
And I believe it was 2014 that kind of walks through some of the same concepts.
00:12:30.160 --> 00:12:30.880
Yeah, excellent.
00:12:30.880 --> 00:12:31.840
I'll put that in the show notes.
00:12:32.580 --> 00:12:34.660
Yeah, so let's talk about servers first.
00:12:34.660 --> 00:12:38.580
You're using Linode for your hosts here, yeah?
00:12:38.580 --> 00:12:40.020
Yeah, absolutely.
00:12:40.020 --> 00:12:46.520
And it's kind of, I think maybe it's a little bit confusing in the book because I say, well, we're going to deploy this application.
00:12:46.940 --> 00:12:53.600
And actually, before we kind of dive into the servers, I actually have an appendix where we create an application.
00:12:53.600 --> 00:12:56.600
I say, like, if you've already got an application, great.
00:12:56.600 --> 00:12:58.920
Like, let's figure out how to deploy it.
00:12:58.920 --> 00:13:02.940
You can pretty much follow the steps in each chapter and you start out with the server.
00:13:03.580 --> 00:13:07.020
And if you don't have an application, like, here is a full tutorial.
00:13:07.020 --> 00:13:16.600
It's the appendix C in the book where I walk through an entire open source application, Flask application, that has all of the pieces that we need.
00:13:16.600 --> 00:13:17.780
Like, it has a task queue.
00:13:17.780 --> 00:13:21.400
It has all these application dependencies and whatnot.
00:13:21.400 --> 00:13:22.320
It's a Flask app.
00:13:23.020 --> 00:13:28.920
And so the idea is, like, if you, before we even get started with the server, if you've got an application, great.
00:13:28.920 --> 00:13:34.440
If you don't, hey, you might want to go and read appendix C if you want to know about this application before we deploy it.
00:13:34.440 --> 00:13:35.500
Yeah, very cool.
00:13:35.500 --> 00:13:38.600
At minimum, get cloned so you have something to go deploy, right?
00:13:38.600 --> 00:13:39.700
Yeah, yeah, totally.
00:13:39.700 --> 00:13:47.080
And, I mean, the great part is, like, I actually wrote that content on the Twilio blog, which Twilio is my current employer.
00:13:47.300 --> 00:13:53.920
And so that appendix has been, you know, a lot of people have followed along with that and given me feedback on it.
00:13:53.920 --> 00:13:59.140
So it's a pretty good tutorial just to include as an appendix if you are trying to build a Flask application.
00:13:59.140 --> 00:14:00.000
Yeah, excellent.
00:14:00.000 --> 00:14:03.720
Yeah, let's come back to talking about what you do at Twilio because that sounds interesting.
00:14:03.720 --> 00:14:05.080
But Linode.
00:14:05.080 --> 00:14:06.760
Yeah, absolutely.
00:14:06.760 --> 00:14:14.580
So the idea behind really how we get started in this is, like, okay, we need to deploy our application somewhere.
00:14:14.580 --> 00:14:16.300
That can't just be living on your laptop.
00:14:16.540 --> 00:14:18.260
Like, people on the internet need to access that.
00:14:18.260 --> 00:14:22.540
And so we get a $10 a month server on Linode.
00:14:22.540 --> 00:14:26.600
And I walk through the steps of, like, how to actually provision that.
00:14:26.600 --> 00:14:37.000
And then once we provision it, we boot it up and we create a public-private key and we lock down the server against unauthorized attempts to log in.
00:14:37.000 --> 00:14:40.740
So we disallow the root user from being a login account.
00:14:40.740 --> 00:14:42.300
We create a separate login account.
00:14:42.300 --> 00:14:45.000
We disable password authentication.
00:14:45.200 --> 00:14:49.120
We only have public-key infrastructure authentication.
00:14:49.120 --> 00:14:51.840
And then we set up firewalls and automatic upgrades.
00:14:51.840 --> 00:15:01.800
And these things will not completely secure a server, but they're the good first steps that I would always recommend people do to every single server that they're starting up.
00:15:02.040 --> 00:15:17.680
You know, one thing that my current experience absolutely backs this up, but just sort of the way the cloud and sort of this type of hosting has been going, you know, I was a little surprised you weren't using, like, Ubuntu machines on EC2.
00:15:18.960 --> 00:15:19.600
Yeah, sure.
00:15:19.600 --> 00:15:29.400
So I think, you know, I really like Amazon Web Services, but I also feel like it's almost overused for a lot of deployments.
00:15:29.400 --> 00:15:37.640
Like, you can actually take a virtual private server and scale that up to hacker news traffic if you configure it properly.
00:15:37.800 --> 00:15:44.060
And I think that's one of those things where, like, you can rack up a huge bill deploying to Amazon Web Services if you're not careful.
00:15:44.220 --> 00:15:51.720
Whereas, like, the idea behind this was, like, let's learn all the pieces that you need in order to actually deploy a Python application.
00:15:51.720 --> 00:15:56.420
And we're going to do that within the confines of a single virtual private server.
00:15:56.420 --> 00:16:02.320
It's a much more controlled environment for the audience of the book, which is really people who are unfamiliar with deployments.
00:16:02.640 --> 00:16:09.980
But I totally think you're right, and there could be an entire separate book that's like, okay, cool, you've learned the gist of deploying web applications.
00:16:09.980 --> 00:16:14.540
Now let's actually go and deploy this on a cloud-based infrastructure.
00:16:14.540 --> 00:16:21.780
Or I guess you'd call it, like, an infrastructure-as-a-service provider like Rackspace or Amazon or Azure.
00:16:21.780 --> 00:16:22.760
Right.
00:16:22.760 --> 00:16:23.460
Yeah, for sure.
00:16:23.460 --> 00:16:30.700
So I think probably the majority of people out there would be better served by using something like Linode or DigitalOcean.
00:16:30.920 --> 00:16:35.080
The pricing is so straightforward, and the setup is so easy and so quick.
00:16:35.080 --> 00:16:44.600
And EC2 is more, you know, it's something that works for places like Netflix, which are doing amazing things, but it's, like, so large-scale.
00:16:44.600 --> 00:16:51.100
And when you're getting started, you know, it seems like it used to be the place to start, but maybe it's not the good starting point.
00:16:51.100 --> 00:16:52.200
Maybe it's a place to grow into.
00:16:52.200 --> 00:16:55.100
Yeah, I think it might be something to grow into.
00:16:55.100 --> 00:17:00.660
I just really wanted to try to cut down the complexity so that everyone felt like they could follow along in the book.
00:17:00.660 --> 00:17:10.880
And I think that if you understand the concepts in this book, you can probably also move on and pick up the Amazon Web Services side to it.
00:17:10.880 --> 00:17:14.060
But you're totally right in that it's confusing on some of the pricing.
00:17:14.860 --> 00:17:22.620
And I also have heard a lot of horror stories from new developers that said, like, oh, I accidentally spun up, like, 20 servers, and I got a bill for $1,000 this month.
00:17:22.620 --> 00:17:23.460
And I'm like, oh, no.
00:17:23.460 --> 00:17:27.660
Like, I really, really don't want that to happen to people and have them be afraid of doing deployments.
00:17:27.660 --> 00:17:33.000
It's like, if you get a bill for $10 a month, that should be the maximum amount that you get out of this.
00:17:33.000 --> 00:17:33.320
Right.
00:17:33.320 --> 00:17:35.080
It's much more predictable over in those places.
00:17:35.080 --> 00:17:35.660
Very cool.
00:17:35.660 --> 00:17:35.940
Exactly.
00:17:35.940 --> 00:17:43.500
So when you're talking about locking down the servers, one thing that I thought was pretty cool that you recommend is using something called fail-to-ban.
00:17:43.500 --> 00:17:44.980
Yeah, sure.
00:17:45.700 --> 00:17:50.500
Yeah, so fail-to-ban is essentially just a package on Ubuntu.
00:17:50.500 --> 00:17:59.700
I believe it's on many of the other distributions as well, which essentially sets certain parameters like time-based failed logins.
00:17:59.700 --> 00:18:11.740
So if from a certain IP address there are failed login attempts, it will prevent any logins from that IP address for, for example, like the next 30 minutes.
00:18:11.960 --> 00:18:19.520
So the idea would be it provides just enough, like just enough of a prevention that someone who is trying to log into that server.
00:18:19.520 --> 00:18:32.400
Now, granted, they can't do a password-based login anyway after it's secured down, but it's just one other step of basically just locking down the server that will prevent some of those unauthorized attempts.
00:18:32.400 --> 00:18:33.380
Right.
00:18:33.380 --> 00:18:39.380
And while you're going through this process, you know, your machine, if it is on the internet, it is basically under attack.
00:18:39.380 --> 00:18:40.000
Right.
00:18:40.060 --> 00:18:46.020
And so having it sort of password login safe for a while is still something you want to consider.
00:18:46.020 --> 00:18:47.380
Yeah.
00:18:47.380 --> 00:18:55.380
And, you know, I think part of it, too, is just exposing readers to some of these tools and concepts that they have at their disposals.
00:18:55.380 --> 00:19:03.860
I think that you could write, and I'm sure there are entire books written about fail-to-ban or about UFW, which is the firewall tool that we use.
00:19:04.100 --> 00:19:14.500
But just knowing that they're there and that you've set the basic parameters up, I think is enough to get people started, but not dwell on those subjects so they can continue on and actually get the deployment done.
00:19:14.500 --> 00:19:15.160
Right.
00:19:15.160 --> 00:19:15.340
Yeah.
00:19:15.340 --> 00:19:21.620
The other thing that I made a note of in this chapter when I was reading your book is UFW or uncomplicated firewall.
00:19:22.060 --> 00:19:25.640
That thing is so easy to set up, and it's great.
00:19:25.640 --> 00:19:28.020
Oh, I mean, I was...
00:19:28.020 --> 00:19:31.420
I actually wrote a whole section on, like, setting up IP tables.
00:19:32.380 --> 00:19:43.600
And then when I started doing some research, I realized in Ubuntu there is this uncomplicated firewall, and I was like, oh, wow, this does everything that I was trying to show off in IP tables.
00:19:43.600 --> 00:19:44.900
It's so much easier.
00:19:44.900 --> 00:19:47.240
I think it'll just simplify the deployment process.
00:19:47.240 --> 00:19:48.800
So that's pretty much what I went with.
00:19:48.800 --> 00:19:49.400
Yeah, absolutely.
00:19:49.400 --> 00:19:51.040
I would say it's even uncomplicated.
00:19:51.040 --> 00:19:51.640
It's great.
00:19:51.640 --> 00:19:52.340
Yeah.
00:19:53.080 --> 00:20:02.200
So then basically for the rest of the book, you said, look, you could sit down and manually type these out at the command line, but that doesn't make a lot of sense.
00:20:02.200 --> 00:20:03.540
Like, let's make this reproducible.
00:20:03.540 --> 00:20:07.820
And so the next thing you bring up is actually Ansible and playbooks, right?
00:20:07.820 --> 00:20:08.980
Yeah.
00:20:08.980 --> 00:20:12.000
So, well, there's Fabric and there's Ansible.
00:20:12.180 --> 00:20:23.260
And so the idea is I think that going through and manually doing deployment and reading through what steps you're taking is really important for the learning process.
00:20:23.260 --> 00:20:27.500
But obviously you're not going to do this every time you have a deployment.
00:20:27.500 --> 00:20:34.600
So you're going to want to automate the entire process so that you can deploy as many web applications in the future as you want.
00:20:34.600 --> 00:20:39.120
And you can modify the deployment scripts so that they're custom built for your applications.
00:20:39.120 --> 00:20:49.980
And so every single chapter in the book, so starting with chapter two, which is the service chapter, we do the manual steps and I explain manual, like what you're doing in those manual steps.
00:20:49.980 --> 00:21:02.360
And then I go into a sort of second section of the chapter, which is here's how we automate the manual steps that we just did with either Fabric or Ansible.
00:21:02.360 --> 00:21:08.660
And so starting in chapter three, we have Ansible playbooks that automate everything that we're building on top of.
00:21:08.660 --> 00:21:17.420
And actually those, all of those, that, that playbook, that Ansible playbook is actually all open source on GitHub under one of the GitHub repos that I have.
00:21:17.420 --> 00:21:19.200
Okay. Yeah. Excellent.
00:21:19.200 --> 00:21:21.620
We'll put that out there on the show notes as well.
00:21:21.620 --> 00:21:22.780
Yeah. Great.
00:21:22.780 --> 00:21:24.040
Yeah. I think you're right.
00:21:24.040 --> 00:21:37.160
You know, it's, this is one of the things where if you've got time and you haven't deployed your, you haven't made your, your site live or whatever, it's fine to just sit there and fiddle with a server until you get it working.
00:21:37.740 --> 00:21:45.220
But if something goes wrong, especially, you know, you'd need to rebuild the machine or move it or, or scale it out or something.
00:21:45.220 --> 00:21:48.520
And you have got to do that under some high stress situation.
00:21:48.520 --> 00:21:55.180
Like the website is down and there's lots of traffic doing that by hand, you know, it's just extremely stressful.
00:21:55.180 --> 00:22:00.600
And if it's automated, you push a button a few minutes later, the life, you know, life is good again.
00:22:00.600 --> 00:22:01.720
It's definitely recommended.
00:22:01.720 --> 00:22:14.480
This episode is brought to you by Hired.
00:22:14.480 --> 00:22:21.020
Hired is a two-sided curated marketplace that connects the world's knowledge workers to the best opportunities.
00:22:21.020 --> 00:22:30.120
Each offer you receive has salary and equity presented right up front, and you can view the offers to accept or reject them before you even talk to the company.
00:22:30.760 --> 00:22:36.480
Typically, candidates receive five or more offers in just the first week, and there are no obligations ever.
00:22:36.480 --> 00:22:38.580
Sounds pretty awesome, doesn't it?
00:22:38.580 --> 00:22:40.620
Well, did I mention there's a signing bonus?
00:22:40.620 --> 00:22:44.720
Everyone who accepts a job from Hired gets a $2,000 signing bonus.
00:22:44.720 --> 00:22:49.060
And as Talk Python listeners, it gets way sweeter.
00:22:49.060 --> 00:22:56.620
Use the link Hired.com slash Talk Python To Me, and Hired will double the signing bonus to $4,000.
00:22:56.620 --> 00:22:58.340
Opportunity's knocking.
00:22:58.820 --> 00:23:01.940
Visit Hired.com slash Talk Python To Me and answer the call.
00:23:01.940 --> 00:23:13.040
Yeah, absolutely.
00:23:13.040 --> 00:23:22.800
I mean, no large scale, or even I would say for the most part, small scale website or web application really is going to do a manual deployment.
00:23:23.060 --> 00:23:24.340
It's just so time consuming.
00:23:24.340 --> 00:23:31.060
And the last thing you want is to make all these code changes and then all of a sudden be like, oh, it's going to take me 20 minutes to deploy all this stuff.
00:23:31.060 --> 00:23:34.320
Man, I'll just do it tomorrow because I don't feel like doing it right now.
00:23:34.320 --> 00:23:34.760
Right.
00:23:34.860 --> 00:23:41.900
You get what you can get with some of those large enterprises where it's like they deploy every six months and they're down for the weekend.
00:23:41.900 --> 00:23:42.820
Right.
00:23:42.820 --> 00:23:43.380
Exactly.
00:23:43.380 --> 00:23:44.720
Something insane like that, right?
00:23:44.720 --> 00:23:45.540
Yeah.
00:23:45.540 --> 00:23:48.480
No, you should be able to just deploy immediately as soon as you make changes.
00:23:48.840 --> 00:23:52.700
And so that's part of what the automating each step is.
00:23:52.700 --> 00:23:57.860
And almost, I don't really call it out like this, but it's almost like if you're playing a video game and you hit a checkpoint.
00:23:58.320 --> 00:24:03.160
And if you mess up or die or whatever, you go back to that checkpoint.
00:24:03.160 --> 00:24:06.320
And that's kind of how I see the automated steps at each chapter.
00:24:06.320 --> 00:24:14.260
When you're finished with automating that chapter, you know you can always fall back to that checkpoint if you mess something up in the next chapter.
00:24:14.260 --> 00:24:15.180
Yeah.
00:24:15.180 --> 00:24:16.280
I think of it the same way.
00:24:16.920 --> 00:24:20.860
So now we're getting in your sort of steps along the way.
00:24:20.860 --> 00:24:21.820
We've got the server.
00:24:21.820 --> 00:24:24.600
Well, the server is really set up by Linode.
00:24:24.600 --> 00:24:26.680
But we've got the VM running in their machine.
00:24:26.680 --> 00:24:28.440
We've got the Ansible Playbook.
00:24:28.440 --> 00:24:31.740
Now it's time to start serving some stuff, right?
00:24:31.740 --> 00:24:33.440
So you start with Nginx.