# environment

The environment file can be used to store global configuration parameters for your docker-compose file. The file is stored in `/etc/environment`. 

The following configuration is largely based on [docker media server how to].
```bash
vim /etc/environment
```
After a standard ubuntu 18.04 installation the environment file probably looks like this
```bash
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
```
### User and Group
In my basic setup I create a user `cloud` and a group `cloud` that I run docker-compose with, in my environment file I specify the ids of the user and group as parameters.
```bash
PUID=1002
PGID=1002
```
You can get the values for your user via the following command
```bash
sudo id cloud
```
this shoudl output some thing like this
```bash
uid=1002(cloud) gid=1002(cloud) groups=1002(cloud)
```
### Time zone
You can add a valiable for your timezone [time zones]
```bash
TZ="Europe/Zurich"
```
### Basic auth
You can specify a basic auth user that you can use to secure pages, you can encode the password as follows
```bash
echo $(htpasswd -nb admin supersecret) | sed -e s/\\$/\\$\\$/g
```
You might need to install some extra dependencies for the apache tools
```bash
apt install apache2-utils -y
```
That would result in some thing as `admin:$$apr1$$o6BgYlgS$$U3GfcrYe6/7Ir2bVvVit61` that you could than add as follows
```bash
HTTP_USERNAME=admin
HTTP_PASSWORD="$$apr1$$o6Bgbodo@naumann.devYlgS$$U3GfcrYe6/7Ir2bVvVit61"
```
### Clear text password
Some configurations need clear text passwords
```bash
U01_CLEAR=bodo
U02_CLEAR=tv
GRP_CLEAR=cloud
P01_CLEAR=supersecret
P02_CLEAR=supersecret
```
### Domain name
You can configure your host name as domain name and reference it in all services, this makes it easy to reuse a docker file on different hosts.
```bash
DOMAINNAME="example.com"
```
### DNS Server
The default DNS Server
```bash
DNS=192.168.1.254
```
### email address
```bash
EMAIL=mail@example.com
```
### Sample
This is a sample based on the parameters above
```bash
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
PUID=1002
PGID=1002
TZ="Europe/Zurich"
HTTP_USERNAME=admin
HTTP_PASSWORD="$$apr1$$o6Bgbodo@naumann.devYlgS$$U3GfcrYe6/7Ir2bVvVit61"
U01_CLEAR=bodo
U02_CLEAR=tv
GRP_CLEAR=cloud
P01_CLEAR=supersecret
P02_CLEAR=supersecret
DOMAINNAME="example.com"
DNS=1.1.1.1
EMAIL=mail@example.com
```

[docker media server how to]: https://www.smarthomebeginner.com/docker-home-media-server-2018-basic/#Basic_Docker_and_Docker_Compose_Primer
[time zones]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones