0

Hi I just finished deploying a project with Django, Docker and Heroku based on the https://djangoforprofessionals.com/ tutorial. However, I don't know how to switch back to local development after having deployed the app. If i go to 127.0.0.1:8000 in my browser i get a ERR_TIMED_OUT message.

Here is the official source code, which corresponds 1:1 to my code: https://github.com/wsvincent/djangoforprofessionals/tree/master/ch18-deployment

In the tutorial there are two docker-compose files, a docker-compose.yml for local development and a docker-compose-prod.yml for deployment. My idea was to run docker-compose down and docker-compose -f docker-compose.yml up -d --build after deployment to continue working locally, but it did not work out.

Any help would be much appreciated!

Daniel
  • 963
  • 1
  • 12
  • 29
  • Did you do a `runserver` to start a local server? – dfundako Jan 29 '20 at 15:13
  • no, but I did not need to do that beforehand neither, just did docker-compose up and I could access my app via 127.0.0.1:8000 – Daniel Jan 29 '20 at 15:20
  • Thats because your docker-compose file has a `command` section in it that had the `runserver` command. Look at the ch1 repo and the docker-compose file to see an example. – dfundako Jan 29 '20 at 15:24
  • I see...in the tutorial they switched the `command` section in the `docker-compose.yml` and `docker-compose-prod.yml` files from `python /code/manage.py runserver 0.0.0.0:8000` to `gunicorn bookstore_project.wsgi -b 0.0.0.0:8000` - so do i need to switch it back in order to make it work and is it enough if I switch it only back in the docker-compose.yml file? Or can I run gunicorn locally? – Daniel Jan 29 '20 at 15:31
  • Read through the section on multiple compose files: https://runnable.com/docker/advanced-docker-compose-configuration – dfundako Jan 29 '20 at 15:46
  • thanks, I read it and tried the following: run `docker-compose down`, `docker-compose -f docker-compose.yml up -d --build` . If I understand correctly this should start the gunicorn server via `command: gunicorn bookstore_project.wsgi -b 0.0.0.0:8000` in the file and I should be able to see my app if I go to https://127.0.0.1:8000/ - but this is not the case – Daniel Jan 29 '20 at 16:06
  • it is enough to run `docker-compose up -d` as docker-compose.yml file is the default with multiple docker-compose files - however Istill can't get my app running locally. `docker-compose ps` gives me: `Attaching to books_web_1, books_db_1 web_1 | [2020-01-29 16:12:26 +0000] [1] [INFO] Starting gunicorn 19.9.0 web_1 | [2020-01-29 16:12:26 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1) web_1 | [2020-01-29 16:12:26 +0000] [1] [INFO] Using worker: sync web_1 | [2020-01-29 16:12:26 +0000] [8] [INFO] Booting worker with pid: 8` etc. – Daniel Jan 29 '20 at 16:29

0 Answers0