Compare commits

...

5 Commits

5 changed files with 55 additions and 4 deletions

View File

@ -0,0 +1,8 @@
<?php
$CONFIG = array (
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
'host' => 'redis',
'port' => 6379,
),
);

View File

@ -87,13 +87,13 @@ RUN { \
echo 'opcache.revalidate_freq=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini; \
\
mkdir /var/www/data; \
mkdir /data; \
chown -R www-data:root /data; \
chown -R www-data:root /var/www; \
chmod -R g=u /var/www
VOLUME /var/www/html
ENV NEXTCLOUD_VERSION 13.0.2
RUN set -ex; \
@ -115,6 +115,7 @@ RUN set -ex; \
COPY *.sh /
COPY config/* /usr/src/nextcloud/config/
#HEALTHCHECK --interval=1s --timeout=3s --retries=16 \
#CMD test $(ps ax | grep php-fpm | grep -v grep | wc -l) -gt 0 && echo okay
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View File

@ -1,11 +1,43 @@
<?php
$autoconfig_enabled = false;
if (getenv('SQLITE_DATABASE')) {
$AUTOCONFIG["dbtype"] = "sqlite";
$AUTOCONFIG["dbname"] = getenv('SQLITE_DATABASE');
$autoconfig_enabled = true;
}elseif (getenv('MYSQL_ROOT_PASSWORD') && getenv('MYSQL_ROOT_USER') && getenv('MYSQL_DATABASE') && getenv('MYSQL_USER') && getenv('MYSQL_PASSWORD') && getenv('MYSQL_HOST')) {
$root_user = getenv('MYSQL_ROOT_USER');
$root_password = getenv('MYSQL_ROOT_PASSWORD');
$user = getenv('MYSQL_USER');
$password = getenv('MYSQL_PASSWORD');
$database = getenv('MYSQL_DATABASE');
$host = getenv('MYSQL_HOST');
// Erase root environment variables
putenv('MYSQL_ROOT_USER');
putenv('MYSQL_ROOT_PASSWORD');
// Create connection
$connection = new mysqli($host, $root_user, $root_password);
// Check connection
if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}
// Create database
$create_database = "CREATE DATABASE " .$database;
$create_user = "GRANT ALL PRIVILEGES ON " .$database. ".* TO '" .$user."'@'%' IDENTIFIED BY '" .$password. "';";
if ($connection->query($create_database) && $connection->query($create_user)) {
$AUTOCONFIG["dbtype"] = "mysql";
$AUTOCONFIG["dbname"] = getenv('MYSQL_DATABASE');
$AUTOCONFIG["dbuser"] = getenv('MYSQL_USER');
$AUTOCONFIG["dbpass"] = getenv('MYSQL_PASSWORD');
$AUTOCONFIG["dbhost"] = getenv('MYSQL_HOST');
$autoconfig_enabled = true;
} else {
echo "Error creating database: " . $connection->error;
}
$connection->close();
} elseif (getenv('MYSQL_DATABASE') && getenv('MYSQL_USER') && getenv('MYSQL_PASSWORD') && getenv('MYSQL_HOST')) {
$AUTOCONFIG["dbtype"] = "mysql";
$AUTOCONFIG["dbname"] = getenv('MYSQL_DATABASE');

View File

@ -0,0 +1,8 @@
<?php
$CONFIG = array (
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
'host' => 'redis',
'port' => 6379,
),
);

View File

@ -101,6 +101,8 @@ __SQLITE_DATABASE__:
- `SQLITE_DATABASE` Name of the database using sqlite
__MYSQL/MariaDB__:
- `MYSQL_ROOT_USER` Name of mysql / mariadb root user.
- `MYSQL_ROOT_PASSWORD` Root Password of the database, used to create the MYSQL_USER, MYSQL_PASSWORD, and MYSQL_DATABASE.
- `MYSQL_DATABASE` Name of the database using mysql / mariadb.
- `MYSQL_USER` Username for the database using mysql / mariadb.
- `MYSQL_PASSWORD` Password for the database user using mysql / mariadb.