You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running manage.py collectstatic within a Dockerfile causes error.
Dockerfile example:
FROM netboxcommunity/netbox:latest
COPY ./plugin_requirements.txt /
RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /plugin_requirements.txt
# These lines are only required if your plugin has its own static files.
COPY configuration/configuration.py /etc/netbox/config/configuration.py
RUN SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
Error when docker-compose build:
Traceback (most recent call last):
File "/opt/netbox/netbox/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 420, in execute
django.setup()
File "/opt/netbox/venv/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/apps/registry.py", line 124, in populate
app_config.ready()
File "/opt/netbox/netbox/extras/plugins/__init__.py", line 68, in ready
template_extensions = import_object(f"{self.__module__}.{self.template_extensions}")
File "/opt/netbox/netbox/extras/plugins/utils.py", line 31, in import_object
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/opt/netbox-attachments/netbox_attachments/template_content.py", line 46, in <module>
for content_type in ContentType.objects.all():
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 320, in __iter__
self._fetch_all()
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1507, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 57, in __iter__
results = compiler.execute_sql(
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1359, in execute_sql
cursor = self.connection.cursor()
File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/base/base.py", line 284, in cursor
return self._cursor()
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/base/base.py", line 260, in _cursor
self.ensure_connection()
File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/base/base.py", line 243, in ensure_connection
with self.wrap_database_errors:
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/base/base.py", line 244, in ensure_connection
self.connect()
File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/base/base.py", line 225, in connect
self.connection = self.get_new_connection(conn_params)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/postgresql/base.py", line 203, in get_new_connection
connection = Database.connect(**conn_params)
File "/opt/netbox/venv/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
Reason:
Loads /opt/netbox-attachments/netbox_attachments/template_content.py file, which iterates through ContentType.objects.all():
Database is not UP when running this command
Returns connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
The text was updated successfully, but these errors were encountered:
Running
manage.py collectstatic
within aDockerfile
causes error.Dockerfile example:
Error when
docker-compose build
:Reason:
/opt/netbox-attachments/netbox_attachments/template_content.py
file, which iterates throughContentType.objects.all():
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
The text was updated successfully, but these errors were encountered: