@@ -126,13 +126,13 @@ Let's change the command our image runs:
126
126
[source,dockerfile]
127
127
----
128
128
[...]
129
- RUN pip install "django<5" gunicorn <1>
129
+ RUN pip install "django<5" gunicorn # <1>
130
130
131
131
COPY src /src
132
132
133
133
WORKDIR /src
134
134
135
- CMD gunicorn --bind :8888 superlists.wsgi:application <2>
135
+ CMD gunicorn --bind :8888 superlists.wsgi:application # <2>
136
136
----
137
137
====
138
138
// CSANAD: shouldn't we try it out before adding this to the Dockerfile?
@@ -230,9 +230,6 @@ MIDDLEWARE = [
230
230
// CSANAD: I would add a few thoughts on the significance of the order of
231
231
// middlewares.
232
232
233
- And if you take another manual look at your site after rebuilding the
234
- container, things should look much healthier.
235
-
236
233
And then we need to add it to our pip installs in the Dockerfile:
237
234
238
235
.Dockerfile (ch10l003)
@@ -374,11 +371,8 @@ whitenoise==6.6.0
374
371
375
372
That's a good first cut, let's commit it:
376
373
377
- // SEBASTIAN I am not very fond of freezing just "top-level" dependencies of the project,
378
- // . This is not guaranteeing the reproducible builds and I failed to build & deploy because of that more than once.
379
- // But I understand it's a trade-off so the reader does get bogged down.
380
- // TODO: add a note about this and a link to some more reading
381
374
375
+ [subs="specialcharacters,quotes"]
382
376
----
383
377
$ *git add requirements.txt*
384
378
$ *git commit -m "Add a requirements.txt with Django, gunicorn and whitenoise"*
@@ -420,14 +414,14 @@ FROM python:slim
420
414
RUN python -m venv /venv
421
415
ENV PATH="/venv/bin:$PATH"
422
416
423
- COPY requirements.txt requirements.txt <1>
424
- RUN pip install -r requirements.txt <2>
417
+ COPY requirements.txt requirements.txt # <1>
418
+ RUN pip install -r requirements.txt # <2>
425
419
426
420
COPY src /src
427
421
428
422
WORKDIR /src
429
423
430
- CMD python manage.py runserver
424
+ CMD gunicorn --bind :8888 superlists.wsgi:application
431
425
----
432
426
====
433
427
@@ -451,6 +445,7 @@ TIP: Forgetting the `-r` and running `pip install requirements.txt`
451
445
// and then setting the user in the Dockerfile with `USER todoapp`.
452
446
// But we can cover this in a later chapter (the next one looks like a good fit,
453
447
// since it's related to the app being production ready).
448
+ // TODO yep let's definitely do this.
454
449
455
450
Let's do a build & run & test to check everything still works:
456
451
@@ -552,6 +547,7 @@ TIP: Better to fail hard than allow a typo in an environment variable name to
552
547
// in a development environment relying on containerization, programmers usually
553
548
// mount the whole /src minimizing the time-consuming rebuilding of their images.
554
549
550
+
555
551
==== Setting environment variables inside the Dockerfile
556
552
557
553
Now let's set that environment variable in our Dockerfile using the `ENV` directive:
0 commit comments