From 4664dbb642b63d9553fd0075cc2dc9155e9bcf2c Mon Sep 17 00:00:00 2001 From: mihasinkec Date: Mon, 3 Aug 2020 14:17:17 +0200 Subject: [PATCH] Added Docker stuff. --- Dockerfile | 15 +++++++++++++++ docker-compose.yml | 27 +++++++++++++++++++++++++++ sna/application/config/config.php | 8 +++++++- sna/application/config/database.php | 8 ++++---- 4 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b638c1f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM php:7.2-apache + +# Use the default production configuration. +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +RUN docker-php-ext-install mysqli + +# Enable rewrite module for httpd. +RUN ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load + +ADD sna /var/www/html + +# Set 20M body size limit and enable short open tags in PHP +RUN sed -i "s//\n\tLimitRequestBody 20480000\n/" /etc/apache2/sites-enabled/000-default.conf && \ + sed -i "s/short_open_tag = Off/short_open_tag = On/" $PHP_INI_DIR/php.ini diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d879d1d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,27 @@ +version: '3' +services: + app: + build: . + restart: always + ports: + - "5000:80" + volumes: + - :/var/www/html/audio + - :/var/www/html/comments + - :/var/www/html/images + - :/var/www/html/images/words + environment: + DB_HOST: db + DB_USER: testuser + DB_PASS: testpass + DB_NAME: digital_atlas + db: + image: "mariadb:10.5-focal" + restart: always + environment: + MYSQL_ROOT_PASSWORD: roottestpass + MYSQL_DATABASE: digital_atlas + MYSQL_USER: testuser + MYSQL_PASSWORD: testpass + volumes: + - :/var/lib/mysql diff --git a/sna/application/config/config.php b/sna/application/config/config.php index c234d42..aacbba2 100644 --- a/sna/application/config/config.php +++ b/sna/application/config/config.php @@ -32,6 +32,12 @@ else $config['base_url'] = 'http://my-server-name.si/sna'; } +// Environment variable override +if($conf_var = getenv('BASE_URL')) { + $config['base_url'] = $conf_var; +} + + /* |-------------------------------------------------------------------------- | Index File @@ -387,7 +393,7 @@ $config['encryption_key'] = ''; $config['sess_driver'] = 'files'; $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; -$config['sess_save_path'] = NULL; +$config['sess_save_path'] = '/tmp'; $config['sess_match_ip'] = FALSE; $config['sess_time_to_update'] = 300; $config['sess_regenerate_destroy'] = FALSE; diff --git a/sna/application/config/database.php b/sna/application/config/database.php index b4cd9a8..3f58d9a 100644 --- a/sna/application/config/database.php +++ b/sna/application/config/database.php @@ -75,10 +75,10 @@ $query_builder = TRUE; $db['default'] = array( 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'nermin', - 'password' => '', - 'database' => 'digital_atlas', + 'hostname' => (getenv('DB_HOST')) ? getenv('DB_HOST') : 'localhost', + 'username' => (getenv('DB_USER')) ? getenv('DB_USER') : 'nermin', + 'password' => (getenv('DB_PASS')) ? getenv('DB_PASS') : '', + 'database' => (getenv('DB_NAME')) ? getenv('DB_NAME') : 'digital_atlas', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE,