@@ -189,8 +189,6 @@ and most of the rest of the deployment process is taken care of by someone else.
189
189
190
190
=== Docker and the Danger Areas of Deployment
191
191
192
- // TODO: expand this section, is just bullet points atm
193
-
194
192
How will containerizing our software help with the danger areas?
195
193
196
194
* Containers are like a little virtual server,
@@ -263,11 +261,11 @@ But there are solutions to all of these. In order:
263
261
264
262
=== An Overview of Our Deployment Procedure
265
263
266
- Over the next few pages I'm going to go through _a_ deployment procedure.
264
+ Over these three chapters chapters I'm going to go through _a_ deployment procedure.
267
265
It isn't meant to be the _perfect_ deployment procedure,
268
266
so please don't take it as being best practice,
269
267
or a recommendation--it's meant to be an illustration,
270
- to show the kinds of issues involved in deployment ,
268
+ to show the kinds of issues involved in putting code into production ,
271
269
and where testing fits in.
272
270
273
271
@@ -290,11 +288,11 @@ and where testing fits in.
290
288
**Next chapter: moving to a production-ready configuration**
291
289
292
290
* Gradually, incrementally change the container configuration
293
- to make it production-ready,
291
+ to make it production-ready.
294
292
295
293
* Regularly re-run the FTs to check we didn't break anything.
296
294
297
- * Address issues to do with the database, static files, etc .
295
+ * Address issues to do with the database, static files, and so on .
298
296
299
297
// gunicorn, DEBUG=False, secret key, etc
300
298
@@ -314,12 +312,6 @@ and where testing fits in.
314
312
* We'll use Ansible to build an automated script that can deploy
315
313
our container to staging
316
314
317
- NOTE: A clarification: in these chapter,
318
- we run tests _against_ our Docker container, or _against_ our staging server,
319
- but that doesn't mean we run the tests _from_ Docker or _from_ our staging server.
320
- We still run the tests from our own laptop,
321
- but they target the place that's running our code.
322
-
323
315
324
316
=== As Always, Start with a Test
325
317
@@ -367,6 +359,14 @@ and to use a real server instead.
367
359
<2> Here's the hack: we replace `self.live_server_url` with the address of
368
360
our "real" server.
369
361
362
+
363
+ NOTE: A clarification: in these chapter,
364
+ we run tests _against_ our Docker container, or _against_ our staging server,
365
+ but that doesn't mean we run the tests _from_ Docker or _from_ our staging server.
366
+ We still run the tests from our own laptop,
367
+ but they target the place that's running our code.
368
+
369
+
370
370
We test that said hack hasn't broken anything by running the functional
371
371
tests [keep-together]#"normally"#:
372
372
@@ -455,7 +455,7 @@ Currently, all our code is source code really, so we move everything into _src_
455
455
(we'll be seeing some new files appearing outside _src_ shortly.footnote:[
456
456
A common thing to find outside of the _src_ folder is a folder called _tests_.
457
457
We won't be doing that while we're relying on the standard Django test framework,
458
- but it's a common thing to do if you're using pytest, for example.]
458
+ but it's a good thing to do if you're using pytest, for example.]
459
459
)
460
460
461
461
@@ -464,7 +464,7 @@ but it's a common thing to do if you're using pytest, for example.]
464
464
[subs="specialcharacters,quotes"]
465
465
----
466
466
$ *mkdir src*
467
- $ *git mv * src*
467
+ $ *git mv functional_tests lists superlists manage.py src*
468
468
$ *git commit -m "Move all our code into a src folder"*
469
469
----
470
470
@@ -497,6 +497,7 @@ What's happened there is that Docker has
497
497
498
498
Cool! We'll find out more about all of these steps as the chapter progresses.
499
499
500
+
500
501
.Podman, a Docker Alternative
501
502
*****************************************************************************************
502
503
Impartiality commands me to also recommend https://podman.io/[Podman],
@@ -510,7 +511,7 @@ But it's a little less well established and documented,
510
511
(the Windows installation instructions are a little more DIY for example),
511
512
and in the end, although I'm a fan of a plucky upstart,
512
513
Docker is open source too,
513
- so I didn't decide to switch . But you could definitely check it out!
514
+ so I didn't decide to stick with Docker . But you could definitely check it out!
514
515
515
516
You can follow along all the instructions in the book
516
517
by just substituing the `docker` binary for `podman` in all the CLI instructions,
@@ -1151,8 +1152,6 @@ It always seems hopeless at first! But eventually you get there.
1151
1152
1152
1153
=== Database migrations
1153
1154
1154
- // TODO: these errors won't happen if the user has run "migrate" on their own machine.
1155
-
1156
1155
((("database migrations")))
1157
1156
A quick visual inspection confirms--the site is up (<<staging-is-up>>)!
1158
1157
@@ -1224,12 +1223,10 @@ Run 'python manage.py migrate' to apply them.
1224
1223
1225
1224
1226
1225
NOTE: If you don't see this error,
1227
- it's because your source repo already had the database file in it, unlike mine.
1226
+ it's because your src folder had the database file in it, unlike mine.
1228
1227
For the sake of argument, run `rm src/db.sqlite` and re-run the build & run commands,
1229
1228
and you should be able to repro the error. I promise it's instructive!
1230
1229
1231
- // TODO this ^ is hacky. figure out a way to make it more likely that the user sees the error.
1232
-
1233
1230
1234
1231
==== Should we run "migrate" inside the Dockerfile? No.
1235
1232
@@ -1339,9 +1336,9 @@ Ran 3 tests in 26.965s
1339
1336
OK
1340
1337
----
1341
1338
1342
- AMAZING IT ACTUALLY WORKS
1339
+ AMAZING IT ACTUALLY WORKSSSSSSSS.
1343
1340
1344
- That 's definitely good enough for now! Let's commit.
1341
+ Ahem, that 's definitely good enough for now! Let's commit.
1345
1342
1346
1343
1347
1344
[subs="specialcharacters,quotes"]
@@ -1351,26 +1348,22 @@ $ *git commit -m"First cut of a Dockerfile"*
1351
1348
----
1352
1349
1353
1350
1354
- Time for a well-earned tea break I think, and perhaps a
1355
- https://en.wikipedia.org/wiki/Digestive_biscuit[chocolate biscuit].
1356
-
1357
-
1358
- Success! Our Hack Deployment Works
1359
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1360
-
1361
1351
Phew. Well, it took a bit of hacking about,
1362
1352
but now we can be reassured that the basic Docker plumbing works.
1363
- Notice that the FT was able to guide us incrementally towards a working config.
1353
+ Notice that the FT was able to guide us incrementally towards a working config,
1354
+ and spot problems early on (like the missing database).
1364
1355
1365
1356
But we really can't be using the Django dev server in production,
1366
1357
or running on port 8888 forever.
1367
1358
In the next chapter, we'll make our hacky image more production-ready.
1368
1359
1360
+ But first, time for a well-earned tea break I think, and perhaps a
1361
+ https://en.wikipedia.org/wiki/Digestive_biscuit[chocolate biscuit].
1362
+
1369
1363
1370
1364
.Test-Driving Server Configuration and Deployment
1371
1365
*******************************************************************************
1372
1366
1373
-
1374
1367
TODO update this recap.
1375
1368
1376
1369
@@ -1389,10 +1382,5 @@ Some typical pain points--networking, ports, static files, and the database::
1389
1382
production. You'll need to think through each of these for your own
1390
1383
deployments.
1391
1384
1392
- Tests allow us to experiment and work incrementally::
1393
- Whenever we make a change to our server configuration, we can rerun the
1394
- test suite, and be confident that everything works as well as it did
1395
- before. It allows us to experiment with our setup with less fear (as
1396
- we'll see in the next chapter).
1397
1385
1398
1386
*******************************************************************************
0 commit comments