Created
January 8, 2016 12:19
-
-
Save tiagotex/c0956f97b6b376f744c2 to your computer and use it in GitHub Desktop.
Use docker to generate config file replacing env variables in template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Conf { | |
public static $SERVER_NAME; | |
public static $SERVER_DB; | |
public static function init_values() { | |
self::$SERVER_NAME = "$NAME"; | |
self::$SERVER_DB = "$DB"; | |
} | |
} | |
Conf::init_values(); | |
?> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: | |
build: . | |
ports: | |
- "8000:80" | |
environment: | |
NAME: mysql | |
DB: gbdbo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:5.5-apache | |
COPY . /var/www/html/ | |
RUN docker-php-ext-install mysqli | |
RUN sed -i '/DocumentRoot/c\DocumentRoot /var/www/html/htdocs' /etc/apache2/apache2.conf | |
RUN echo 'date.timezone = UTC' >> /usr/local/etc/php/conf.d/php.ini | |
RUN a2enmod rewrite | |
RUN apt-get update; apt-get install -y gettext | |
RUN chmod -R 700 ./generate_config_php | |
ENTRYPOINT [ "./generate_config_php" ] | |
CMD ["apache2-foreground"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export SERVER_NAME=\$SERVER_NAME | |
export SERVER_DB=\$SERVER_DB | |
envsubst < Conf.class.php.template > Conf.class.php | |
exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment