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

Commit

Permalink
Add support to nextcloud image to use an S3 bucket as primary storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete Brown committed Sep 7, 2017
1 parent f33846f commit 107262d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
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
11 changes: 8 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,11 @@ 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)*
Don't forget to use a **strong password** for the admin account!

### Port
Expand Down Expand Up @@ -86,7 +91,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 +175,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

0 comments on commit 107262d

Please sign in to comment.