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
385 stars 82 forks source link

Reconfigure Docker setup #59

Closed w0rldart closed 11 months ago

w0rldart commented 11 months ago

Currently, docker-compose.yml and Dockerfile are setup in a way that it has to download and unzip the vvveb as a package. Perhaps this is for the docker hub image, but for that, I advise setting up a dedicated repository. And docker-compose.yml does not allow to utilise the code from the existing repository

Also, the current setup fails for local develooment, due to permissions configurations.


With this proposed approach/change, which is

In addition, a little code formatting to keep everything consistent and aligned

w0rldart commented 11 months ago

@givanz fyi

givanz commented 11 months ago

Thanks for the improvements.

I tested the new docker composer with nginx and found an issue with the install redirect.

Even if the port is added to the path it will not work on 8080 because nginx will try to redirect to /install folder without the port number because of try_files.

To avoid this I changed the install path redirect to

$installPathRedirect = '/install/index.php';

and it works without the need to add port number.

I also had to set write permission to /var/www/html in Dockerfile for install.

ENV DIR_VVVEB='/var/www/html'
RUN usermod -u 1000 www-data

WORKDIR ${DIR_VVVEB}

RUN chown -R www-data:www-data ${DIR_VVVEB}
RUN chmod -R 666 ${DIR_VVVEB}

I added a new entry in docker composer for auto install, the install script will only run once and will exit if already installed, it checks if /config/db.php exists.


  vvveb-install:
    build:
      context: .
    volumes:
      - ./:/var/www/html/
    entrypoint:
      [
        "bash",
        "-c",
        "sleep 5 && php cli.php install module=index host=db user=vvveb password=vvveb database=vvveb admin[email]=admin@vvveb.com admin[password]=admin",
      ]
    depends_on:
      - php
    networks:
      - internal

Let me know if you think it can be improved or that there could be issues with auto install.

w0rldart commented 11 months ago

1. Port situation

I realised the port issue on redirects would be persistent, even after install.

My approach for that (which would require more re-work) would be to adapt the redirectors (maybe have a helper method for that) that does redirect calculation, including the port (if present). Because we can have other stuff running on port 80 and still want to be able to run this, on another port.

So this would be the best, and long-term solution.

Quick win, is to replace 8080 with 80.

2. Permissions

I have had no issues with permissions with this approach. In fact, the reason I even created this whole thing, is because the existing setup throws permission issues. And generally speaking, on a Docker dev setup, this should not be modified.

This is not a production setup anyway.

3. Auto install

The reason I had left the auto install part out, is to have the opportunity to test/simulate the whole workflow. The auto install part can be documented somewhere and added by those who wish, but I don't see it beneficial to be part of the docker workflow. And anyway, not only that it can be easily added, but you also have to do it once (unless you're testing the installing workflow, and repeatedly delete the db)

givanz commented 11 months ago

I have had no issues with permissions with this approach.

I retested and didn't get any permissions issues, it was probably something related to my setup.

The port issue is easily fixed by adding index.php for install, for after install I made some changes to url generation to also include port number in the latest update.

You are right, it's better to be able to test setup or to choose SQLite, I will add the auto install part commented.

Thanks