Skip to content

[BUG] /config/www/.env does not consume env_file directive correctly #262

Closed
@M-Pepper

Description

@M-Pepper

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"
[email protected]

# 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: Compose

CPU 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions