linuxserver / docker-bookstack

A Docker container for the BookStack documentation wiki
GNU General Public License v3.0
725 stars 105 forks source link

[BUG] Environment variables not being passed to /config/www/.env #189

Closed XStylus closed 5 months ago

XStylus commented 10 months ago

Is there an existing issue for this?

Current Behavior

The following docker-compose environment variables are not being passed to the Bookstack .env file at /config/www/.env:

  - MAIL_DRIVER=
  - MAIL_HOST=
  - MAIL_PORT=
  - MAIL_USERNAME=
  - MAIL_PASSWORD=
  - MAIL_ENCRYPTION=
  - MAIL_FROM_NAME=
  - MAIL_FROM=
  - GOOGLE_AP_ID=
  - GOOGLE_APP_SECRET=
  - GOOGLE_AUTO_REGISTER=

Expected Behavior

When the above variables are entered into "environment:" on docker-compose, it is expected that they be passed along to /config/www/.env.

There is an undesirable workaround by way of using a separate .env file alongside the docker-compose file, or by manually editing the /config/www/.env file after installation.

Steps To Reproduce

  1. Add the affected variables to docker compose.
  2. Install Bookstack using docker compose file.
  3. View /config/www/.env file.
  4. See that the affected variables remain at their defaults and not as specified in the docker compose file.

Environment

- OS: ubuntu 22.04.3 LTS
- How docker service was installed: Distro packagemanager

CPU architecture

x86-64

Docker creation

# Docker Compose file for Bookstack

version: "2"
services:
  bookstack:
    image: linuxserver/bookstack:latest
    container_name: bookstack_app
    restart: unless-stopped
    depends_on:
      - bookstack_db
    volumes:
      - /mnt/Secondary/docker/bookstack/config:/config
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=https://wiki.example.com
      - DB_HOST=bookstack_db
      - DB_USER=bookstack
      - DB_PASS=SuperPWGoesHere
      - DB_DATABASE=bookstackapp
      - DB_PORT=3306
# Email configuration settings
      - MAIL_DRIVER=smtp
      - MAIL_HOST=smtp.mailserver.com
      - MAIL_PORT=587
      - MAIL_USERNAME=example@example.com
      - MAIL_PASSWORD=SuperPWGoesHere
      - MAIL_ENCRYPTION=tls
      - MAIL_FROM_NAME="BookStack Wiki"
      - MAIL_FROM=noreply@example.com
      - GOOGLE_AP_ID=GoogleAppIDGoesHere.apps.googleusercontent.com
      - GOOGLE_APP_SECRET=GoogleAppSecretGoesHere
      - GOOGLE_AUTO_REGISTER=true
#    ports:
#      - 8006:80

#    networks:
#      - bookstack

  bookstack_db:
    image: linuxserver/mariadb:latest
    container_name: bookstack_mariadb
    restart: unless-stopped
    volumes:
      - /mnt/Secondary/docker/bookstack/mariadb/config:/config
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Los_Angeles
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_ROOT_PASSWORD=SuperPWGoesHere
      - MYSQL_PASSWORD=SuperPWGoesHere
      - MYSQL_TCP_PORT=3306      

#    networks:
#      - bookstack
#
#networks:
#  bookstack:

volumes:
  bookstack:
    name: bookstack_data
  bookstack_db:
    name: bookstack_mariadb_data      

networks:
  default:
    name: nginx-proxy-manager
    driver: bridge
    external: true

Container logs

N/A
github-actions[bot] commented 10 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

aptalca commented 10 months ago

When the above variables are entered into "environment:" on docker-compose, it is expected that they be passed along to /config/www/.env.

That's not a valid expectation. Not sure where you read that.

The accepted env vars are listed in the readme. Apart from those, the upstream app may accept other vars, but I don't believe the app modifies the .env file to replace them with values from the environment.

XStylus commented 10 months ago

The following variables are passed along to /config/www/.env

Is there a reason that the remaining variables are not?

My understanding might be very flawed. I just find it bizarre that select variables are passed yet other crucial variables are not.

ssddanbrown commented 9 months ago

@XStylus Likely because the container has custom handling for those options (options are not all the same as the env equivalents), and this somewhat aligns the DB option behaviour with many DB containers, where such env options only really apply for first boot with data persistence.

aptalca commented 9 months ago

The options that are required to get the app up and running are handled by the container init and are listed in the readme.

dac11011 commented 9 months ago

How can you even get MAIL settings to work inside docker? I've tried setting them in docker-compse environment, and editing the /config/www/.env. Neither work.

The /config/www/.env shows my new settings.. I restart the container, and the settings are still there. But the WebGUI still shows it connecting to a different MAIL_HOST when I "Send a test email"

seehma commented 8 months ago

same issue for me, how do i set up mail sending in this bookstack-docker-image? At first i also tried to pass them via environment-option in docker-compose file, then i tried to manually add a .env file, but neither worked -> mail sending always tries to connect to localhost...

dac11011 commented 8 months ago

Can we get this fixed? Please don't put out another crappy, non-working Docker image (like all the others) with not enough features to even run it. Thanks

ssddanbrown commented 8 months ago

Just as an additional data point, just tested this and setting mail options within docker-compose.yml environment works fine for me as expected.

My Compose File

```yml --- version: "2" services: bookstack: image: lscr.io/linuxserver/bookstack container_name: bookstack_oct_23 environment: - PUID=1000 - PGID=1000 - APP_URL=http://localhost:6875 - DB_HOST=bookstack_db - DB_PORT=3306 - DB_USER=bookstack - DB_PASS=mydbpass - DB_DATABASE=bookstackapp - MAIL_HOST=172.17.0.1 - MAIL_PORT=1025 - MAIL_USERNAME=null - MAIL_PASSWORD=null - MAIL_ENCRPYTION=null - MAIL_VERIFY_SSL=false - MAIL_FROM=test-lsio@example.com - MAIL_FROM_NAME="LSIO MAIL TESTING" volumes: - ./bookstack_app_data:/config ports: - 6875:80 restart: unless-stopped depends_on: - bookstack_db bookstack_db: image: lscr.io/linuxserver/mariadb container_name: bookstack_oct_23_db environment: - PUID=1000 - PGID=1000 - MYSQL_ROOT_PASSWORD=mydbpass - TZ=Europe/London - MYSQL_DATABASE=bookstackapp - MYSQL_USER=bookstack - MYSQL_PASSWORD=mydbpass volumes: - ./bookstack_db_data:/config restart: unless-stopped ```

dac11011 commented 8 months ago

Confirmed this is working. Thanks!

LinuxServer-CI commented 7 months ago

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.

github-actions[bot] commented 4 months ago

This issue is locked due to inactivity