mirror of
https://github.com/hoellen/dockerfiles.git
synced 2025-04-20 04:19:18 +00:00
Added autoconfiguration to nextcloud image
This commit is contained in:
parent
e3aa977bd1
commit
857fe09da8
@ -93,6 +93,7 @@ COPY php-fpm.conf /etc/php7/php-fpm.conf
|
|||||||
COPY opcache.ini /etc/php7/conf.d/00_opcache.ini
|
COPY opcache.ini /etc/php7/conf.d/00_opcache.ini
|
||||||
COPY apcu.ini /etc/php7/conf.d/apcu.ini
|
COPY apcu.ini /etc/php7/conf.d/apcu.ini
|
||||||
COPY run.sh /usr/local/bin/run.sh
|
COPY run.sh /usr/local/bin/run.sh
|
||||||
|
COPY setup.sh /usr/local/bin/setup.sh
|
||||||
COPY occ /usr/local/bin/occ
|
COPY occ /usr/local/bin/occ
|
||||||
COPY s6.d /etc/s6.d
|
COPY s6.d /etc/s6.d
|
||||||
|
|
||||||
|
@ -1,17 +1,30 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ ! -f /config/config.php ]; then
|
|
||||||
echo -e "<?php\n\$CONFIG = array (\n 'datadirectory' => '/data',\n);" > /config/config.php
|
|
||||||
fi
|
|
||||||
|
|
||||||
sed -i -e "s/<UPLOAD_MAX_SIZE>/$UPLOAD_MAX_SIZE/g" /etc/nginx/nginx.conf /etc/php7/php-fpm.conf \
|
sed -i -e "s/<UPLOAD_MAX_SIZE>/$UPLOAD_MAX_SIZE/g" /etc/nginx/nginx.conf /etc/php7/php-fpm.conf \
|
||||||
-e "s/<APC_SHM_SIZE>/$APC_SHM_SIZE/g" /etc/php7/conf.d/apcu.ini \
|
-e "s/<APC_SHM_SIZE>/$APC_SHM_SIZE/g" /etc/php7/conf.d/apcu.ini \
|
||||||
-e "s/<OPCACHE_MEM_SIZE>/$OPCACHE_MEM_SIZE/g" /etc/php7/conf.d/00_opcache.ini \
|
-e "s/<OPCACHE_MEM_SIZE>/$OPCACHE_MEM_SIZE/g" /etc/php7/conf.d/00_opcache.ini \
|
||||||
-e "s/<CRON_PERIOD>/$CRON_PERIOD/g" /etc/s6.d/cron/run
|
-e "s/<CRON_PERIOD>/$CRON_PERIOD/g" /etc/s6.d/cron/run
|
||||||
|
|
||||||
|
# Put the configuration and apps into volumes
|
||||||
|
ln -sf /config/config.php /nextcloud/config/config.php &>/dev/null
|
||||||
|
ln -sf /apps2 /nextcloud &>/dev/null
|
||||||
|
|
||||||
chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /etc/s6.d
|
chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /etc/s6.d
|
||||||
|
|
||||||
ln -s /config/config.php /nextcloud/config/config.php &>/dev/null
|
if [ ! -f /config/config.php ]; then
|
||||||
ln -s /apps2 /nextcloud &>/dev/null
|
# New installation, run the setup
|
||||||
|
/usr/local/bin/setup.sh
|
||||||
|
else
|
||||||
|
occ upgrade
|
||||||
|
if [ \( $? -ne 0 \) -a \( $? -ne 3 \) ]; then
|
||||||
|
echo "Trying ownCloud upgrade again to work around ownCloud upgrade bug..."
|
||||||
|
occ upgrade
|
||||||
|
if [ \( $? -ne 0 \) -a \( $? -ne 3 \) ]; then exit 1; fi
|
||||||
|
occ maintenance:mode --off
|
||||||
|
echo "...which seemed to work."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /etc/s6.d
|
||||||
|
|
||||||
exec su-exec $UID:$GID /bin/s6-svscan /etc/s6.d
|
exec su-exec $UID:$GID /bin/s6-svscan /etc/s6.d
|
||||||
|
95
nextcloud/10.0/setup.sh
Executable file
95
nextcloud/10.0/setup.sh
Executable file
@ -0,0 +1,95 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Nextcloud
|
||||||
|
##########################
|
||||||
|
|
||||||
|
#source setup/functions.sh # load our functions
|
||||||
|
#source /etc/mailinabox.conf # load global vars
|
||||||
|
CONFIGFILE=/config/config.php
|
||||||
|
|
||||||
|
|
||||||
|
# Create an initial configuration file.
|
||||||
|
instanceid=oc$(echo $PRIMARY_HOSTNAME | sha1sum | fold -w 10 | head -n 1)
|
||||||
|
cat > $CONFIGFILE <<EOF;
|
||||||
|
<?php
|
||||||
|
\$CONFIG = array (
|
||||||
|
'datadirectory' => '/data',
|
||||||
|
|
||||||
|
'instanceid' => '$instanceid',
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Create an auto-configuration file to fill in database settings
|
||||||
|
# when the install script is run. Make an administrator account
|
||||||
|
# here or else the install can't finish.
|
||||||
|
adminpassword=$(dd if=/dev/urandom bs=1 count=40 2>/dev/null | sha1sum | fold -w 30 | head -n 1)
|
||||||
|
cat > /nextcloud/config/autoconfig.php <<EOF;
|
||||||
|
<?php
|
||||||
|
\$AUTOCONFIG = array (
|
||||||
|
# storage/database
|
||||||
|
'directory' => '/data',
|
||||||
|
'dbtype' => '${DB_TYPE:-sqlite3}',
|
||||||
|
'dbname' => '${DB_NAME:-nextcloud}',
|
||||||
|
'dbuser' => '${DB_USER:-nextcloud}',
|
||||||
|
'dbpass' => '${DB_PASSWORD:-password}',
|
||||||
|
'dbhost' => '${DB_HOST:-nextcloud-db}',
|
||||||
|
'dbtableprefix' => 'oc_',
|
||||||
|
EOF
|
||||||
|
if [[ ! -z "$ADMIN_USER" ]]; then
|
||||||
|
cat >> /nextcloud/config/autoconfig.php <<EOF;
|
||||||
|
# create an administrator account with a random password so that
|
||||||
|
# the user does not have to enter anything on first load of ownCloud
|
||||||
|
'adminlogin' => '${ADMIN_USER}',
|
||||||
|
'adminpass' => '${ADMIN_PASSWORD}',
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
cat >> /nextcloud/config/autoconfig.php <<EOF;
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Starting automatic configuration..."
|
||||||
|
# Execute ownCloud's setup step, which creates the ownCloud database.
|
||||||
|
# It also wipes it if it exists. And it updates config.php with database
|
||||||
|
# settings and deletes the autoconfig.php file.
|
||||||
|
(cd /nextcloud; php7 index.php)
|
||||||
|
echo "Automatic configuration finished."
|
||||||
|
|
||||||
|
# Update config.php.
|
||||||
|
# * trusted_domains is reset to localhost by autoconfig starting with ownCloud 8.1.1,
|
||||||
|
# so set it here. It also can change if the box's PRIMARY_HOSTNAME changes, so
|
||||||
|
# this will make sure it has the right value.
|
||||||
|
# * Some settings weren't included in previous versions of Mail-in-a-Box.
|
||||||
|
# * We need to set the timezone to the system timezone to allow fail2ban to ban
|
||||||
|
# users within the proper timeframe
|
||||||
|
# * We need to set the logdateformat to something that will work correctly with fail2ban
|
||||||
|
# Use PHP to read the settings file, modify it, and write out the new settings array.
|
||||||
|
echo ${TZ:-UTC} >/etc/timezone
|
||||||
|
|
||||||
|
TIMEZONE=$(cat /etc/timezone)
|
||||||
|
CONFIG_TEMP=$(/bin/mktemp)
|
||||||
|
php7 <<EOF > $CONFIG_TEMP && mv $CONFIG_TEMP $CONFIGFILE
|
||||||
|
<?php
|
||||||
|
include("/config/config.php");
|
||||||
|
|
||||||
|
\$CONFIG['trusted_domains'] = array('$VIRTUAL_HOST');
|
||||||
|
|
||||||
|
//\$CONFIG['memcache.local'] = '\\OC\\Memcache\\Memcached';
|
||||||
|
//\$CONFIG['overwrite.cli.url'] = '/cloud';
|
||||||
|
\$CONFIG['mail_from_address'] = 'administrator'; # just the local part, matches our master administrator address
|
||||||
|
|
||||||
|
\$CONFIG['logtimezone'] = '$TIMEZONE';
|
||||||
|
\$CONFIG['logdateformat'] = 'Y-m-d H:i:s';
|
||||||
|
|
||||||
|
echo "<?php\n\\\$CONFIG = ";
|
||||||
|
var_export(\$CONFIG);
|
||||||
|
echo ";";
|
||||||
|
?>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chown -R $UID:$GID /config
|
||||||
|
# Enable/disable apps. Note that this must be done after the ownCloud setup.
|
||||||
|
# The firstrunwizard gave Josh all sorts of problems, so disabling that.
|
||||||
|
# user_external is what allows ownCloud to use IMAP for login. The contacts
|
||||||
|
# and calendar apps are the extensions we really care about here.
|
||||||
|
occ app:disable firstrunwizard
|
@ -41,6 +41,14 @@ Other tags than `daily` are built weekly. For security reasons, you should occas
|
|||||||
- **APC_SHM_SIZE** : apc memory size *(default : 128M)*
|
- **APC_SHM_SIZE** : apc memory size *(default : 128M)*
|
||||||
- **OPCACHE_MEM_SIZE** : opcache memory size in megabytes *(default : 128)*
|
- **OPCACHE_MEM_SIZE** : opcache memory size in megabytes *(default : 128)*
|
||||||
- **CRON_PERIOD** : time interval between two cron tasks *(default : 15m)*
|
- **CRON_PERIOD** : time interval between two cron tasks *(default : 15m)*
|
||||||
|
- **TZ** : The log timezone *(default : Europe/Berlin)*
|
||||||
|
- **ADMIN_USER** : Username of the administrator user *(default : admin)*
|
||||||
|
- **ADMIN_PASSWORD** : Password of the administrator user *(default : admin)*
|
||||||
|
- **DB_TYPE** : Database type (sqlite3, mysql or pgsql) *(default : sqlite3)*
|
||||||
|
- **DB_NAME** : Name of database *(default : none)*
|
||||||
|
- **DB_USER** : Username for database *(default : none)*
|
||||||
|
- **DB_PASSWORD** : Password for database user *(default : none)*
|
||||||
|
- **DB_HOST** : Database host *(default : none)*
|
||||||
|
|
||||||
#### Port
|
#### Port
|
||||||
- **8888**
|
- **8888**
|
||||||
@ -59,7 +67,7 @@ Pull the image and create a container. `/mnt` can be anywhere on your host, this
|
|||||||
````
|
````
|
||||||
docker pull wonderfall/nextcloud && docker pull mariadb:10
|
docker pull wonderfall/nextcloud && docker pull mariadb:10
|
||||||
docker run -d --name db_nextcloud -v /mnt/nextcloud/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=supersecretpassword -e MYSQL_DATABASE=nextcloud -e MYSQL_USER=nextcloud -e MYSQL_PASSWORD=supersecretpassword mariadb:10
|
docker run -d --name db_nextcloud -v /mnt/nextcloud/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=supersecretpassword -e MYSQL_DATABASE=nextcloud -e MYSQL_USER=nextcloud -e MYSQL_PASSWORD=supersecretpassword mariadb:10
|
||||||
docker run -d --name nextcloud --link db_nextcloud:db_nextcloud -e UID=1000 -e GID=1000 -v /mnt/nextcloud/data:/data -v /mnt/nextcloud/config:/config -v /mnt/nextcloud/apps:/apps2 wonderfall/nextcloud
|
docker run -d --name nextcloud --link db_nextcloud:db_nextcloud -e UID=1000 -e GID=1000 -e DB_NAME=nextcloud -e DB_USER=nextcloud -e DB_PASSWORD=supersecretpassword -e DB_HOST=db_nextcloud -v /mnt/nextcloud/data:/data -v /mnt/nextcloud/config:/config -v /mnt/nextcloud/apps:/apps2 wonderfall/nextcloud
|
||||||
```
|
```
|
||||||
|
|
||||||
**Below you can find a docker-compose file, which is very useful!**
|
**Below you can find a docker-compose file, which is very useful!**
|
||||||
@ -113,34 +121,53 @@ If Nextcloud performed a full upgrade, your apps could be disabled. Enable them
|
|||||||
|
|
||||||
#### Docker-compose
|
#### Docker-compose
|
||||||
|
|
||||||
I advise you to use [docker-compose](https://docs.docker.com/compose/), which is a great tool for managing containers. You can create a `docker-compose.yml` with the following content (which must be adapted to your needs) and then run everything with `docker-compose up -d`, that's it!
|
I advise you to use [docker-compose](https://docs.docker.com/compose/), which is a great tool for managing containers. You can create a `docker-compose.yml` with the following content (which must be adapted to your needs) and then run `docker-compose up -d nextcloud-db`, wait some 15 seconds for the database to come up, then run everything with `docker-compose up -d`, that's it! On subsequent runs, a single `docker-compose up -d` is sufficient!
|
||||||
|
|
||||||
```
|
```
|
||||||
nextcloud:
|
version: '2'
|
||||||
image: wonderfall/nextcloud:10.0
|
|
||||||
links:
|
|
||||||
- db_nextcloud:db_nextcloud
|
|
||||||
environment:
|
|
||||||
- UID=1000
|
|
||||||
- GID=1000
|
|
||||||
- UPLOAD_MAX_SIZE=10G
|
|
||||||
- APC_SHM_SIZE=128M
|
|
||||||
- OPCACHE_MEM_SIZE=128
|
|
||||||
- CRON_PERIOD=15m
|
|
||||||
volumes:
|
|
||||||
- /mnt/nextcloud/data:/data
|
|
||||||
- /mnt/nextcloud/config:/config
|
|
||||||
- /mnt/nextcloud/apps:/apps2
|
|
||||||
|
|
||||||
db_nextcloud:
|
volumes:
|
||||||
image: mariadb:10
|
nextcloud-db-data:
|
||||||
volumes:
|
nextcloud-data:
|
||||||
- /mnt/nextcloud/db:/var/lib/mysql
|
nextcloud-config:
|
||||||
environment:
|
nextcloud-apps:
|
||||||
- MYSQL_ROOT_PASSWORD=supersecretpassword
|
|
||||||
- MYSQL_DATABASE=nextcloud
|
services:
|
||||||
- MYSQL_USER=nextcloud
|
nextcloud-db:
|
||||||
- MYSQL_PASSWORD=supersecretpassword
|
image: mariadb
|
||||||
|
volumes:
|
||||||
|
- nextcloud-db-data:/var/lib/mysql
|
||||||
|
environment:
|
||||||
|
- MYSQL_ROOT_PASSWORD=1234
|
||||||
|
- MYSQL_DATABASE=nextcloud
|
||||||
|
- MYSQL_USER=nextcloud
|
||||||
|
- MYSQL_PASSWORD=foo5678
|
||||||
|
|
||||||
|
nextcloud:
|
||||||
|
image: wonderfall/nextcloud
|
||||||
|
environment:
|
||||||
|
- UID=1000
|
||||||
|
- GID=1000
|
||||||
|
- UPLOAD_MAX_SIZE=10G
|
||||||
|
- APC_SHM_SIZE=128M
|
||||||
|
- OPCACHE_MEM_SIZE=128
|
||||||
|
- CRON_PERIOD=15m
|
||||||
|
- TZ=Europe/Berlin
|
||||||
|
- ADMIN_USER=admin
|
||||||
|
- ADMIN_PASSWORD=admin
|
||||||
|
- DB_TYPE=mysql
|
||||||
|
- DB_NAME=nextcloud
|
||||||
|
- DB_USER=nextcloud
|
||||||
|
- DB_PASSWORD=foo5678
|
||||||
|
- DB_HOST=nextcloud-db
|
||||||
|
depends_on:
|
||||||
|
- nextcloud-db
|
||||||
|
volumes:
|
||||||
|
- nextcloud-data:/data
|
||||||
|
- nextcloud-config:/config
|
||||||
|
- nextcloud-apps:/apps2
|
||||||
|
ports:
|
||||||
|
- 8888:8888
|
||||||
```
|
```
|
||||||
You can update everything with `docker-compose pull` followed by `docker-compose up -d`.
|
You can update everything with `docker-compose pull` followed by `docker-compose up -d`.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user