@@ -37,6 +37,35 @@ NOTE: Why not ping me a note once your site is live on the web,
37
37
It always gives me a warm and fuzzy feeling...
38
38
39
39
40
+ ////
41
+ DAVID overall notes
42
+
43
+ The main challenge is that I found that when I ran into problems I lacked the
44
+ mental model to troubleshoot - it's possible that others who don't have access
45
+ to Harry(TM) will give up. I think talking through what Ansible is doing, maybe
46
+ even a diagram at the beginning of the chapter to show what we're aiming for?
47
+ In particular, it's difficult to understand where the Ansible error logs are
48
+ coming from (i.e. local, server, container...)
49
+
50
+ I also think we're missing some stuff at the end about how all this might look
51
+ as a development workflow. Maybe talk about setting up scripts (so we don't
52
+ have to remember the ansible command?) And what about releasing to production?
53
+ It doesn't need much, it just feels unfinished to me.
54
+
55
+ A few small things:
56
+
57
+ * I think you should make more of the fact that our functional tests can be
58
+ run against a real website hosted elsewhere. The fact that we can do that
59
+ was not obvious to me when we wrote those tests. Worth talking about a bit
60
+ more?
61
+
62
+ * Shouldn't we commit our changes to Git at some point, as per the
63
+ other chapters?
64
+
65
+ * Will we be returning to this again in the book? I'd like to
66
+ know whether I can destroy my Digital Ocean droplet yet, don't want to get
67
+ billed needlessly.
68
+ ////
40
69
41
70
42
71
.🚧 Warning, chapter under construction 🚧
@@ -680,6 +709,16 @@ KeyError: 'DJANGO_SECRET_KEY'
680
709
Whoops, we need to set those environment variables on the server too.
681
710
682
711
712
+ NOTE: If you see an error saying "Error connecting: Error while fetching server API version",
713
+ it may be because the Python Docker SDK can't find your docker daemon.
714
+ Try restarting Docker Desktop if you're on Windows or a Mac.
715
+ If you're not using the standard docker engine, with Colima for example,
716
+ you may need to set the `DOCKER_HOST` environment variable
717
+ or use a symlink to point to the right place.
718
+ See the
719
+ https://github.com/abiosoft/colima/blob/main/docs/FAQ.md#cannot-connect-to-the-docker-daemon-at-unixvarrundockersock-is-the-docker-daemon-running[Colima FAQ].
720
+
721
+
683
722
=== Using an env File to Store Our Environment Variables
684
723
685
724
When we run our container manually locally, we can pass in environment variables with the `-e` flag.
@@ -745,7 +784,7 @@ And here's how we use it in the provisioning script:
745
784
image: superlists
746
785
state: started
747
786
recreate: true
748
- env_file: ~/superlists.env
787
+ env_file: ~/superlists.env # <6>
749
788
----
750
789
====
751
790
@@ -763,7 +802,9 @@ And here's how we use it in the provisioning script:
763
802
764
803
<5> This `lookup('password')` thing I copy-pasted from Stackoverflow.
765
804
Come on there's no shame in that.
766
-
805
+
806
+ <6> Here's where Ansible tells Docker to use our env file when it runs our container.
807
+
767
808
768
809
NOTE: Using an env file to store secrets is definitely better than committing
769
810
it to version control, but it's maybe not the state of the art either.
@@ -862,13 +903,18 @@ selenium.common.exceptions.WebDriverException: Message: Reached error page:
862
903
about:neterror?e=connectionFailure&u=http%3A//staging.ottg.co.uk/[...]
863
904
----
864
905
865
- // DAVID: I got selenium.common.exceptions.NoSuchElementException
866
- // On the server, I get 'Host not found'.
867
906
868
907
That `neterror` makes me think it's another networking problem.
869
- Let's try `curl` locally:
908
+
909
+ NOTE: If your domain provider puts up a temporary holding page,
910
+ you may get a 404 rather than a connection error at this point,
911
+ and the traceback might have NoSuchElementException instead.
870
912
871
913
914
+ Let's try our standard debugging technique, of using `curl`
915
+ both locally and then from inside the container on the server.
916
+ First, on our own machine:
917
+
872
918
[subs="specialcharacters,macros"]
873
919
----
874
920
$ pass:quotes[*curl -iv staging.ottg.co.uk*]
@@ -877,9 +923,11 @@ curl: (7) Failed to connect to staging.ottg.co.uk port 80 after 25 ms: Couldn't
877
923
connect to server
878
924
----
879
925
880
- // DAVID: I was able to connect, and got Host not found.
926
+ NOTE: Similarly, depending on your domain/hosting provider,
927
+ you may see "Host not found" here instead.
928
+
881
929
882
- Now let's ssh in and try `curl` from the server itself :
930
+ Now let's ssh in to our server and take a look at the docker logs :
883
931
884
932
[subs="specialcharacters,quotes"]
885
933
----
@@ -890,7 +938,7 @@ elspeth@server$ *docker logs superlists*
890
938
[2024-02-28 22:14:43 +0000] [8] [INFO] Booting worker with pid: 8
891
939
----
892
940
893
- No errors in the logs...
941
+ No errors there. Let's try our `curl`:
894
942
895
943
[subs="specialcharacters,quotes"]
896
944
----
@@ -905,7 +953,7 @@ curl: (7) Failed to connect to localhost port 80 after 0 ms: Connection refused
905
953
----
906
954
907
955
Hmm, `curl` fails on the server too.
908
- But all this talk of `port 80`, both locally and on the server, might be giving us a clue.
956
+ But all this talk of `port 80`, both locally and on the server, might be giving us a clue!
909
957
Let's check `docker ps`:
910
958
911
959
[subs="specialcharacters,quotes"]
@@ -947,6 +995,7 @@ element: [id="id_list_table"]; [...]
947
995
948
996
// DAVID: tests pass for me now! And I can create lists on the server...
949
997
// Strange, I'm pretty sure I didn't run migrations.
998
+ // TODO: let's add an rm db.slqite3 inside the dockerfile maybe, to make sure this doesn't happen.
950
999
951
1000
=== Mounting the database on the server and running migrations
952
1001
@@ -981,7 +1030,7 @@ skipped=0 rescued=0 ignored=0
981
1030
----
982
1031
983
1032
// RITA: Please expand this intro sentence. Here's how to do what?
984
- Here's how
1033
+ Here's how
985
1034
986
1035
[role="sourcecode"]
987
1036
.infra/ansible-provision.yaml (ch11l007)
0 commit comments