Skip to content

Commit 9f48545

Browse files
authored
Merge pull request #17 from mgust/parameterised_user
* Parameterized user, host * PHP config fixes
2 parents 1bec579 + 01236ce commit 9f48545

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

Dockerfile

+4-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ RUN tar -xzf /tmp/v${PHPSAML_VERSION}.tar.gz -C ${WEB_REPO}/functions/php-saml/
4747
# Use system environment variables into config.php
4848
RUN cp ${WEB_REPO}/config.dist.php ${WEB_REPO}/config.php && \
4949
chown www-data /var/www/html/app/admin/import-export/upload && \
50-
sed -i -e "s/\['host'\] = 'localhost'/\['host'\] = 'mysql'/" \
51-
-e "s/\['user'\] = 'phpipam'/\['user'\] = 'root'/" \
52-
-e "s/\['pass'\] = 'phpipamadmin'/\['pass'\] = getenv(\"MYSQL_ENV_MYSQL_ROOT_PASSWORD\")/" \
53-
${WEB_REPO}/config.php && \
54-
sed -i -e "s/\['port'\] = 3306;/\['port'\] = 3306;\n\n\$password_file = getenv(\"MYSQL_ENV_MYSQL_ROOT_PASSWORD\");\nif(file_exists(\$password_file))\n\$db\['pass'\] = preg_replace(\"\/\\\\s+\/\", \"\", file_get_contents(\$password_file));/" \
50+
sed -i -e "s/\['host'\] = 'localhost'/\['host'\] = getenv(\"MYSQL_ENV_MYSQL_HOST\") ?: \"mysql\"/" \
51+
-e "s/\['user'\] = 'phpipam'/\['user'\] = getenv(\"MYSQL_ENV_MYSQL_USER\") ?: \"root\"/" \
52+
-e "s/\['pass'\] = 'phpipamadmin'/\['pass'\] = getenv(\"MYSQL_ENV_MYSQL_PASSWORD\")/" \
53+
-e "s/\['port'\] = 3306;/\['port'\] = 3306;\n\n\$password_file = getenv(\"MYSQL_ENV_MYSQL_PASSWORD_FILE\");\nif(file_exists(\$password_file))\n\$db\['pass'\] = preg_replace(\"\/\\\\s+\/\", \"\", file_get_contents(\$password_file));/" \
5554
${WEB_REPO}/config.php
5655

5756
EXPOSE 80

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Here, we store data on the host system under `/my_dir/phpipam` and use a specifi
2323
### Phpipam
2424

2525
```bash
26-
$ docker run -ti -d -p 80:80 --name ipam --link phpipam-mysql:mysql pierrecdn/phpipam
26+
$ docker run -ti -d -p 80:80 -e MYSQL_ENV_MYSQL_PASSWORD=my-secret-pw--name ipam --link phpipam-mysql:mysql pierrecdn/phpipam
2727
```
2828

2929
We are linking the two containers and expose the HTTP port.
@@ -76,7 +76,9 @@ services:
7676
- mysql
7777
image: pierrecdn/phpipam
7878
environment:
79-
- MYSQL_ENV_MYSQL_ROOT_PASSWORD=my-secret-pw
79+
- MYSQL_ENV_MYSQL_USER=root
80+
- MYSQL_ENV_MYSQL_PASSWORD=my-secret-pw
81+
- MYSQL_ENV_MYSQL_HOST=mysql
8082
ports:
8183
- "80:80"
8284
volumes:
@@ -89,7 +91,7 @@ And next :
8991
$ docker-compose up -d
9092
```
9193

92-
You can also point the `MYSQL_ENV_ROOT_PASSWORD` environment variable to a file,
94+
You can also point the `MYSQL_ENV_PASSWORD_FILE` environment variable to a file,
9395
in which case the contents of this file will be used as the password.
9496
This makes it possible to use docker secrets for instance:
9597

@@ -99,7 +101,7 @@ version: '3'
99101
services:
100102
ipam:
101103
environment:
102-
- MYSQL_EVN_MYSQL_ROOT_PASSWORD=/run/secrets/phpipam_mysql_root_password
104+
- MYSQL_ENV_MYSQL_PASSWORD_FILE=/run/secrets/phpipam_mysql_root_password
103105
secrets:
104106
- phpipam_mysql_root_password
105107
```

php.ini

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ zlib.output_compression = Off
77
implicit_flush = Off
88
serialize_precision = 17
99
zend.enable_gc = On
10-
expose_php = On
10+
expose_php = Off
1111
max_execution_time = 30
1212
max_input_time = 60
1313
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
14-
display_errors = On
14+
display_errors = Off
1515
log_errors = On
1616
log_errors_max_len = 1024
1717
default_mimetype = "text/html"
@@ -24,7 +24,7 @@ allow_url_include = Off
2424
default_socket_timeout = 60
2525

2626
[Date]
27-
date.timezone = "US/Central"
27+
date.timezone = "UTC"
2828

2929
[mail function]
3030
smtp_port = 25

0 commit comments

Comments
 (0)