@@ -1341,13 +1341,9 @@ NOTE: If you don't see this error,
1341
1341
1342
1342
==== Should we run "migrate" inside the Dockerfile? No.
1343
1343
1344
- // JAN: Not sure I understand this line.
1345
- // You're saying that we shouldn't run migrate inside our Dockerfile,
1346
- // but then in the next line you do exactly that
1347
-
1348
1344
So, should we include `manage.py migrate` in our Dockerfile?
1349
1345
1350
- If you try it, you'll find it certainly fixes the problem:
1346
+ If you try it, you'll find it certainly _seems_ to fix the problem:
1351
1347
1352
1348
[role="sourcecode"]
1353
1349
.Dockerfile (ch09l008)
@@ -1365,17 +1361,23 @@ CMD python manage.py runserver 0.0.0.0:8888
1365
1361
<1> We run `migrate` using the `--noinput` argument to suppress any little "are you sure" prompts.
1366
1362
1367
1363
1368
- If we rebuild the image and try our FTs again, they all pass!
1364
+ If we rebuild the image...
1365
+
1366
+ [subs="specialcharacters,quotes"]
1367
+ ----
1368
+ $ *docker build -t superlists . && docker run -p 8888:8888 -it superlists*
1369
+ [...]
1370
+ Starting development server at http://0.0.0.0:8888/
1371
+ ----
1369
1372
1373
+ ...and try our FTs again, they all pass!
1370
1374
1371
- [role="small-code"]
1375
+ [role="small-code pause-first "]
1372
1376
[subs="specialcharacters,macros"]
1373
1377
----
1374
1378
$ pass:quotes[*TEST_SERVER=localhost:8888 ./src/manage.py test src/functional_tests \
1375
1379
--failfast*]
1376
- Found 3 test(s).
1377
- Creating test database for alias 'default'...
1378
- System check identified no issues (0 silenced).
1380
+ [...]
1379
1381
...
1380
1382
---------------------------------------------------------------------
1381
1383
Ran 3 tests in 26.965s
@@ -1388,20 +1390,17 @@ which is not what we want,
1388
1390
because the system image is mean to be something fixed and stateless,
1389
1391
whereas the database is living, stateful data that should change over time.
1390
1392
1393
+ // DAVID: This is an important point which might need a bit more explanation.
1394
+ // What would happen if we did?
1391
1395
1392
1396
=== Mounting files inside the container.
1393
1397
1394
1398
We want the database on the server to have totally separate data from the one on our machine.
1395
- // CSANAD: we need to list `src/db.sqlite3` in the .dockerignore file to achieve this.
1396
- // Otherwise, if the reader did not delete the DB, it would still end up built into
1397
- // the image since the COPY directive copies everything that's inside `src`.
1398
-
1399
- // DAVID: This is an important point which might need a bit more explanation.
1400
- // What would happen if we did?
1401
1399
1402
1400
In most deployments, you'd probably be talking to a separate database server, like postgres.
1403
1401
1404
- For the purposes of this book, the easiest analogy to a server that's "outside" our container,
1402
+ For the purposes of this book,
1403
+ the easiest analogy to a server that's "outside" our container,
1405
1404
is to access the database from the filesystem outside the container.
1406
1405
1407
1406
That also gives us a convenient excuse to talk about mounting files in Docker,
@@ -1478,9 +1477,7 @@ And we check the FTs again.
1478
1477
----
1479
1478
$ pass:quotes[*TEST_SERVER=localhost:8888 ./src/manage.py test src/functional_tests \
1480
1479
--failfast*]
1481
- Found 3 test(s).
1482
- Creating test database for alias 'default'...
1483
- System check identified no issues (0 silenced).
1480
+ [...]
1484
1481
...
1485
1482
---------------------------------------------------------------------
1486
1483
Ran 3 tests in 26.965s
0 commit comments