Giter VIP home page Giter VIP logo

docker-nextcloud's Introduction

hoellen/nextcloud

The self-hosted productivity platform that keeps you in control.

Nextcloud official website and source code.

About

This non-official image is intended as an all-in-one (as in monolithic) Nextcloud production image. If you're not sure you want this image, you should probably use the official image. The main goal is to provide an easy-to-use image with decent security standards. This repository is mainly based on Wondefall/docker-nextcloud.

Check out Nextcloud official website and source code.


Features

  • Based on Alpine Linux.
  • Fetching PHP/nginx from their official images.
  • Rootless: no privilege at any time, even at startup.
  • Uses s6 as a lightweight process supervisor.
  • Supports MySQL/MariaDB, PostgresQL and SQLite3 database backends.
  • Includes OPcache and APCu for improved caching & performance, also supports redis.
  • Tarball integrity & authenticity checked during build process.
  • Includes hardened_malloc, a hardened memory allocator.
  • Includes Snuffleupagus, a PHP security module.
  • Includes a simple built-in cron system.
  • Much easier to maintain thanks to multi-stages build.
  • Does not include imagick, samba, etc. by default.

You're free to make your own image based on this one if you want a specific feature. Uncommon features won't be included as they can increase attack surface: this image intends to stay minimal, but functional enough to cover basic needs.

Security

Don't run random images from random dudes on the Internet. Ideally, you want to maintain and build it yourself.

  • Images are scanned every day by Trivy for OS vulnerabilities. Known vulnerabilities will be automatically uploaded to GitHub Security Lab for full transparency. This also warns me if I have to take action to fix a vulnerability.
  • Latest tag/version is automatically built weekly, so you should often update your images regardless if you're already using the latest Nextcloud version.
  • Build production images without cache (use docker build --no-cache for instance) if you want to build your images manually. Latest dependencies will hence be used instead of outdated ones due to a cached layer.
  • A security module for PHP called Snuffleupagus is used by default. This module aims at killing entire bug and security exploit classes (including weak PRNG, file-upload based code execution), thus raising the cost of attacks. For now we're using a configuration file derived from the default one, with some explicit exceptions related to Nextcloud. This configuration file is tested and shouldn't break basic functionality, but it can cause issues in specific and untested use cases: if that happens to you, get logs from either syslog or /nginx/logs/error.log inside the container, and open an issue. You can also disable the security module altogether by changing the PHP_HARDENING environment variable to false before recreating the container.
  • Images are signed with the GitHub-provided OIDC token in Actions using the experimental "keyless" signing feature provided by cosign. You can verify the image signature using cosign as well:
COSIGN_EXPERIMENTAL=true cosign verify ghcr.io/hoellen/nextcloud

Verifying the signature isn't a requirement, and might not be as seamless as using Docker Content Trust (which is not supported by GitHub's OCI registry). However, it's strongly recommended to do so in a sensitive environment to ensure the authenticity of the images and further limit the risk of supply chain attacks.

Tags

  • latest : latest Nextcloud version
  • x : latest Nextcloud x.x (e.g. 30)
  • x.x.x : Nextcloud x.x.x (e.g. 30.0.0)

You can always have a glance here. Only the latest stable version will be maintained by myself.

Note: automated builds only target linux/amd64 (x86_64). There is no technical reason preventing the image to be built for arm64 (in fact you can build it yourself), but GitHub Actions runners are limited in memory, and this limit makes it currently impossible to target both platforms.

Build-time variables

Variable Description Default
NEXTCLOUD_VERSION version of Nextcloud *
ALPINE_VERSION version of Alpine Linux *
PHP_VERSION version of PHP *
NGINX_VERSION version of nginx *
HARDENED_MALLOC_VERSION version of hardened_malloc *
SNUFFLEUPAGUS_VERSION version of Snuffleupagus (php ext) *
SHA256_SUM checksum of Nextcloud tarball (sha256) *
GPG_FINGERPRINT fingerprint of Nextcloud GPG key *
UID user id 1000
GID group id 1000
CONFIG_NATIVE native code for hardened_malloc false
VARIANT variant of hardened_malloc (see repo) light

* latest known available, likely to change regularly

For convenience they were put at the very top of the Dockerfile and their usage should be quite explicit if you intend to build this image yourself. If you intend to change NEXTCLOUD_VERSION, change SHA256_SUM accordingly.

Environment variables

Runtime

Variable Description Default
UPLOAD_MAX_SIZE file upload maximum size 10G
APC_SHM_SIZE apc shared memory size 128M
OPCACHE_MEM_SIZE opcache available memory 128M
MEMORY_LIMIT max php command mem usage 512M
CRON_PERIOD cron time interval (min.) 5m
CRON_MEMORY_LIMIT cron max memory usage 1G
DB_TYPE sqlite3, mysql, pgsql sqlite3
DOMAIN host domain localhost
PHP_HARDENING enables snuffleupagus true

Leave them at default if you're not sure what you're doing.

Startup

Variable Description
ADMIN_USER admin username
ADMIN_PASSWORD admin password
DB_TYPE sqlite3, mysql, pgsql
DB_NAME name of the database
DB_USER name of the database user
DB_PASSWORD password of the db user
DB_HOST database host

ADMIN_USER and ADMIN_PASSWORD are optional and mainly for niche purposes. Obviously, avoid clear text passwords. Once setup.sh has run for the first time, these variables can be removed. You should then edit /nextcloud/config/config.php directly if you want to change something in your configuration.

The usage of Docker secrets will be considered in the future, but config.php already covers quite a lot.

Volumes

Variable Description
/data data files
/nextcloud/config config files
/nextcloud/apps2 3rd-party apps
/nextcloud/themes custom themes
/php/session PHP session files

Note: mounting /php/session isn't required but could be desirable in some circumstances.

Ports

Port Use
8888 (tcp) Nextcloud web

A reverse proxy like Traefik or Caddy can be used, and you should consider:

  • Redirecting all HTTP traffic to HTTPS
  • Setting the HSTS header correctly

Migration

From now on you'll need to make sure all volumes have proper permissions. The default UID/GID is now 1000, so you'll need to build the image yourself if you want to change that, or you can just change the actual permissions of the volumes using chown -R 1000:1000. The flexibility provided by the legacy image came at some cost (performance & security), therefore this feature won't be provided anymore.

Other changes that should be reflected in your configuration files:

  • /config volume is now /nextcloud/config
  • /apps2 volume is now /nextcloud/apps2
  • ghcr.io/hoellen/nextcloud is the new image location

You should edit your docker-compose.yml and config.php accordingly.

Usage

To do.

docker-nextcloud's People

Contributors

bertbaron avatar frebib avatar frzb avatar gagandaroach avatar gusttt avatar hoellen avatar quoing avatar ramblurr avatar rgarcia89 avatar rushsteve1 avatar stffabi avatar stp-bsh avatar waja avatar wonderfall avatar yeoldegrove avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-nextcloud's Issues

not properly set up to resolve "/ocm-provider/"

Hi,

today I stumbled upon the following statement in the admin section:

There are some warnings regarding your setup.
Your web server is not properly set up to resolve "/ocm-provider/". This is most likely related to a web server configuration that was not updated to deliver this folder directly. Please compare your configuration against the shipped rewrite rules in ".htaccess" for Apache or the provided one in the documentation for Nginx at it's documentation page โ†—. On Nginx those are typically the lines starting with "location ~" that need an update.

It seems to be a new check, and it seems to happen on all my instances. Is it me or is there anything we can do about this? I did not find anything on https://docs.nextcloud.com/server/27/go.php?to=admin-nginx that helped my to find the right place where to adjust the rules regarding this.

DB Index problem on upgrade from 27.1.15 to 28.0.1

Index name "calobjects_index" for table "oc_calendarobjects" collides with the constraint on table "oc_calendarobjectsBroke".

is the message. Droping the index calobjects_index on oc_calendarobjects. Solves the problem.
Maybe it is an upstream problem.

using NC_ as prefix not working

Hi,

i was trying to get rid of my clear text secrets in the config.php
You by yourself mentioned in the readme, that by default "a lot" can be handled via docker secret or similar in config.php.

but this:
https://github.com/nextcloud/server/blob/master/lib/private/Config.php (see ENV reference NC_) doesn't work

as the official documentation is more or less non existent on this, i'm asking, is this a issue with this image or just not working at all?

i've just tried to set env vars according to the schema

dbtype in config.php

NC_dbtype=psql in environment variables.

but this breaks with a 500 internal server error.

Unable to pull image ghcr.io/hoellen/nextcloud

I'm not able to pull the image, even after login ghcr.io with my account. Is this an error on my end or are there permissions on your side not set correctly? Also in the README the nextcloud version (21) is wrong. It should be 23, right?

Cron not executed on NC29

I've recently updated to NC29 and my instance complains about cron not being executed for over 2h.

There's a notice at the cron setting which states "The cron.php needs to be executed by the system account "nextcloud"."
I've already restarted the container two times - no visible effect.

Cron worked as expected on NC28.

Snuffleupagus "allow" rules for Memories app

Hi,

Nextcloud Memories App https://apps.nextcloud.com/apps/memories depends on shell_exec function, whose execution is dropped by Snuffleupagus configuration in ghcr.io/hoellen/nextcloud:25 docker image.

{"reqId":"kSXRACAVK6v9d1dB9vGU","level":3,"time":"2023-05-08 19:54:11","remoteAddr":"172.17.26.1","user":"XXX","app":"PHP","method":"POST","url":"/settings/apps/enable","message":"[snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', because its argument '$command' content (ps -ef | grep go-vod-ocwgkowh3q4h | grep -v grep | awk '{print $2}') matched a rule at /nextcloud/apps2/memories/lib/Util.php#461","userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/112.0","version":"25.0.6.1","data":{"app":"PHP"}}

In particular, these two files call shell_exec multiple times:

I have temporarily worked around the issue by allowing the two files to run any (!) command:

$ grep "memories" /usr/local/etc/php/conf.d/nextcloud-php8.rules | grep -v grep
sp.disable_function.function("shell_exec").param("command").filename("/nextcloud/apps2/memories/lib/Util.php").allow();
sp.disable_function.function("shell_exec").param("command").filename("/nextcloud/apps2/memories/lib/Service/BinExt.php").allow();

Error at initial configuration

Hi,

first of all thank you for the awesome image!

I tried to setup a fresh installation but ran into an error.
Log output:

Enabling Snuffleupagus...
Starting automatic configuration...
Automatic configuration finished.
Nextcloud is not installed - only a limited number of commands are available


There are no commands defined in the "app" namespace.  
                                             

Exception: Not installed in /nextcloud/lib/base.php:281
Stack trace:
#0 /nextcloud/lib/base.php(697): OC::checkInstalled(Object(OC\SystemConfig))
#1 /nextcloud/lib/base.php(1164): OC::init()
#2 /nextcloud/cron.php(43): require_once('/nextcloud/lib/...')
#3 {main}
{
  "reqId": "3R5ysfM84Jmj0g3oWsdQa",
  "level": 3,
  "time": "2023-04-15T20:56:53+00:00",
  "remoteAddr": "",
  "user": "--",
  "app": "cron",
  "method": "",
  "url": "--",
  "message": "Not installed",
  "userAgent": "--",
  "version": "",
  "exception": {
    "Exception": "Exception",
    "Message": "Not installed",
    "Code": 0,
    "Trace": [{
      "file": "/nextcloud/lib/base.php",
      "line": 697,
      "function": "checkInstalled",
      "class": "OC",
      "type": "::",
      "args": [
        ["OC\\SystemConfig"]
      ]
    }, {
      "file": "/nextcloud/lib/base.php",
      "line": 1164,
      "function": "init",
      "class": "OC",
      "type": "::",
      "args": []
    }, {
      "file": "/nextcloud/cron.php",
      "line": 43,
      "args": ["/nextcloud/lib/base.php"],
      "function": "require_once"
    }],
    "File": "/nextcloud/lib/base.php",
    "Line": 281,
    "CustomMessage": "--"
  }
}

I found some somewhat related issues (1, 2, 3) but still can't get it to work.
Any idea what's going wrong?

Adding ffmpeg

Hey,

I wanted to add the App "memories" which looks like something everybody wants to have ;) (reddit post). To make it run, I had to disable the PHP_HARDENING (I dont know, perhaps this can also run with it enabled with some tweaking?).

Now I wanted to add the extensions for the media types but unfortunately ffmpeg is not installed.
Can you add it, or a possibility to add it via variables? I saw it in some commit from the past, but it did not survive...

Thanks!

No database connection

Hey there,

since the commit 8070434 I do get the log message: waiting for the database container... and the container is not starting. I use a postgres database and it was and is connectable from within the nextcloud container. When I do occ upgrade for example the response is

Setting log level to debug
Turned on maintenance mode
Updating database schema
Updated database
Updating <calendar> ...
Updated <calendar> to 4.6.1
Starting code integrity check...
Finished code integrity check
Update successful
Turned off maintenance mode
Resetting log level

so I assume nextcloud itself can access the database.

Do you have an idea how to fix this?

thx!

Missing .mjs as a file extension for javascript messing up with certain apps

Logreader needs .mjs file extension in order to properly work (blank screen when accessing the logs from settings)
Based on upstream docs for Ngnix:

[...]
    # Add .mjs as a file extension for javascript
    # Either include it in the default mime.types list
    # or include you can include that list explicitly and add the file extension
    # only for Nextcloud like below:
    include mime.types;
    types {
        text/javascript mjs;
    }
[...]
[...]
    # Serve static files
    location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map)$ {
[...]

I guess other apps would required it. Tested on a 28.0.1 install. Not tested in previous versions.

Latest 26.0.0 (scheduled) build is broken

From the logs:

Error loading shared library libssl.so.3: No such file or directory (needed by /usr/sbin/nginx)
Error loading shared library libcrypto.so.3: No such file or directory (needed by /usr/sbin/nginx)

So nginx is not starting ...

Config file has leading content

Hi,

with the latest release of 27.0.1 the container stopped working with:

Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_set_external_entity_loader was tried and nopped in /nextcloud/lib/base.php on line 592
Config file has leading content, please remove everything before "<?php" in config.php
Fatal error: Uncaught Error: Typed static property OC::$server must not be accessed before initialization in /nextcloud/index.php:71 Stack trace: #0 {main} thrown in /nextcloud/index.php on line 71

but:

/nextcloud/config $ head -2 config.php
<?php
$CONFIG = array (

Thanks Jan

Migrating from old image fails on startup

Starting automatic configuration...
Automatic configuration finished.
Exception: Not installed in /nextcloud/lib/base.php:277
Stack trace:
#0 /nextcloud/lib/base.php(656): OC::checkInstalled(Object(OC\SystemConfig))
#1 /nextcloud/lib/base.php(1096): OC::init()
#2 /nextcloud/cron.php(43): require_once('/nextcloud/lib/...')
#3 {main}

Upgrading from the old image https://github.com/hoellen/dockerfiles/tree/master/nextcloud to this one here.
DB is run seperately, so this could be a different bug than #10

DB_HOST variable not set for checking database availability

You moved the database check from startup to run.sh. There, you are checking for the variable DB_HOST - if this variable is empty you are defaulting to "nextcloud-db" - the default db name is not used in every installation.

Either you have to change your readme or get the host variable for the run.sh from the config.php file. Reason is, you wrote to delete those environment variables after initial setup in your readme - so normally this environment variable is not set anymore in the compose file and uses the default value.

Nextcloud is not installed - only a limited number of commands are available

Hi @hoellen,

creating a new instance resulted into:

nextcloud_1            | Starting automatic configuration...
nextcloud_1            | Automatic configuration finished.
nextcloud_1            | Nextcloud is not installed - only a limited number of commands are available
nextcloud_1            |
nextcloud_1            |
nextcloud_1            |  Command "app:disable" is not defined.
nextcloud_1            |
nextcloud_1            |
nextcloud_1            |  Do you want to run "app:check-code" instead?  (yes/no) [no]:
nextcloud_1            |  > Exception: Not installed in /nextcloud/lib/base.php:277
nextcloud_1            | Stack trace:
nextcloud_1            | #0 /nextcloud/lib/base.php(649): OC::checkInstalled(Object(OC\SystemConfig))
nextcloud_1            | #1 /nextcloud/lib/base.php(1087): OC::init()
nextcloud_1            | #2 /nextcloud/cron.php(43): require_once('/nextcloud/lib/...')
nextcloud_1            | #3 {main}

Looks like it's the same issue like Wonderfall/docker-nextcloud#90. Maybe I'm doing something wrong? Can't imagine that a real issue over there is unfixed since 4 month?

Weekly builds

Hi @hoellen,

what's the intention to build the images weekly (https://github.com/hoellen/docker-nextcloud/blob/master/.github/workflows/build.yml#L9) but also update the normal tags (like the upstream major and minor version)?
Some people (like me) are running update frameworks like watchtower. (Re)building the images each Friday is not a bad idea at all, but I would not expect to get an image update on regular basis when following (minor/major) version tag, but when a new upstream release happens or new functions/fixes lands in the image.

Do you think that people would instead prefer a tag like "weekly/nightly" and follow this tag when they would like to follow such an image?

Regards, Jan.

Nextcloud 24: Issues potentially caused by old 3rd party library that NC migrated away from

I'm still troubleshooting this issue, so I might be wrong, but:

My calendars weren't loading, so I dug into it and first saw some weird PHP errors about the allowed memory size being exhausted, which didn't really make sense, and then I also saw an error about a deprecated "Serializable interface". Long story short, it looks like this image is still using Opis/closure, while Nextcloud 24 has moved on to Laravel/serializable-closure. I'm guessing this is something that needs to be updated within the image, but again, could be wrong. Going to tinker with it some more.

Calendar issues related to allowed memory size - PHP problem?

I've been troubleshooting this for a couple days now, since upgrading from NC 23.0.8 to 24.0.4. Most of my calendars stopped loading and started throwing the following error:

Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) at /nextcloud/3rdparty/sabre/vobject/lib/Recur/RRuleIterator.php#680

I'm not sure if this is a bug with 24.0.4 (doesn't seem like it since others have said they've had no issues), the PHP version, or this particular image and something with its PHP configuration. But I figure it doesn't hurt to post here in case it is related, or if someone else runs into the same issue.

My issue on the NC server Github: nextcloud/calendar#4422
Similar issue someone else reported back in May: nextcloud/server#32568

Fix header "X-XSS-Protection" for Nextcloud 24

Nextcloud 24 throws the following error: The "X-XSS-Protection" HTTP header doesn't contain "1; mode=block". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.

This happens even when nginx on the host side is configured correctly. If you inspect the page, you'll see duplicate headers, one of which is set to 0. When I go into the container's nginx conf (/etc/nginx/conf.d/default.conf), I see add_header X-XSS-Protection "0" always;.

Since it doesn't seem like I can do much via the container shell, I copied the file to the host, edited it, then copied it back to the container, and restarted it. That fixed it.

Multi arch support

Hi @hoellen,

what do you think about multi arch builds? This can be done with little effort with github actions and uploaded to ghcr. The downside of this is, that builds needs more time the more archs are added to the pipeline.

If you like, I can propose a PR.

Chears, Jan.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.