@@ -212,9 +212,8 @@ Believe it or not, this pun didn't actually hit me until I was rewriting this ch
212
212
For 10 years it was right under my nose. I think that makes it funnier actually.]
213
213
files from Python.
214
214
215
- First we install whitenoise into our local environment:
215
+ First we install Whitenoise into our local environment:
216
216
217
- [source,python]
218
217
----
219
218
pip install whitenoise
220
219
----
@@ -262,10 +261,6 @@ $ *docker build -t superlists . && docker run \
262
261
And if you take another manual look at your site, things should look much healthier.
263
262
Let's rerun our FTs to confirm:
264
263
265
- // DAVID: Incidentally as per your suggestion Harry I have just been skipping
266
- // the requirements.txt and instead just amending the pip install in the Dockerfile.
267
- // If we do that, however, we'll need to make sure readers rebuild the image each time
268
- // we add a requirement - such as at this point.
269
264
270
265
[role="small-code"]
271
266
[subs="specialcharacters,macros"]
@@ -443,14 +438,6 @@ TIP: Forgetting the `-r` and running `pip install requirements.txt`
443
438
It's a mistake I still make, _all the time_.
444
439
445
440
446
- // CSANAD: It's fine for now, but I would definitely put the requirements under
447
- // /tmp and then `rm` it after `pip install`. Also, using a non-privileged
448
- // user is important, something like:
449
- // `adduser --no-create-home --disabled-password todoapp`
450
- // and then setting the user in the Dockerfile with `USER todoapp`.
451
- // But we can cover this in a later chapter (the next one looks like a good fit,
452
- // since it's related to the app being production ready).
453
- // TODO yep let's definitely do this.
454
441
455
442
Let's build & run:
456
443
@@ -773,6 +760,7 @@ $ *docker build -t superlists . && docker run \
773
760
-it superlists*
774
761
----
775
762
763
+ and...
776
764
777
765
[role="small-code"]
778
766
[subs="specialcharacters,macros"]
@@ -801,24 +789,28 @@ $ *git status*
801
789
$ *git commit -am "Add collectstatic to dockerfile, and new location to gitignore"*
802
790
----
803
791
804
- // CSANAD: now would be a good time to check our changes and notice git marked
805
- // src/static as unstaged, so we should update .gitignore accordingly:
806
- // from `static` to `src/static`.
807
- // Or we could add this step to Chapter 09 at "Move all our code into a src
808
- // folder"
809
792
810
793
811
794
=== Switching to a nonroot user
812
795
813
- TODO: WIP, this is definitely a good idea for security, needs writing up.
796
+ // CSANAD: It's fine for now, but I would definitely put the requirements under
797
+ // /tmp and then `rm` it after `pip install`. Also, using a non-privileged
798
+ // user is important, something like:
799
+ // `adduser --no-create-home --disabled-password todoapp`
800
+ // and then setting the user in the Dockerfile with `USER todoapp`.
801
+ // But we can cover this in a later chapter (the next one looks like a good fit,
802
+ // since it's related to the app being production ready).
803
+ // TODO yep let's definitely do this.
804
+
805
+ TODO: apologies, WIP, this is definitely a good idea for security, needs writing up.
814
806
815
807
Dockerfile should gain some lines a bit like this:
816
808
817
809
.Dockerfile (ch10l0XX)
818
810
====
819
811
[source,dockerfile]
820
812
----
821
- RUN addgroup --system nonroot && adduser --system --group nonroot
813
+ RUN addgroup --system nonroot && adduser --system --no-create-home --disabled-password -- group nonroot
822
814
823
815
USER nonroot
824
816
----
@@ -899,7 +891,8 @@ but sometimes you just wanna say "just print stuff to stdout pls",
899
891
and you wish that configuring the simplest thing was a little easier.].
900
892
901
893
Here's pretty much the simplest possible logging config
902
- which just prints everything to the console (i.e. standard out). I've added this code to the very end of the settings.py file.
894
+ which just prints everything to the console (i.e. standard out).
895
+ I've added this code to the very end of the settings.py file.
903
896
904
897
905
898
[role="sourcecode"]
0 commit comments