infinitesunrise / carsinbikelanes

A browsable geographic database for crowdsourced traffic violation reporting
GNU General Public License v3.0
63 stars 18 forks source link

Unable to validate the config form #19

Open mathieuruellan opened 8 years ago

mathieuruellan commented 8 years ago

Hi,

I'm trying to run it with a docker, and i can't validate the configuration form. The rename seems to be a problem in a docker environment

here are logs: [Fri Sep 23 20:28:35 2016] [notice] Apache/2.2.22 (Debian) PHP/5.4.45-0+deb7u5 configured -- resuming normal operations [Fri Sep 23 20:29:15 2016] [error] [client 172.18.0.1] PHP Warning: rename(): The first argument to copy() function cannot be a directory in /var/www/setup.php on line 125, referer: http://localhost:8080/ [Fri Sep 23 20:29:15 2016] [error] [client 172.18.0.1] PHP Warning: rename(config,/var/cibl_config): Invalid cross-device link in /var/www/setup.php on line 125, referer: http://localhost:8080/ [Fri Sep 23 20:29:15 2016] [error] [client 172.18.0.1] Problem setting up configuration folder., referer: http://localhost:8080/

At least, could you provide me a config file template?

Thank you!

infinitesunrise commented 8 years ago

Hey there, I think a few other folks are currently working to make CIBL compatible with cloud environments like Docker, you may continue to run into snags for the time being apparently due to file system assumptions the current code makes and my inexperience with more advanced deployments. But here's what the default config look like printed out: http://pastebin.com/L0DHUGX3

Hope that helps!

mathieuruellan commented 8 years ago

Thank you to consider docker (providing a docker compose is a good way integrate/test easily and quickly)

Ok, l'm looking at the source code, and try to figure out what's going wrong. You move a directory on $config_folder. With docker, the $config_folder directory must be a volume because it must be persisted. The process must have write access on the parent directory (/var) that is a very bad idea.

The solution should be replace everything in the $config_folder (or delete and copy recursively).

mathieuruellan commented 8 years ago

I succeed to dockerize. I replace the rename line with shell_exec("cp -r config $config_folder");

The condition is that the parent directory must be the volume with correct access.

mathieuruellan commented 8 years ago

Me again ;)! Tell me if i'm boring ;)!

I saw that setup switch is done with a rename


//CREATE CONFIG FILE, CREATE EMPTY DIRECTORIES, SWAP SETUP AND MAIN INDEX PAGE
config_write($config);
mkdir("images");
mkdir("thumbs");
rename('index.php', 'index_old.php');
rename('index_actual.php', 'index.php');

Here again, it is a solution that is making "dockerification" really difficult, because code is not persisted! What about setting a "configured" attribut in the config.php?

kind regards, Mathieu