[BUG] /config/www/.env does not consume env_file directive correctly
M-Pepper opened this issue · 8 comments
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
I'm using vault to generate custom .env files for my services that hold sensitive secrets and for quick rotation.
The bookstack /config/www/.env inside the container does not consume the env_file contents.
Example compose configuration:
bookstack:
image: lscr.io/linuxserver/bookstack
container_name: bookstack
env_file:
- /opt/vault/env/.env.bookstack
environment:
- PUID=1000
- PGID=1000
- APP_URL=https://bookstack.prod.example.org
- APP_KEY=cvpwQhNDJhbCcQJc2J74m0LDJtuM3Y8aso7eCLtTbZw=
- APP_DEFAULT_DARK_MODE=true
volumes:
- /opt/appdata/bookstack/app_data:/config
labels:
- swag=enable
restart: unless-stopped
depends_on:
- bookstack_db
Example of /opt/vault/env/.env.bookstack:
# Generated by docker-secrets.sh at Sun Feb 9 08:08:29 PM UTC 2025
# bookstack credentials
DB_PASS=jYfCMqe9cz5yi4iM6DFj6zIq
DB_HOST=bookstack_db
DB_USER=bookstack
DB_PORT=3306
DB_DATABASE=bookstackapp
How the /config/www/.env file is created on container creation:
# This file, when named as ".env" in the root of your BookStack install
# folder, is used for the core configuration of the application.
# By default this file contains the most common required options but
# a full list of options can be found in the '.env.example.complete' file.
# NOTE: If any of your values contain a space or a hash you will need to
# wrap the entire value in quotes. (eg. MAIL_FROM_NAME="BookStack Mailer")
# Application key
# Used for encryption where needed.
# Run `php artisan key:generate` to generate a valid key.
APP_KEY=SomeRandomString
# Application URL
# This must be the root URL that you want to host BookStack on.
# All URLs in BookStack will be generated using this value
# to ensure URLs generated are consistent and secure.
# If you change this in the future you may need to run a command
# to update stored URLs in the database. Command example:
# php artisan bookstack:update-url https://old.example.com https://new.example.com
APP_URL=https://example.com
# Database details
DB_HOST=localhost
DB_DATABASE=database_database
DB_USERNAME=database_username
DB_PASSWORD=database_user_password
# Mail system to use
# Can be 'smtp' or 'sendmail'
MAIL_DRIVER=smtp
# Mail sender details
MAIL_FROM_NAME="BookStack"
MAIL_FROM=bookstack@example.com
# SMTP mail options
# These settings can be checked using the "Send a Test Email"
# feature found in the "Settings > Maintenance" area of the system.
# For more detailed documentation on mail options, refer to:
# https://www.bookstackapp.com/docs/admin/email-webhooks/#email-configuration
MAIL_HOST=localhost
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Expected Behavior
Proper consumption of env_file declarations.
Steps To Reproduce
See above.
Environment
- OS: Ubuntu 22.04
- How docker service was installed: ComposeCPU architecture
x86-64
Docker creation
See above.Container logs
[migrations] started
[migrations] 01-nginx-site-confs-default: skipped
[migrations] 02-default-location: skipped
[migrations] done
───────────────────────────────────────
██╗ ███████╗██╗ ██████╗
██║ ██╔════╝██║██╔═══██╗
██║ ███████╗██║██║ ██║
██║ ╚════██║██║██║ ██║
███████╗███████║██║╚██████╔╝
╚══════╝╚══════╝╚═╝ ╚═════╝
Brought to you by linuxserver.io
───────────────────────────────────────
To support LSIO projects visit:
https://www.linuxserver.io/donate/
───────────────────────────────────────
GID/UID
───────────────────────────────────────
User UID: 1000
User GID: 1000
───────────────────────────────────────
Linuxserver.io version: v24.12.1-ls191
Build-date: 2025-02-03T18:30:09+00:00
───────────────────────────────────────
Setting resolver to 127.0.0.11
Setting worker_processes to 8
generating self-signed keys in /config/keys, you can replace these with your own keys if required
.....+.+...+...........+....+..+++++++++++++++++++++++++++++++++++++++*...+.......+...+..+.........+...+.+.........+......+.....+..........+.....+++++++++++++++++++++++++++++++++++++++*...+..+......+.........+.+.....+................+...+...+.........+...........+...+................+.....+....+..+...+....+...............+..+....+...........+................++++++
.+.....+.............+...+.........+..+......+............+.+.....+.........+++++++++++++++++++++++++++++++++++++++*......+...............+..+....+.....+...+.+......+.....+......+....+......+..+...+.......+++++++++++++++++++++++++++++++++++++++*.....+.........+.....+..........+......+...+...+.....+....+......+...+..+..........+.........+...+......+..............+...+...+.+...+............+...........+.......+...+..+......+.+......+..............+......+.........+....+.........+...+..+.............+..............+.+...+...........+.........+......+.............+..+.+.....+....+...+.....+...+...+.......+..+.+......+......+...+............+..+.+..+...+......+...+..........+.................+.............+.....+...+...+.+.........+.....+......................+...............+.....+.........+.+...+..+...............+............+......+....+...........+....+..+.+...+......+......+..+.+......+...+...+.........+.....+....+..+...+.........+.+......+.....+......+...+.+........+.......+...+...........+.+......+.....+....+..............+....+...........+....+..+....+..+...............+.......+.....+.+......+...+.................+.........+....+..+...................+.....+......+.............+........+.......+.....++++++
-----
Waiting for DB to be available
Illuminate\Database\QueryException
SQLSTATE[HY000] [1045] Access denied for user 'database_username'@'bookstack.docker_default' (using password: YES) (Connection: mysql, SQL: select table_name as `name`, (data_length + index_length) as `size`, table_comment as `comment`, engine as `engine`, table_collation as `collation` from information_schema.tables where table_schema = 'bookstackapp' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)
at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:829
825▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
826▕ );
827▕ }
828▕
➜ 829▕ throw new QueryException(
830▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
831▕ );
832▕ }
833▕ }
+36 vendor frames
37 /app/www/artisan:35
Illuminate\Foundation\Console\Kernel::handle()
[custom-init] No custom files found, skipping...
[ls.io-init] done.Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.
Why would you assume that a .env file inside the container would populate with the contents of a .env file passed to docker compose?
The reason your container isn't starting up correctly is that you're using the wrong environment variables for the database username and password.
I am getting the same issue. I was using DB_USER and DB_PASS, changed to DB_USERNAME and DB_PASSWORD as @M-Pepper was using. My environment has been running in Azure against an App Service for 2yrs and stopped working in the last 24-48hrs.
Waiting for DB to be available
Illuminate\Database\QueryException
SQLSTATE[HY000] [1045] Access denied for user 'database_username'@'52.245.250.134' (using password: YES) (Connection: mysql, SQL: select table_name as name, (data_length + index_length) as size, table_comment as comment, engine as engine, table_collation as collation from information_schema.tables where table_schema = 'bookstackapp' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)
at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:829
825▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
826▕ );
827▕ }
828▕
➜ 829▕ throw new QueryException(
830▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
831▕ );
832▕ }
833▕ }
+36 vendor frames
37 /app/www/artisan:35
Illuminate\Foundation\Console\Kernel::handle()
FYI: rolled container back to earlier version ... all working again.
Same issue?
2025-02-25 14:06:17 2022_04_17_101741_add_editor_change_field_and_permission ......... 32ms DONE
2025-02-25 14:06:17 2022_04_25_140741_update_polymorphic_types ....................... 19ms DONE
2025-02-25 14:06:17 2022_07_16_170051_drop_joint_permission_type .................... 144ms DONE
2025-02-25 14:06:17 2022_08_17_092941_create_references_table ....................... 115ms DONE
2025-02-25 14:06:17 2022_09_02_082910_fix_shelf_cover_image_types ..................... 1ms DONE
2025-02-25 14:06:17 2022_10_07_091406_flatten_entity_permissions_table ............... 91ms DONE
2025-02-25 14:06:17 2022_10_08_104202_drop_entity_restricted_field ................... 87ms DONE
2025-02-25 14:06:17 2023_01_24_104625_refactor_joint_permissions_storage .............. 4ms FAIL
2025-02-25 14:06:17
2025-02-25 14:06:17 Illuminate\Database\QueryException
2025-02-25 14:06:17
2025-02-25 14:06:17 SQLSTATE[HY000]: General error: 1030 Got error 194 "Tablespace is missing for a table" from storage engine InnoDB (Connection: mysql, SQL: truncate table `joint_permissions`)
2025-02-25 14:06:17
2025-02-25 14:06:17 at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:829
2025-02-25 14:06:17 825▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
2025-02-25 14:06:17 826▕ );
2025-02-25 14:06:17 827▕ }
2025-02-25 14:06:17 828▕
2025-02-25 14:06:17 ➜ 829▕ throw new QueryException(
2025-02-25 14:06:17 830▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
2025-02-25 14:06:17 831▕ );
2025-02-25 14:06:17 832▕ }
2025-02-25 14:06:17 833▕ }
2025-02-25 14:06:17
2025-02-25 14:06:17 +6 vendor frames
2025-02-25 14:06:17
2025-02-25 14:06:17 7 /app/www/database/migrations/2023_01_24_104625_refactor_joint_permissions_storage.php:18
2025-02-25 14:06:17 Illuminate\Database\Query\Builder::truncate()
2025-02-25 14:06:17 +24 vendor frames
2025-02-25 14:06:17
2025-02-25 14:06:17 32 /app/www/artisan:35
2025-02-25 14:06:17 Illuminate\Foundation\Console\Kernel::handle()
@flier268 no, quite a different issue. If running on Windows via WSL you may be running into the issue as described in MariaDB/mariadb-docker#331.
This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.
This issue is locked due to inactivity