domainmod / domainmod

DomainMOD is an open source application written in PHP & MySQL used to manage your domains and other internet assets in a central location. DomainMOD also includes a Data Warehouse framework that allows you to import your web server data so that you can view, export, and report on your live data.
https://domainmod.org
GNU General Public License v3.0
470 stars 96 forks source link

Issue with running using docker #166

Open nathanmerry opened 4 months ago

nathanmerry commented 4 months ago

Hello,

I am attempting to run your service using Docker; however, I am having issues with the initial setup. I am running this all on my local machine.

When I attempt to run docker-compose up -d and view it locally, I receive a 500 error. After inspecting the logs, I can see the error chmod: cannot access '/var/www/html/temp': No such file or directory.

Then when I open the server in the browser, I see the following logs:

PHP Warning: require_once(/var/www/html/_includes/config.inc.php): Failed to open stream: No such file or directory in /var/www/html/index.php on line 25
PHP Fatal error: Uncaught Error: Failed opening required '/var/www/html/_includes/config.inc.php' (include_path='.:/usr/local/lib/php') in /var/www/html/index.php:25\nStack trace:\n#0 {main}\n thrown in /var/www/html/index.php on line 25

Do you know what the issue could be?

My docker-compose.yml:

services:
  app:
    image: domainmod/domainmod:latest
    container_name: domainmod_app
    depends_on:
      - db
    environment:
      - PUID=501
      - PGID=20
      - TZ=America/Vancouver
      - DOMAINMOD_WEB_ROOT=
      - DOMAINMOD_DATABASE_HOST=db
      - DOMAINMOD_DATABASE=domainmod
      - DOMAINMOD_USER=domainmod
      - DOMAINMOD_PASSWORD=password1
    volumes:
      - ./application:/var/www/html
    ports:
      - 8080:80
    restart: unless-stopped

  db:
    image: ghcr.io/linuxserver/mariadb:alpine
    container_name: domainmod_db
    environment:
      - PUID=501
      - PGID=20
      - TZ=America/Vancouver
      - MYSQL_DATABASE=domainmod
      - MYSQL_USER=domainmod
      - MYSQL_PASSWORD=password1
      - MYSQL_ROOT_PASSWORD=password2
    volumes:
      - ./database:/config
    ports:
      - 3306
    restart: unless-stopped
nublaii commented 4 months ago

Looks like the image is not reading the variables defined on the docker-compose.yml file.

I copied the sample file out of the image (/var/www/html/_includes/config.SAMPLE.inc.php), edited it to use the env values and mounted it:

docker-compose.yaml:

...
    volumes:
      - ./config.inc.php:/var/www/html/_includes/config.inc.php
...

config.inc.php:

<?php
/**
 * /_includes/config.SAMPLE.inc.php
 *
 * This file is part of DomainMOD, an open source domain and internet asset manager.
 * Copyright (c) 2010-2024 Greg Chetcuti <greg@chetcuti.com>
 *
 * Project: http://domainmod.org   Author: http://chetcuti.com
 *
 * DomainMOD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * DomainMOD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with DomainMOD. If not, see
 * http://www.gnu.org/licenses/.
 *
 */
?>
<?php
// Path Settings
$web_root = getenv('DOMAINMOD_WEB_ROOT');

// Database Settings
$dbhostname = getenv('DOMAINMOD_DATABASE_HOST');;
$dbname = getenv('DOMAINMOD_DATABASE');;
$dbusername = getenv('DOMAINMOD_USER');;
$dbpassword = getenv('DOMAINMOD_PASSWORD');;
jayjay3108 commented 2 months ago

Could you make a pr for that? Seems Like That is a General Problem with this App for docker Installation

crispybegs commented 1 month ago

i just tried domainmod in docker for the first time today and have this exact problem. Was it ever fixed?

joseluislucas commented 1 month ago

I'm having the same issue and I can't seem to fix it. Any suggestions for a workaround?

nathanmerry commented 1 month ago

as @nublaii said, you must create a copy of /var/www/html/_includes/config.SAMPLE.inc.php to /var/www/html/_includes/config.inc.php 👍

nogara commented 2 weeks ago

There is indeed something missing in the Docker image that uses the environment variables from docker-compose.yml and configures the service (by creating the _includes/config.inc.php file with the data from the env vars.

I created a PR on the docker-source project that should help with that.

https://github.com/domainmod/docker-source/pull/1

bepstein111 commented 2 days ago

So I fixed that, but now I'm getting this: No such file or directory in /var/www/html/classes/DomainMOD/Database.php:33\nStack trace:\n#0 /var/www/html/classes/DomainMOD/Database.php(33): PDO->__construct()\n#1 /var/www/html/classes/DomainMOD/Database.php(49): DomainMOD\\Database->__construct()\n#2 /var/www/html/index.php(29): DomainMOD\\Database::getInstance()\n#3 {main}\n thrown in /var/www/html/classes/DomainMOD/Database.php on line 33

EDIT: Just kidding I'm an idiot, don't mind me.