Closed writeson closed 2 years ago
@writeson How do you start the app?
From a Mac terminal command line:
docker-compose -f deploy/docker-compose.yml --project-directory . up --build
Then in a browser trying to open either HTTP://localhost:8000 or HTTP://0.0.0.0:8000, neither seem to work for me.
@writeson Please add -f ./deploy/docker-compose.dev.yml
before project-directory.
Because by default docker compose config doesn't expose any ports.
Please close the issues if the fix is confirmed.
The change you suggested, adding ./
in front of deploy/docker-compose.yml
didn't fix the problem. However, adding:
ports:
- 8000:8000
To the api service, and:
ports:
- 3306:3306
To the db service, made HTTP://localhost/8000 return something, and the database visible to tools like DataGrip.
I am getting this message in the startup sequence though:
doug_fastapi-db-1 | find: '/docker-entrypoint-startdb.d/': No such file or directory
And HTTP://localhost:8000/health returns a 404
@writeson Yeah. Adding ports in docker-compose will definitely solve the problem.
But I was suggesting you to try this command:
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . up --build
Because it overrides previous compose files.
Also, the correct URL for healthchecks is /api/health
You can check list of all URLs in swagger: /api/docs
Thanks for the full command; I'm still pretty much a noob at Docker. Also, what can I say about the /api/health
and /api/docs
aside from D'OH! I'm being particularly dense lately.
It's totally ok. You'll learn everything soon. Also, by opening this issue, you may help someone who'll be struggling with the same problem as you. Every issue is super helpful. Thanks.
where I can see the swagger UI, I have used the docker command you mentioned above. Also, I am new to this thing, can we have the documentation for this template? As we run a fast API app on localhost, is it compulsory to require the docker?
You need to either set ports in you docker compose file, as mentioned here or find out container's IP and send request directly to it.
Docker is not required, but it makes working with application easier, because you don't need to spin up the database on your local machine.
Maybe I'm being dense, but I can't seem to access the web server. I've got the containers running following the README, but navigating to HTTP://0.0.0.0:8000 brings up nothing.... What am I missing?