mattermost / mattermost/docker
.env file is unable to use environment variables declared within itself
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 533
- Forks
- 284
- PR merge metrics
- No merged PRs in 30d
Description
I recently started using Mattermost with Docker. As instructed in the Deployment Guide, I cloned the repository, copied the env.example file to a .env file, filled out the environment variables and started the server. However, it didn't start properly and after viewing the logs with docker logs, the error turned out to be
Error: failed to load configuration: failed to create store: unable to load on store creation: invalid config: Config.IsValid: model.config.is_valid.site_url.app_error,
Usage:
mattermost [flags]
mattermost [command]
After some thought, I noticed that MM_SETTINGS_SITEURL (line 38) was using https://${DOMAIN} as its value, so I hardcoded my domain into it instead of using the environment variable. After that, I received this error:
{"timestamp":"2022-04-24 15:34:38.346 Z","level":"error","msg":"Failed to ping DB","caller":"sqlstore/store.go:272","error":"parse \"postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable&connect_timeout=10\": net/url: invalid userinfo","retrying in seconds":10}
This error clearly shows that the file is interpreting the environment variables literally instead of as environment variables, so I hardcoded the credentials into MM_SQLSETTINGS_DATASOURCE and Mattermost was able to successfully connect to the database and launch. There are also two other variables which use other variables, namely CERT_PATH (line 41) and KEY_PATH (line 42), but since I don't use Gitlab SSO, I haven't tried them.
I'm using Docker 20.10.14 on Debian GNU/Linux 11 (bullseye).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report points to env.example lines 38, 41, and 42; start by reproducing the deployment with Docker and inspect the resulting docker logs. Check how those values are passed and expanded, and consider the issue done when references such as DOMAIN and POSTGRES_* no longer remain literal and the server launches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, shell
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100