DB_PASSWORD_FILE not applied at runtime → MySQL auth fails (using password: NO) #3957
-
Lychee versionv7.0.1 Did you check the latest Lychee version?Yes, I did Which PHP version are you using?PHP 8.4 Detailed description of the problemWhen running Lychee via Docker Compose with database credentials provided through Docker secrets ( Manual inspection shows that Environment Docker Compose (relevant excerpts) lychee:
environment:
- DB_CONNECTION=mysql
- DB_HOST=lychee_db
- DB_PORT=3306
- DB_DATABASE=lychee
- DB_USERNAME=lychee
- DB_PASSWORD_FILE=/run/secrets/mysql_passwordsecrets:
mysql_password:
file: ./secrets/mysql_password.txtObserved behavior Lychee repeatedly fails during startup while running database migrations. Exact log output (excerpt): The container then restarts and repeats the same failure. Investigation An interactive shell was started inside the Lychee container: docker compose run --rm --entrypoint sh lycheeChecking environment variables before sourcing any scripts: Then manually sourcing the validation script used by the entrypoint: . /usr/local/bin/validate-env.shChecking again: This demonstrates: Expected behavior When DB_PASSWORD_FILE is set: This is the documented and expected behavior of Actual behavior Root cause (likely) (suggest by ChatGPT)
As a result, secrets loaded from Workarounds Additional notes Impact This breaks Docker secrets–based deployments, which are a standard and recommended practice for containerized applications. Steps to reproduce the issue
services:
lychee_db:
image: mariadb:11
container_name: lychee_db
restart: unless-stopped
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
- MYSQL_DATABASE=lychee
- MYSQL_USER=lychee
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
expose:
- 3306
volumes:
- mysql:/var/lib/mysql
networks:
- lychee
secrets:
- mysql_root_password
- mysql_password
lychee:
image: ghcr.io/lycheeorg/lychee:latest
container_name: lychee
restart: unless-stopped
ports:
- "8000:8000"
volumes:
- ./lychee/uploads:/app/public/uploads
- ./lychee/storage/app:/app/storage/app
- ./lychee/logs:/app/storage/logs
- ./lychee/tmp:/app/storage/tmp
- ./lychee/conf/.env:/app/.env:ro
- ./lychee/conf/user.css:/app/public/dist/user.css
- ./lychee/conf/custom.js:/app/public/dist/custom.js
environment:
## App config
- APP_NAME=Lychee
- APP_ENV=production
- APP_URL=https://images.hthompson.dev
- APP_FORCE_HTTPS=true
## Database config
- DB_CONNECTION=mysql
- DB_HOST=lychee_db
- DB_PORT=3306
- DB_DATABASE=lychee
- DB_USERNAME=lychee
- DB_PASSWORD_FILE=/run/secrets/mysql_password
## Timezone config
- TIMEZONE=America/Los_Angeles
## Trusted proxy config
- TRUSTED_PROXIES=127.0.0.1,::1,172.18.0.0/16
# - TRUSTED_PROXIES=*
# - TRUSTED_PROXIES=127.0.0.1,::1,172.64.0.0/13,104.16.0.0/13,2606:4700::/32,
depends_on:
- lychee_db
networks:
- lychee
secrets:
- mysql_password
- mail_password
networks:
lychee:
volumes:
mysql:
secrets:
mysql_root_password:
file: ./secrets/mysql_root_password.txt
mysql_password:
file: ./secrets/mysql_password.txt
mail_password:
file: ./secrets/mail_password.txt
APP_KEY=base64:<REDACTED>
docker compose up -d
docker logs lychee
docker compose run --rm --entrypoint sh lychee
echo "DB_PASSWORD=${DB_PASSWORD:+<set>}"Expected output:
. /usr/local/bin/validate-env.sh
echo "DB_PASSWORD=${DB_PASSWORD:+<set>}"Expected output: Diagnostics [REQUIRED]N/A Browser & System [REQUIRED]System: Ubuntu 24.04 Please confirm (incomplete submissions will not be addressed)
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
I will investigate that one. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for such a quick response and fix! |
Beta Was this translation helpful? Give feedback.
Fixed: #3958