Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Add support to nextcloud image to use an S3 bucket as primary storage #224

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nextcloud/Dockerfile.11.0
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ ENV UID=991 GID=991 \
CRON_MEMORY_LIMIT=1g \
TZ=Etc/UTC \
DB_TYPE=sqlite3 \
DOMAIN=localhost
DOMAIN=localhost \
DATASTORE_USE_PATH_STYLE=false

RUN apk -U upgrade \
&& apk add -t build-dependencies \
Expand Down
3 changes: 2 additions & 1 deletion nextcloud/Dockerfile.12.0
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ ENV UID=991 GID=991 \
CRON_MEMORY_LIMIT=1g \
TZ=Etc/UTC \
DB_TYPE=sqlite3 \
DOMAIN=localhost
DOMAIN=localhost \
DATASTORE_USE_PATH_STYLE=false

RUN apk -U upgrade \
&& apk add -t build-dependencies \
Expand Down
3 changes: 2 additions & 1 deletion nextcloud/Dockerfile.daily
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ ENV UID=991 GID=991 \
CRON_MEMORY_LIMIT=1g \
TZ=Etc/UTC \
DB_TYPE=sqlite3 \
DOMAIN=localhost
DOMAIN=localhost \
DATASTORE_USE_PATH_STYLE=false

RUN apk -U upgrade \
&& apk add -t build-dependencies \
Expand Down
12 changes: 9 additions & 3 deletions nextcloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- GNU Libiconv for php iconv extension (avoiding errors with some apps).
- No root processes. Never.
- Environment variables provided (see below).
- Optional use of S3 bucket for primary storage (see below for config).

### Tags
- **latest** : latest stable version. (12.0)
Expand Down Expand Up @@ -58,7 +59,12 @@ Other tags than `daily` are built weekly. For security reasons, you should occas
- **DB_USER** : username for database *(default : none)*
- **DB_PASSWORD** : password for database user *(default : none)*
- **DB_HOST** : database host *(default : none)*

- **DATASTORE_BUCKET** : S3 bucket to use for primary storage *(default : none)*
- **DATASTORE_KEY** : S3 Key for about bucket *(default : none)*
- **DATASTORE_SECRET** : S3 secret for about bucket *(default : none)*
- **DATASTORE_HOST** : S3 host for above bucket *(default : none)*
- **DATASTORE_PORT** : S3 port for above bucket *(default : 443)*
- **DATASTORE_USE_PATH_STYLE** : Whether to use path style for S3 bucket *(default : false)*
Don't forget to use a **strong password** for the admin account!

### Port
Expand Down Expand Up @@ -86,7 +92,7 @@ docker run -d --name db_nextcloud \
-e MYSQL_DATABASE=nextcloud -e MYSQL_USER=nextcloud \
-e MYSQL_PASSWORD=supersecretpassword \
mariadb:10

docker run -d --name nextcloud \
--link db_nextcloud:db_nextcloud \
-v /mnt/nextcloud/data:/data \
Expand Down Expand Up @@ -170,7 +176,7 @@ nextcloud-db:
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD=supersecretpassword

# If using Nextant
solr:
image: solr:6-alpine
Expand Down
25 changes: 25 additions & 0 deletions nextcloud/rootfs/usr/local/bin/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,31 @@ cat >> /nextcloud/config/autoconfig.php <<EOF;
?>
EOF

# Put S3 config into it's own config file
if [[ ! -z "$DATASTORE_BUCKET" ]]; then
cat >> /nextcloud/config/s3.config.php <<EOF;
<?php
\$CONFIG = array (
# Setup S3 as a backend for primary storage
'objectstore' => array (
'class' => 'OC\\Files\\ObjectStore\\S3',
'arguments' => array (
'bucket' => '${DATASTORE_BUCKET}',
'autocreate' => false,
'key' => '${DATASTORE_KEY}',
'secret' => '${DATASTORE_SECRET}',
'hostname' => '${DATASTORE_HOST}',
'port' => '${DATASTORE_PORT:-443}',
'use_ssl' => true,
// required for some non amazon s3 implementations
'use_path_style' => %{DATASTORE_USE_PATH_STYLE},
),
),
);
?>
EOF
fi

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
Expand Down