givanz / Vvveb

Powerful and easy to use cms to build websites, blogs or ecommerce stores.
https://www.vvveb.com
GNU Affero General Public License v3.0
239 stars 49 forks source link

Persistent storage volumes #112

Open PencilShavings opened 3 months ago

PencilShavings commented 3 months ago

What folders should be mapped for persistent storage? In the docs “Install using docker” it just says docker run -p 8080:80 vvveb/vvvebcms:latest.

givanz commented 3 months ago

The folder that needs mapping is the apache htdocs folder /var/www/html

sudo docker volume create vvveb-volume
sudo docker run -p 8080:80 --mount source=vvveb-volume,target=/var/www/html vvveb/vvvebcms 

Or with docker compose

services:
  frontend:
    image: vvveb/vvvebcms:latest
    volumes:
      - vvveb-volume:/var/www/html
volumes:
  vvveb-volume:
    external: true
PencilShavings commented 3 months ago

You have to mount the entire site? Is there not just a data/config folder that can be bound?

Is there a way to use bind mounts? I personalty don’t find named-volumes very tangible. Having the ability to place the content wherever on the system is a necessity.

givanz commented 2 months ago

You can bind /config and /public/media folders for persistent assets and config.

If you use SQLite then you can also mount the database folder storage/sqlite/.

sudo docker run -p 8080:80  \
--mount type=bind,source="$(pwd)"/config,target=/var/www/html/config  \
--mount type=bind,source="$(pwd)"/media,target=/var/www/html/public/media \
vvveb/vvvebcms 
PencilShavings commented 2 months ago

public/media/ & storage/sqlite/ seemed to have done part of the trick but mapping /var/www/html/config results in “Internal server error, please try again later.” with a bunch of other code. I am amusing because there are files in that directory that get removed when you mount a local directory to it.

Without it, every time I restart the container I get sent back to the initial setup process.

Error message if it’s useful:

Internal server error, please try again later. 
[Refresh page](http://localhost:8080/install//) 
Error
Error loading session driver 
File
/var/www/html/system/session.php on line 45 
Code
    public function __construct($driver, $expire = 3600) {
        $class = '\\Vvveb\\System\\Session\\' . $driver;

        if (class_exists($class)) {
            $options      = \Vvveb\config(APP . '.session', []);
            $this->driver = new $class($options);
        } else {
            throw new \Exception('Error loading session driver ' . $driver);     // <==
        }

        return $this->driver;
    }

    public function get($key) {
Trace
#0 /var/www/html/system/session.php(33): Vvveb\System\Session->__construct(NULL)
#1 /var/www/html/system/functions.php(318): Vvveb\System\Session::getInstance()
#2 /var/www/html/install/controller/index.php(49): Vvveb\session('language')
#3 /var/www/html/system/core/frontcontroller.php(190): Vvveb\Controller\Index->__construct()
#4 /var/www/html/system/core/frontcontroller.php(298): Vvveb\System\Core\FrontController::call('Vvveb\\Controlle...', 'index', '/var/www/html/i...')
#5 /var/www/html/system/core/frontcontroller.php(364): Vvveb\System\Core\FrontController::redirect('Index', 'index')
#6 /var/www/html/system/core/startup.php(366): Vvveb\System\Core\FrontController::dispatch()
#7 /var/www/html/index.php(138): Vvveb\System\Core\start()
#8 /var/www/html/install/index.php(51): include('/var/www/html/i...')
#9 /var/www/html/public/install/index.php(26): include('/var/www/html/i...')
#10 {main}
givanz commented 2 months ago

Docker does not copy the existing files into bind mounts, and because config/app.php is missing is throwing this error.

You need to connect to the container, download and unzip the cms files to copy the files to the empty bind mounts folders.

docker exec -it <mycontainer> bash
curl -Lo /tmp/vvveb.zip https://www.vvveb.com/download.php
unzip /tmp/vvveb.zip -d /var/www/html