Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suddenly got problems with deploy of container #3386

Open
dataanh opened this issue Nov 2, 2024 · 2 comments
Open

Suddenly got problems with deploy of container #3386

dataanh opened this issue Nov 2, 2024 · 2 comments
Labels
setup issue possibly or definitely an issue with the user setup

Comments

@dataanh
Copy link

dataanh commented Nov 2, 2024

Issue

I used tandoor for a long time, no problems. Suddenly after bad stop of my Container Manager, it's impossible for me to deploy the container. Tried to delete everything, but no change. Can't understand the log.

Tandoor Version

newest

OS Version

Synology Portainer

Setup

Docker / Docker-Compose

Reverse Proxy

Nginx Proxy Manager (NPM)

Other

No response

Environment file

# only set this to true when testing/debugging
# when unset: 1 (true) - dont unset this, just for development
DEBUG=0
SQL_DEBUG=0

# HTTP port to bind to
# TANDOOR_PORT=8080

# hosts the application can run under e.g. recipes.mydomain.com,cooking.mydomain.com,...
ALLOWED_HOSTS=*

# random secret key, use for example `base64 /dev/urandom | head -c50` to generate one
# ---------------------------- REQUIRED -------------------------
SECRET_KEY=YOUR_SECRET_KEY_CHANGE_ME_PLEASE
# ---------------------------------------------------------------

# your default timezone See https://timezonedb.com/time-zones for a list of timezones
TZ=Europe/Berlin

# add only a database password if you want to run with the default postgres, otherwise change settings accordingly
DB_ENGINE=django.db.backends.postgresql
# DB_OPTIONS= {} # e.g. {"sslmode":"require"} to enable ssl
POSTGRES_HOST=tandoor-db
POSTGRES_PORT=5432
POSTGRES_USER=tandooruser
# ---------------------------- REQUIRED -------------------------
POSTGRES_PASSWORD=tandoorpass
# ---------------------------------------------------------------
POSTGRES_DB=tandoor

# database connection string, when used overrides other database settings.
# format might vary depending on backend
# DATABASE_URL = engine://username:password@host:port/dbname

# the default value for the user preference 'fractions' (enable/disable fraction support)
# default: disabled=0
FRACTION_PREF_DEFAULT=0

# the default value for the user preference 'comments' (enable/disable commenting system)
# default comments enabled=1
COMMENT_PREF_DEFAULT=1

# Users can set a amount of time after which the shopping list is refreshed when they are in viewing mode
# This is the minimum interval users can set. Setting this to low will allow users to refresh very frequently which
# might cause high load on the server. (Technically they can obviously refresh as often as they want with their own scripts)
SHOPPING_MIN_AUTOSYNC_INTERVAL=5

# Default for user setting sticky navbar
# STICKY_NAV_PREF_DEFAULT=1

# If base URL is something other than just / (you are serving a subfolder in your proxy for instance http://recipe_app/recipes/)
# Be sure to not have a trailing slash: e.g. '/recipes' instead of '/recipes/'
# SCRIPT_NAME=/recipes

# If staticfiles are stored at a different location uncomment and change accordingly, MUST END IN /
# this is not required if you are just using a subfolder
# This can either be a relative path from the applications base path or the url of an external host
# STATIC_URL=/static/

# If mediafiles are stored at a different location uncomment and change accordingly, MUST END IN /
# this is not required if you are just using a subfolder
# This can either be a relative path from the applications base path or the url of an external host
# MEDIA_URL=/media/

# Serve mediafiles directly using gunicorn. Basically everyone recommends not doing this. Please use any of the examples
# provided that include an additional nxginx container to handle media file serving.
# If you know what you are doing turn this back on (1) to serve media files using djangos serve() method.
# when unset: 1 (true) - this is temporary until an appropriate amount of time has passed for everyone to migrate
GUNICORN_MEDIA=0

# GUNICORN SERVER RELATED SETTINGS (see https://docs.gunicorn.org/en/stable/design.html#how-many-workers for recommended settings)
# GUNICORN_WORKERS=1
# GUNICORN_THREADS=1

# S3 Media settings: store mediafiles in s3 or any compatible storage backend (e.g. minio)
# as long as S3_ACCESS_KEY is not set S3 features are disabled
# S3_ACCESS_KEY=
# S3_SECRET_ACCESS_KEY=
# S3_BUCKET_NAME=
# S3_REGION_NAME= # default none, set your region might be required
# S3_QUERYSTRING_AUTH=1 # default true, set to 0 to serve media from a public bucket without signed urls
# S3_QUERYSTRING_EXPIRE=3600 # number of seconds querystring are valid for
# S3_ENDPOINT_URL= # when using a custom endpoint like minio
# S3_CUSTOM_DOMAIN= # when using a CDN/proxy to S3 (see https://github.com/TandoorRecipes/recipes/issues/1943)

# Email Settings, see https://docs.djangoproject.com/en/3.2/ref/settings/#email-host
# Required for email confirmation and password reset (automatically activates if host is set)
# EMAIL_HOST=
# EMAIL_PORT=
# EMAIL_HOST_USER=
# EMAIL_HOST_PASSWORD=
# EMAIL_USE_TLS=0
# EMAIL_USE_SSL=0
# email sender address (default 'webmaster@localhost')
# DEFAULT_FROM_EMAIL=
# prefix used for account related emails (default "[Tandoor Recipes] ")
# ACCOUNT_EMAIL_SUBJECT_PREFIX=

# allow authentication via reverse proxy (e.g. authelia), leave off if you dont know what you are doing
# see docs for more information https://vabene1111.github.io/recipes/features/authentication/
# when unset: 0 (false)
REMOTE_USER_AUTH=0

# Default settings for spaces, apply per space and can be changed in the admin view
# SPACE_DEFAULT_MAX_RECIPES=0 # 0=unlimited recipes
# SPACE_DEFAULT_MAX_USERS=0 # 0=unlimited users per space
# SPACE_DEFAULT_MAX_FILES=0 # Maximum file storage for space in MB. 0 for unlimited, -1 to disable file upload.
# SPACE_DEFAULT_ALLOW_SHARING=1 # Allow users to share recipes with public links

# allow people to create accounts on your application instance (without an invite link)
# when unset: 0 (false)
# ENABLE_SIGNUP=0

# If signup is enabled you might want to add a captcha to it to prevent spam
# HCAPTCHA_SITEKEY=
# HCAPTCHA_SECRET=

# if signup is enabled you might want to provide urls to data protection policies or terms and conditions
# TERMS_URL=
# PRIVACY_URL=
# IMPRINT_URL=

# enable serving of prometheus metrics under the /metrics path
# ATTENTION: view is not secured (as per the prometheus default way) so make sure to secure it
# trough your web server (or leave it open of you dont care if the stats are exposed)
# ENABLE_METRICS=0

# allows you to setup OAuth providers
# see docs for more information https://vabene1111.github.io/recipes/features/authentication/
# SOCIAL_PROVIDERS = allauth.socialaccount.providers.github, allauth.socialaccount.providers.nextcloud,

# Should a newly created user from a social provider get assigned to the default space and given permission by default ?
# ATTENTION: This feature might be deprecated in favor of a space join and public viewing system in the future
# default 0 (false), when 1 (true) users will be assigned space and group
# SOCIAL_DEFAULT_ACCESS = 1

# if SOCIAL_DEFAULT_ACCESS is used, which group should be added
# SOCIAL_DEFAULT_GROUP=guest

# Django session cookie settings. Can be changed to allow a single django application to authenticate several applications
# when running under the same database
# SESSION_COOKIE_DOMAIN=.example.com
# SESSION_COOKIE_NAME=sessionid # use this only to not interfere with non unified django applications under the same top level domain

# by default SORT_TREE_BY_NAME is disabled this will store all Keywords and Food in the order they are created
# enabling this setting makes saving new keywords and foods very slow, which doesn't matter in most usecases.
# however, when doing large imports of recipes that will create new objects, can increase total run time by 10-15x
# Keywords and Food can be manually sorted by name in Admin
# This value can also be temporarily changed in Admin, it will revert the next time the application is started
# This will be fixed/changed in the future by changing the implementation or finding a better workaround for sorting
# SORT_TREE_BY_NAME=0
# LDAP authentication
# default 0 (false), when 1 (true) list of allowed users will be fetched from LDAP server
#LDAP_AUTH=
#AUTH_LDAP_SERVER_URI=
#AUTH_LDAP_BIND_DN=
#AUTH_LDAP_BIND_PASSWORD=
#AUTH_LDAP_USER_SEARCH_BASE_DN=
#AUTH_LDAP_TLS_CACERTFILE=

# Enables exporting PDF (see export docs)
# Disabled by default, uncomment to enable
ENABLE_PDF_EXPORT=1

# Recipe exports are cached for a certain time by default, adjust time if needed
EXPORT_FILE_CACHE_DURATION=600

Docker-Compose file

services:
  db:
    image: postgres:16
    container_name: Tandoor-DB
    hostname: tandoor-db
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "tandoor", "-U", "tandooruser"]
      timeout: 45s
      interval: 10s
      retries: 10
    volumes:
      - /volume1/docker/tandoor/db:/var/lib/postgresql/data
    env_file:
      - stack.env
    restart: on-failure:5

  tandoor:
    image: vabene1111/recipes:latest
    container_name: Tandoor
    hostname: tandoor
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8080 || exit 1
    volumes:
      - /volume1/docker/tandoor/staticfiles:/opt/recipes/staticfiles:rw
      - /volume1/docker/tandoor/mediafiles:/opt/recipes/mediafiles:rw
      - /volume1/docker/tandoor/nginx:/opt/recipes/nginx/conf.d:rw
    env_file:
      - stack.env
    restart: on-failure:5
    depends_on:
      db:
        condition: service_started

  nginx:
    image: nginx:mainline-alpine
    container_name: Tandoor-NGINX
    hostname: nginx-tandoor
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:80 || exit 1
    volumes:
      - /volume1/docker/tandoor/staticfiles:/static:ro
      - /volume1/docker/tandoor/mediafiles:/media:ro
      - /volume1/docker/tandoor/nginx:/etc/nginx/conf.d:ro
    ports:
      - 9815:80
    env_file:
      - stack.env
    restart: on-failure:5
    depends_on:
      tandoor:
        condition: service_healthy

Relevant logs

Tandoor-DB:
PostgreSQL Database directory appears to contain a database; Skipping initialization
2024-11-02 15:54:08.160 CET [1] LOG:  starting PostgreSQL 16.4 (Debian 16.4-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2024-11-02 15:54:08.160 CET [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-11-02 15:54:08.161 CET [1] LOG:  listening on IPv6 address "::", port 5432
2024-11-02 15:54:08.163 CET [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-11-02 15:54:08.169 CET [29] LOG:  database system was shut down at 2024-11-02 15:44:47 CET
2024-11-02 15:54:08.175 CET [1] LOG:  database system is ready to accept connections
2024-11-02 15:55:44.582 CET [1] LOG:  received fast shutdown request
2024-11-02 15:55:44.598 CET [1] LOG:  aborting any active transactions
2024-11-02 15:55:44.600 CET [1] LOG:  background worker "logical replication launcher" (PID 32) exited with exit code 1
2024-11-02 15:55:44.603 CET [27] LOG:  shutting down
2024-11-02 15:55:44.615 CET [27] LOG:  checkpoint starting: shutdown immediate
2024-11-02 15:55:44.768 CET [27] LOG:  checkpoint complete: wrote 2 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.034 s, total=0.166 s; sync files=3, longest=0.034 s, average=0.012 s; distance=0 kB, estimate=0 kB; lsn=0/21C8658, redo lsn=0/21C8658
2024-11-02 15:55:44.773 CET [1] LOG:  database system is shut down


      

Tandoor:
Checking configuration...
�
]
Nginx configuration file could not be found at the default location!
Path: /opt/recipes/nginx/conf.d/Recipes.conf
Waiting for database to be ready...
Database is ready
Migrating database
Operations to perform:
  Apply all migrations: account, admin, auth, authtoken, contenttypes, cookbook, oauth2_provider, sessions, sites, socialaccount
Running migrations:
  No migrations to apply.
Collecting static files, this may take a while...
js-reverse file written to /opt/recipes/cookbook/static/django_js_reverse
Traceback (most recent call last):
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/core/files/storage/handler.py", line 35, in __getitem__
Done
    return self._storages[alias]
           ~~~~~~~~~~~~~~^^^^^^^
KeyError: 'staticfiles'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/opt/recipes/manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 184, in handle
    if self.is_local_storage() and self.storage.location:
       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 245, in is_local_storage
    return isinstance(self.storage, FileSystemStorage)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/utils/functional.py", line 295, in __getattribute__
    value = super().__getattribute__(name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/utils/functional.py", line 266, in inner
    self._setup()
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/contrib/staticfiles/storage.py", line 537, in _setup
    self._wrapped = storages[STATICFILES_STORAGE_ALIAS]
                    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/core/files/storage/handler.py", line 43, in __getitem__
    storage = self.create_storage(params)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/core/files/storage/handler.py", line 55, in create_storage
    return storage_cls(**options)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/whitenoise/storage.py", line 64, in __init__
    super().__init__(*args, **kwargs)
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/contrib/staticfiles/storage.py", line 460, in __init__
    self.hashed_files, self.manifest_hash = self.load_manifest()
                                            ^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/contrib/staticfiles/storage.py", line 481, in load_manifest
    raise ValueError(
ValueError: Couldn't load manifest 'staticfiles.json' (version 1.1)
[2024-11-02 16:54:21 +0200] [1] [INFO] Starting gunicorn 22.0.0
[2024-11-02 16:54:21 +0200] [1] [INFO] Listening at: http://[::]:8080 (1)
[2024-11-02 16:54:21 +0200] [1] [INFO] Using worker: gthread
[2024-11-02 16:54:21 +0200] [16] [INFO] Booting worker with pid: 16
[2024-11-02 16:54:21 +0200] [17] [INFO] Booting worker with pid: 17
[2024-11-02 16:54:21 +0200] [18] [INFO] Booting worker with pid: 18
::ffff:127.0.0.1 - - [02/Nov/2024:16:54:39 +0200] "GET / HTTP/1.1" 302 0 "-" "Wget"
::ffff:127.0.0.1 - - [02/Nov/2024:16:54:39 +0200] "GET /search/ HTTP/1.1" 302 0 "-" "Wget"
::ffff:127.0.0.1 - - [02/Nov/2024:16:54:39 +0200] "GET /accounts/login/?next=/search/ HTTP/1.1" 500 145 "-" "Wget"
::ffff:127.0.0.1 - - [02/Nov/2024:16:55:09 +0200] "GET / HTTP/1.1" 302 0 "-" "Wget"
::ffff:127.0.0.1 - - [02/Nov/2024:16:55:09 +0200] "GET /search/ HTTP/1.1" 302 0 "-" "Wget"
::ffff:127.0.0.1 - - [02/Nov/2024:16:55:09 +0200] "GET /accounts/login/?next=/search/ HTTP/1.1" 500 145 "-" "Wget"
::ffff:127.0.0.1 - - [02/Nov/2024:16:55:40 +0200] "GET / HTTP/1.1" 302 0 "-" "Wget"
::ffff:127.0.0.1 - - [02/Nov/2024:16:55:40 +0200] "GET /search/ HTTP/1.1" 302 0 "-" "Wget"
::ffff:127.0.0.1 - - [02/Nov/2024:16:55:40 +0200] "GET /accounts/login/?next=/search/ HTTP/1.1" 500 145 "-" "Wget"
[2024-11-02 16:55:40 +0200] [1] [INFO] Handling signal: term
@dataanh dataanh added the setup issue possibly or definitely an issue with the user setup label Nov 2, 2024
@smilerz
Copy link
Collaborator

smilerz commented Nov 2, 2024

It looks like there's an issue with the staticfiles folder. Can you check if it exists and what permissions are?

@qupterra
Copy link

qupterra commented Nov 8, 2024

I encountered this issue and found that the staticfiles.json file was 0 bytes in size.

I ran mv staticfiles.json staticfiles.json_old to copy the existing (zero byte) file to keep it safe just in case, restarted the container and it started working again.

I found it at the location where my docker volumes were stored, then ../docker_staticfiles/_data/staticfiles.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
setup issue possibly or definitely an issue with the user setup
Projects
None yet
Development

No branches or pull requests

3 participants