cfahlgren1 / Bounce

A Django web application that uses MapBox to show thousands of outdoor basketball courts all around the United States
https://bouncemap.com
19 stars 9 forks source link

Docker implementation issue #22

Closed BenjMaq closed 4 years ago

BenjMaq commented 4 years ago

Hey,

I think there are a few things missing in the setup guide. Currently, it does not work for a completely new contributor. I've kept track of the few things I've had to do manually, and I'll push a PR once I'm able to get everything working.

In the meantime, I'm facing an issue when running command ./manage.py loaddata bounce_data.json

bash: ./manage.py: /usr/bin/env: bad interpreter: Permission denied

I also tried python ./manage.py loaddata bounce_data.json but then I have

Traceback (most recent call last):
  File "./manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 71, in handle
    with transaction.atomic(using=self.using):
  File "/usr/local/lib/python3.8/site-packages/django/db/transaction.py", line 175, in __enter__
    if not connection.get_autocommit():
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 390, in get_autocommit
    self.ensure_connection()
  File "/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
    self.connect()
  File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
    self.connect()
  File "/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 197, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 185, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/usr/local/lib/python3.8/site-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Can you help @cfahlgren1 ? Thanks

cfahlgren1 commented 4 years ago

@BenjMaq, I will take a look at it tonight. I was able to setup with the guide from scratch before, but I will try again. It should just be the few docker commands and setting up the .env file. It seems like it might be an issue with the docker connection. Are you able to run docker without any errors? Check docker-compose logs

BenjMaq commented 4 years ago

Hey, yes I checked the logs and the error is the same as the above one:

Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Also, it would be great to have a guide on how to setup the .env file. For someone clueless of Django and Postgres like me, it's really not clear what to do to fill the .env file.

What do I need to add there?

NAME=
DATABASE=postgres
DB_HOST=
PASSWORD=
DISABLE_COLLECTSTATIC=1
PORT=5432
SECRET_KEY=
cfahlgren1 commented 4 years ago

Hey, yes I checked the logs and the error is the same as the above one:


Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Also, it would be great to have a guide on how to setup the .env file. For someone clueless of Django and Postgres like me, it's really not clear what to do to fill the .env file.

What do I need to add there?


NAME=

DATABASE=postgres

DB_HOST=

PASSWORD=

DISABLE_COLLECTSTATIC=1

PORT=5432

SECRET_KEY=

Okay I think I know what your issue is. I forgot to upload the new .env.template file. I uploaded the correct one last night. So pull down the new changes and update your env file

cfahlgren1 commented 4 years ago

Hey, yes I checked the logs and the error is the same as the above one:


Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Also, it would be great to have a guide on how to setup the .env file. For someone clueless of Django and Postgres like me, it's really not clear what to do to fill the .env file.

What do I need to add there?


NAME=

DATABASE=postgres

DB_HOST=

PASSWORD=

DISABLE_COLLECTSTATIC=1

PORT=5432

SECRET_KEY=

Okay I think I know what your issue is. I forgot to upload the new .env.template file. I uploaded the correct one last night. So pull down the new changes and update your env file. @marcorichetta what did your local .env file look like?

cfahlgren1 commented 4 years ago

@BenjMaq the new .env.template has the two environment variables that connect to docker. That's the part your missing.

BenjMaq commented 4 years ago

I have rebased this morning so this is definitely not the issue. I just don’t know how should I fill the .env file?

The .env.template file has a lot of env variable empty, like

NAME=
DB_HOST=
PASSWORD=
SECRET_KEY=

A guide on what to fill in there would be useful