Skip to content

Commit dbb1d1f

Browse files
committed
some polishing in docker chaps
1 parent ca14daf commit dbb1d1f

File tree

4 files changed

+117
-84
lines changed

4 files changed

+117
-84
lines changed

chapter_09_docker.asciidoc

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ and most of the rest of the deployment process is taken care of by someone else.
189189

190190
=== Docker and the Danger Areas of Deployment
191191

192-
// TODO: expand this section, is just bullet points atm
193-
194192
How will containerizing our software help with the danger areas?
195193

196194
* Containers are like a little virtual server,
@@ -263,11 +261,11 @@ But there are solutions to all of these. In order:
263261

264262
=== An Overview of Our Deployment Procedure
265263

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.
267265
It isn't meant to be the _perfect_ deployment procedure,
268266
so please don't take it as being best practice,
269267
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,
271269
and where testing fits in.
272270

273271

@@ -290,11 +288,11 @@ and where testing fits in.
290288
**Next chapter: moving to a production-ready configuration**
291289

292290
* Gradually, incrementally change the container configuration
293-
to make it production-ready,
291+
to make it production-ready.
294292

295293
* Regularly re-run the FTs to check we didn't break anything.
296294

297-
* Address issues to do with the database, static files, etc.
295+
* Address issues to do with the database, static files, and so on.
298296

299297
// gunicorn, DEBUG=False, secret key, etc
300298

@@ -314,12 +312,6 @@ and where testing fits in.
314312
* We'll use Ansible to build an automated script that can deploy
315313
our container to staging
316314

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-
323315

324316
=== As Always, Start with a Test
325317

@@ -367,6 +359,14 @@ and to use a real server instead.
367359
<2> Here's the hack: we replace `self.live_server_url` with the address of
368360
our "real" server.
369361

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+
370370
We test that said hack hasn't broken anything by running the functional
371371
tests [keep-together]#"normally"#:
372372

@@ -455,7 +455,7 @@ Currently, all our code is source code really, so we move everything into _src_
455455
(we'll be seeing some new files appearing outside _src_ shortly.footnote:[
456456
A common thing to find outside of the _src_ folder is a folder called _tests_.
457457
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.]
459459
)
460460

461461

@@ -464,7 +464,7 @@ but it's a common thing to do if you're using pytest, for example.]
464464
[subs="specialcharacters,quotes"]
465465
----
466466
$ *mkdir src*
467-
$ *git mv * src*
467+
$ *git mv functional_tests lists superlists manage.py src*
468468
$ *git commit -m "Move all our code into a src folder"*
469469
----
470470

@@ -497,6 +497,7 @@ What's happened there is that Docker has
497497

498498
Cool! We'll find out more about all of these steps as the chapter progresses.
499499

500+
500501
.Podman, a Docker Alternative
501502
*****************************************************************************************
502503
Impartiality commands me to also recommend https://podman.io/[Podman],
@@ -510,7 +511,7 @@ But it's a little less well established and documented,
510511
(the Windows installation instructions are a little more DIY for example),
511512
and in the end, although I'm a fan of a plucky upstart,
512513
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!
514515
515516
You can follow along all the instructions in the book
516517
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.
11511152

11521153
=== Database migrations
11531154

1154-
// TODO: these errors won't happen if the user has run "migrate" on their own machine.
1155-
11561155
((("database migrations")))
11571156
A quick visual inspection confirms--the site is up (<<staging-is-up>>)!
11581157

@@ -1224,12 +1223,10 @@ Run 'python manage.py migrate' to apply them.
12241223

12251224

12261225
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.
12281227
For the sake of argument, run `rm src/db.sqlite` and re-run the build & run commands,
12291228
and you should be able to repro the error. I promise it's instructive!
12301229

1231-
// TODO this ^ is hacky. figure out a way to make it more likely that the user sees the error.
1232-
12331230

12341231
==== Should we run "migrate" inside the Dockerfile? No.
12351232

@@ -1339,9 +1336,9 @@ Ran 3 tests in 26.965s
13391336
OK
13401337
----
13411338

1342-
AMAZING IT ACTUALLY WORKS
1339+
AMAZING IT ACTUALLY WORKSSSSSSSS.
13431340

1344-
That's definitely good enough for now! Let's commit.
1341+
Ahem, that's definitely good enough for now! Let's commit.
13451342

13461343

13471344
[subs="specialcharacters,quotes"]
@@ -1351,26 +1348,22 @@ $ *git commit -m"First cut of a Dockerfile"*
13511348
----
13521349

13531350

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-
13611351
Phew. Well, it took a bit of hacking about,
13621352
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).
13641355

13651356
But we really can't be using the Django dev server in production,
13661357
or running on port 8888 forever.
13671358
In the next chapter, we'll make our hacky image more production-ready.
13681359

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+
13691363

13701364
.Test-Driving Server Configuration and Deployment
13711365
*******************************************************************************
13721366
1373-
13741367
TODO update this recap.
13751368
13761369
@@ -1389,10 +1382,5 @@ Some typical pain points--networking, ports, static files, and the database::
13891382
production. You'll need to think through each of these for your own
13901383
deployments.
13911384
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).
13971385
13981386
*******************************************************************************

0 commit comments

Comments
 (0)