Closed MikeTheCanuck closed 6 years ago
Hey,
This is basically the same pattern we followed last year, and would provide a not found if going to the root on a local machine. If you remember the load balancer on AWS will point to the /api
path and not the root of the directory, so will auto-direct you to the correct location once live. IF i remember correctly, we did remove the Django built in browsable api (what you currently see at the /api path) and just use swagger (what is currently at the /schema path).
This can be done pretty quickly.
Can document the not found though in the readme, more directly. Unless, we expect to make a change to how the load balancer works.
Also, on Windows hosting, browsing to http://0.0.0.0:8000/
won't work! So this needs to be documented somehow.
On Windows 10 Pro with Docker for Windows, it's http://localhost:8000/api
. For other Windows versions with Docker Toolbox, you have to do docker-machine ip
and put the IP address where localhost
is in the above URL. :-(
Ok, to update, we actual led to the team name to work with the load balancer:
https://github.com/hackoregon/backend-service-pattern/blob/master/homelessAPI/urls.py#L24
url(r'^homeless/', include('homelessApp.urls', namespace='homeless'))
the root of which went to the schema_view:
from django.conf.urls import url
from . import views
from rest_framework_swagger.views import get_swagger_view
schema_view = get_swagger_view(title='Team Homelessness API')
urlpatterns = [
url(r'^$', schema_view),
url(r'^disability/$', views.ListDisability.as_view()),
url(r'^ethnicity/$', views.ListEthnicity.as_view()),
url(r'^gender/$', views.ListGender.as_view()),
url(r'^geolocation/$', views.ListGeographiclocation.as_view()),
url(r'^individuals/$', views.ListHomelessindividuals.as_view()),
url(r'^veterans/$', views.ListVeterans.as_view()),
url(r'^sleeping/$', views.ListSleepingLocation.as_view()),
url(r'^length/$', views.ListLengthOfHomelessness.as_view()),
url(r'^domesticviolence/$', views.ListDomesticViolence.as_view()),
url(r'^chronic/$', views.ListChronicHomelessness.as_view()),
url(r'^agehousecomp/$', views.ListChronicHomelessness.as_view()),
url(r'^acsage/$', views.ListAcsage.as_view()),
url(r'^acsdisability/$', views.ListAcsdisability.as_view()),
url(r'^acsrace/$', views.ListAcsrace.as_view()),
url(r'^acsveteran/$', views.ListAgeHouseComp.as_view()),
]
This will still return a Not Found locally.
So guess we have a few tasks:
I'll start on the README - it's Docker host dependent.
I've updated the README with notes on Windows and Linux Docker hosting. I don't have a Mac; someone else will need to do that one. I think Docker for Mac is the same as Docker for Windows.
@bhgrant8 thank you for reminding me how we got to this state last year (don't know how I forgot that very meaningful switchover to ALB and a single front-end for all the services).
@znmeb thanks for documenting - the Mac scenario works the same both for native Docker and for the Docker Toolbox. It also looked like the Linux scenario was same as native Docker for Windows & MacOS so I rearranged things for clarity: https://github.com/hackoregon/backend-examplar-2018/commit/209c738c869425c34874c1a368330989ed641a75
The way I run Docker for Windows is via Windows Subsystem for Linux Ubuntu. That's documented at https://github.com/hackoregon/data-science-pet-containers/blob/master/win10pro-wsl-ubuntu-tools/README.md, I had trouble with the git bash
window, Most things worked but there were some annoying things that didn't.
When I run
./bin/start.sh -l
, the startup process finalizes with the following console output:So, after my experiences last year with the API containers, I browsed to
http://0.0.0.0:8000/
and expected some form of 200/OK type reponse, and some basic Django API response.Instead I see the following:
The
/admin
and/schema
routes work fine, as documented later, but this could be disconcerting to a new Django developer.