TandoorRecipes / recipes

Application for managing recipes, planning meals, building shopping lists and much much more!
https://docs.tandoor.dev
Other
5.35k stars 563 forks source link

Brand new docker install don't use postgres db #2791

Closed meepmeep closed 9 months ago

meepmeep commented 9 months ago

Tandoor Version

1.5.10

Setup

Docker / Docker-Compose

Reverse Proxy

Others (please state below)

Other

Own nginx

Bug description

Getting the .env from https://raw.githubusercontent.com/vabene1111/recipes/develop/.env.template and rename it to .env Getting docker-compose file from https://raw.githubusercontent.com/vabene1111/recipes/develop/docs/install/docker/traefik-nginx/docker-compose.yml

Modifying the nginx_recipes port to match my own nginx's reverse proxy conf (8282)

# grep -v '^\s*$\|^\s*\#' .env
DEBUG=0
SQL_DEBUG=0
DEBUG_TOOLBAR=0
ALLOWED_HOSTS=*
SECRET_KEY=<REDATED>
TZ=Europe/Paris
DB_ENGINE=django.db.backends.postgresql
POSTGRES_HOST=db_recipes
POSTGRES_PORT=5432
POSTGRES_USER=djangouser
POSTGRES_PASSWORD=<REDATED>
POSTGRES_DB=djangodb
FRACTION_PREF_DEFAULT=0
COMMENT_PREF_DEFAULT=1
SHOPPING_MIN_AUTOSYNC_INTERVAL=5
GUNICORN_MEDIA=0
EMAIL_HOST="<REDATED>"
EMAIL_PORT=465
EMAIL_HOST_USER="<REDATED>"
EMAIL_HOST_PASSWORD="<REDATED>"
EMAIL_USE_TLS=0
EMAIL_USE_SSL=1
DEFAULT_FROM_EMAIL="<REDATED>"
ACCOUNT_EMAIL_SUBJECT_PREFIX="[Tandoor Recipes] "
REMOTE_USER_AUTH=0
# cat docker-compose.yml
version: "3"
services:
  db_recipes:
    restart: always
    image: postgres:15-alpine
    volumes:
      - ./postgresql:/var/lib/postgresql/data
    env_file:
      - ./.env

  web_recipes:
    restart: always
    image: vabene1111/recipes
    env_file:
      - ./.env
    volumes:
      - staticfiles:/opt/recipes/staticfiles
      # Do not make this a bind mount, see https://docs.tandoor.dev/install/docker/#volumes-vs-bind-mounts
      - nginx_config:/opt/recipes/nginx/conf.d
      - ./mediafiles:/opt/recipes/mediafiles
    depends_on:
      - db_recipes

  nginx_recipes:
    image: nginx:mainline-alpine
    restart: always
    ports:
      - 8282:80
    env_file:
      - ./.env
    depends_on:
      - web_recipes
    volumes:
      # Do not make this a bind mount, see https://docs.tandoor.dev/install/docker/#volumes-vs-bind-mounts
      - nginx_config:/etc/nginx/conf.d:ro
      - staticfiles:/static:ro
      - ./mediafiles:/media:ro

volumes:
  nginx_config:
  staticfiles:

Starting recipes, it works, I can create my account, create my space, but " This application is not running with a Postgres database backend. This is ok but not recommended as some features only work with postgres databases. "

Gunicorn Media: False
Sqlite: True
Debug: False

image

(and it's not link to https://github.com/TandoorRecipes/recipes/issues/1936 because I haven't override env variable from docker-compose)

Relevant logs

MailCow:/opt/recipes# docker-compose up
[+] Running 4/4
 ✔ Network recipes_default            Created                                                                                                     0.1s
 ✔ Container recipes-db_recipes-1     Created                                                                                                     0.2s
 ✔ Container recipes-web_recipes-1    Created                                                                                                     0.0s
 ✔ Container recipes-nginx_recipes-1  Created                                                                                                     0.0s
Attaching to recipes-db_recipes-1, recipes-nginx_recipes-1, recipes-web_recipes-1
recipes-db_recipes-1     | The files belonging to this database system will be owned by user "postgres".
recipes-db_recipes-1     | This user must also own the server process.
recipes-db_recipes-1     |
recipes-db_recipes-1     | The database cluster will be initialized with locale "en_US.utf8".
recipes-db_recipes-1     | The default database encoding has accordingly been set to "UTF8".
recipes-db_recipes-1     | The default text search configuration will be set to "english".
recipes-db_recipes-1     |
recipes-db_recipes-1     | Data page checksums are disabled.
recipes-db_recipes-1     |
recipes-db_recipes-1     | fixing permissions on existing directory /var/lib/postgresql/data ... ok
recipes-db_recipes-1     | creating subdirectories ... ok
recipes-db_recipes-1     | selecting dynamic shared memory implementation ... posix
recipes-db_recipes-1     | selecting default max_connections ... 100
recipes-db_recipes-1     | selecting default shared_buffers ... 128MB
recipes-db_recipes-1     | selecting default time zone ... Europe/Paris
recipes-db_recipes-1     | creating configuration files ... ok
recipes-db_recipes-1     | running bootstrap script ... ok
recipes-web_recipes-1    | Checking configuration...
recipes-web_recipes-1    | Waiting for database to be ready...
recipes-db_recipes-1     | sh: locale: not found
recipes-db_recipes-1     | 2023-12-09 16:57:32.107 CET [31] WARNING:  no usable system locales were found
recipes-nginx_recipes-1  | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
recipes-nginx_recipes-1  | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
recipes-nginx_recipes-1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
recipes-nginx_recipes-1  | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
recipes-nginx_recipes-1  | /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
recipes-nginx_recipes-1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
recipes-nginx_recipes-1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
recipes-nginx_recipes-1  | /docker-entrypoint.sh: Configuration complete; ready for start up
recipes-nginx_recipes-1  | 2023/12/09 16:57:32 [notice] 1#1: using the "epoll" event method
recipes-nginx_recipes-1  | 2023/12/09 16:57:32 [notice] 1#1: nginx/1.25.3
recipes-nginx_recipes-1  | 2023/12/09 16:57:32 [notice] 1#1: built by gcc 12.2.1 20220924 (Alpine 12.2.1_git20220924-r10)
recipes-nginx_recipes-1  | 2023/12/09 16:57:32 [notice] 1#1: OS: Linux 6.1.0-13-amd64
recipes-nginx_recipes-1  | 2023/12/09 16:57:32 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
recipes-nginx_recipes-1  | 2023/12/09 16:57:32 [notice] 1#1: start worker processes
recipes-nginx_recipes-1  | 2023/12/09 16:57:32 [notice] 1#1: start worker process 20
recipes-nginx_recipes-1  | 2023/12/09 16:57:32 [notice] 1#1: start worker process 21
recipes-nginx_recipes-1  | 2023/12/09 16:57:32 [notice] 1#1: start worker process 22
recipes-nginx_recipes-1  | 2023/12/09 16:57:32 [notice] 1#1: start worker process 23
recipes-db_recipes-1     | performing post-bootstrap initialization ... ok
recipes-db_recipes-1     | syncing data to disk ... ok
recipes-db_recipes-1     |
recipes-db_recipes-1     |
recipes-db_recipes-1     | Success. You can now start the database server using:
recipes-db_recipes-1     |
recipes-db_recipes-1     |     pg_ctl -D /var/lib/postgresql/data -l logfile start
recipes-db_recipes-1     |
recipes-db_recipes-1     | initdb: warning: enabling "trust" authentication for local connections
recipes-db_recipes-1     | initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
recipes-db_recipes-1     | waiting for server to start....2023-12-09 16:57:32.572 CET [37] LOG:  starting PostgreSQL 15.5 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014, 64-bit
recipes-db_recipes-1     | 2023-12-09 16:57:32.577 CET [37] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
recipes-db_recipes-1     | 2023-12-09 16:57:32.590 CET [40] LOG:  database system was shut down at 2023-12-09 16:57:32 CET
recipes-db_recipes-1     | 2023-12-09 16:57:32.596 CET [37] LOG:  database system is ready to accept connections
recipes-db_recipes-1     |  done
recipes-db_recipes-1     | server started
recipes-db_recipes-1     | CREATE DATABASE
recipes-db_recipes-1     |
recipes-db_recipes-1     |
recipes-db_recipes-1     | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
recipes-db_recipes-1     |
recipes-db_recipes-1     | waiting for server to shut down....2023-12-09 16:57:32.703 CET [37] LOG:  received fast shutdown request
recipes-db_recipes-1     | 2023-12-09 16:57:32.707 CET [37] LOG:  aborting any active transactions
recipes-db_recipes-1     | 2023-12-09 16:57:32.709 CET [37] LOG:  background worker "logical replication launcher" (PID 43) exited with exit code 1
recipes-db_recipes-1     | 2023-12-09 16:57:32.710 CET [38] LOG:  shutting down
recipes-db_recipes-1     | 2023-12-09 16:57:32.714 CET [38] LOG:  checkpoint starting: shutdown immediate
recipes-db_recipes-1     | 2023-12-09 16:57:32.770 CET [38] LOG:  checkpoint complete: wrote 920 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.017 s, sync=0.024 s, total=0.060 s; sync files=301, longest=0.007 s, average=0.001 s; distance=4235 kB, es
timate=4235 kB
recipes-db_recipes-1     | 2023-12-09 16:57:32.775 CET [37] LOG:  database system is shut down
recipes-db_recipes-1     |  done
recipes-db_recipes-1     | server stopped
recipes-db_recipes-1     |
recipes-db_recipes-1     | PostgreSQL init process complete; ready for start up.
recipes-db_recipes-1     |
recipes-db_recipes-1     | 2023-12-09 16:57:32.852 CET [1] LOG:  starting PostgreSQL 15.5 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014, 64-bit
recipes-db_recipes-1     | 2023-12-09 16:57:32.852 CET [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
recipes-db_recipes-1     | 2023-12-09 16:57:32.852 CET [1] LOG:  listening on IPv6 address "::", port 5432
recipes-db_recipes-1     | 2023-12-09 16:57:32.940 CET [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
recipes-db_recipes-1     | 2023-12-09 16:57:32.959 CET [53] LOG:  database system was shut down at 2023-12-09 16:57:32 CET
recipes-db_recipes-1     | 2023-12-09 16:57:32.972 CET [1] LOG:  database system is ready to accept connections
recipes-web_recipes-1    | Database is ready
recipes-web_recipes-1    | Migrating database
recipes-web_recipes-1    | Operations to perform:
recipes-web_recipes-1    |   Apply all migrations: account, admin, auth, authtoken, contenttypes, cookbook, oauth2_provider, sessions, sites, socialaccount
recipes-web_recipes-1    | Running migrations:
recipes-web_recipes-1    |   Applying contenttypes.0001_initial... OK
recipes-web_recipes-1    |   Applying auth.0001_initial... OK
recipes-web_recipes-1    |   Applying account.0001_initial... OK
recipes-web_recipes-1    |   Applying account.0002_email_max_length... OK
recipes-web_recipes-1    |   Applying admin.0001_initial... OK
recipes-web_recipes-1    |   Applying admin.0002_logentry_remove_auto_add... OK
recipes-web_recipes-1    |   Applying admin.0003_logentry_add_action_flag_choices... OK
recipes-web_recipes-1    |   Applying contenttypes.0002_remove_content_type_name... OK
recipes-web_recipes-1    |   Applying auth.0002_alter_permission_name_max_length... OK
recipes-web_recipes-1    |   Applying auth.0003_alter_user_email_max_length... OK
recipes-web_recipes-1    |   Applying auth.0004_alter_user_username_opts... OK
recipes-web_recipes-1    |   Applying auth.0005_alter_user_last_login_null... OK
recipes-web_recipes-1    |   Applying auth.0006_require_contenttypes_0002... OK
recipes-web_recipes-1    |   Applying auth.0007_alter_validators_add_error_messages... OK
recipes-web_recipes-1    |   Applying auth.0008_alter_user_username_max_length... OK
recipes-web_recipes-1    |   Applying auth.0009_alter_user_last_name_max_length... OK
recipes-web_recipes-1    |   Applying auth.0010_alter_group_name_max_length... OK
recipes-web_recipes-1    |   Applying auth.0011_update_proxy_permissions... OK
recipes-web_recipes-1    |   Applying auth.0012_alter_user_first_name_max_length... OK
recipes-web_recipes-1    |   Applying authtoken.0001_initial... OK
recipes-web_recipes-1    |   Applying authtoken.0002_auto_20160226_1747... OK
recipes-web_recipes-1    |   Applying authtoken.0003_tokenproxy... OK
recipes-web_recipes-1    |   Applying cookbook.0001_initial... OK
recipes-web_recipes-1    |   Applying cookbook.0002_auto_20191119_2035... OK
recipes-web_recipes-1    |   Applying cookbook.0003_enable_pgtrm... OK
recipes-web_recipes-1    |   Applying cookbook.0004_storage_created_by... OK
recipes-web_recipes-1    |   Applying cookbook.0005_recipebook_recipebookentry... OK
recipes-web_recipes-1    |   Applying cookbook.0006_recipe_image... OK
recipes-web_recipes-1    |   Applying cookbook.0007_auto_20191226_0852... OK
recipes-web_recipes-1    |   Applying cookbook.0008_mealplan... OK
recipes-web_recipes-1    |   Applying cookbook.0009_auto_20200130_1056... OK
recipes-web_recipes-1    |   Applying cookbook.0010_auto_20200130_1059... OK
recipes-web_recipes-1    |   Applying cookbook.0011_remove_recipeingredients_unit... OK
recipes-web_recipes-1    |   Applying cookbook.0012_auto_20200130_1116... OK
recipes-web_recipes-1    |   Applying cookbook.0013_userpreference... OK
recipes-web_recipes-1    |   Applying cookbook.0014_auto_20200213_2332... OK
recipes-web_recipes-1    |   Applying cookbook.0015_auto_20200213_2334... OK
recipes-web_recipes-1    |   Applying cookbook.0016_auto_20200213_2335... OK
recipes-web_recipes-1    |   Applying cookbook.0017_auto_20200216_2257... OK
recipes-web_recipes-1    |   Applying cookbook.0018_auto_20200216_2303... OK
recipes-web_recipes-1    |   Applying cookbook.0019_ingredient... OK
[...]
recipes-web_recipes-1    |   Applying oauth2_provider.0005_auto_20211222_2352... OK
recipes-web_recipes-1    |   Applying oauth2_provider.0006_alter_application_client_secret... OK
recipes-web_recipes-1    |   Applying oauth2_provider.0007_application_post_logout_redirect_uris... OK
recipes-web_recipes-1    |   Applying sessions.0001_initial... OK
recipes-web_recipes-1    |   Applying sites.0001_initial... OK
recipes-web_recipes-1    |   Applying sites.0002_alter_domain_unique... OK
recipes-web_recipes-1    |   Applying socialaccount.0001_initial... OK
recipes-web_recipes-1    |   Applying socialaccount.0002_token_max_lengths... OK
recipes-web_recipes-1    |   Applying socialaccount.0003_extra_data_default_dict... OK
recipes-web_recipes-1    | Generating static files
recipes-web_recipes-1    | js-reverse file written to /opt/recipes/cookbook/static/django_js_reverse
recipes-nginx_recipes-1  | 10.0.0.103 - - [09/Dec/2023:16:58:07 +0100] "GET /service-worker.js HTTP/1.0" 502 157 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0" "-"
recipes-web_recipes-1    |
recipes-web_recipes-1    | 1 static file copied to '/opt/recipes/staticfiles', 640 unmodified, 1379 post-processed.
recipes-web_recipes-1    | Done
recipes-web_recipes-1    | [2023-12-09 16:58:07 +0100] [1] [INFO] Starting gunicorn 20.1.0
recipes-web_recipes-1    | [2023-12-09 16:58:07 +0100] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
recipes-web_recipes-1    | [2023-12-09 16:58:07 +0100] [1] [INFO] Using worker: gthread
recipes-web_recipes-1    | [2023-12-09 16:58:07 +0100] [14] [INFO] Booting worker with pid: 14
recipes-web_recipes-1    | [2023-12-09 16:58:07 +0100] [15] [INFO] Booting worker with pid: 15
recipes-web_recipes-1    | [2023-12-09 16:58:07 +0100] [16] [INFO] Booting worker with pid: 16
smilerz commented 9 months ago

Duplicate. It's a false positive.

meepmeep commented 9 months ago

So it's a bug.

Database shouldn't say "info, you are not using a postgres install".

smilerz commented 9 months ago

Correct.