OSSN dockerization with integrated config files

Adrien Allemand Posted in General Discussion 5 years ago

I have dockerized OSSN for practical reasons and i am now trying to skip the annoying config part at the begininng of the startup process.

In my docker file i use these instructions to copy the config files in place, the copy works

COPY --chown=www-data:www-data ossn.config.site.php /var/www/html/ossn/configurations/ossn.config.site.php
COPY --chown=www-data:www-data ossn.config.db.php /var/www/html/ossn/configurations/ossn.config.db.php

then when i run my docker-compose I specify the environement variables as so :

  - DB_HOST=db
  - DB_PORT=3306
  - DB_USER=ossnuser
  - DB_PASSWORD=test
  - DB_DB=ossndb

The server starts and doesn't display any errors on startup (from console) but when i try to connect to my container i have the following error message :

Fatal error: Uncaught OssnDatabaseException: Table 'ossndb.ossn_site_settings' doesn't exist 
SELECT * FROM ossn_site_settings ; 
in /var/www/html/ossn/classes/OssnDatabase.php:96 
Stack trace: #0 /var/www/html/ossn/classes/OssnDatabase.php(195): OssnDatabase->execute() 
#1 /var/www/html/ossn/classes/OssnSite.php(35): OssnDatabase->select(Array, true) 
#2 /var/www/html/ossn/libraries/ossn.lib.system.php(29): OssnSite->getAllSettings() 
#3 /var/www/html/ossn/system/start.php(35): include_once('/var/www/html/o...') 
#4 /var/www/html/ossn/index.php(12): require_once('/var/www/html/o...') 
#5 {main} thrown in /var/www/html/ossn/classes/OssnDatabase.php on line 96

As I understand the problem, the tables haven't been created yet. I went onto the DB through a phpmyadmin and the db exists but is empty (no tables).

Where does the database creation process take place in a normal ossn startup sequence ?

Do you have an idea how i could trigger it from a script ?

Is there anyone who has experience dockerizing OSSN ?

(My dockerization is based on Tyranwyn's)

Replies
Indonesian Arsalan Shah Replied 5 years ago

Instead of re-installing everthing, install it at once and create snapshot of your server then you may restore the snapshot or create new instance from it.

Or

You may install it at once, backup your database, data_folder, and the www folder, then when you wanna restore simply create a command that restore the database and the www and data folder.

Maybe yous should also see :https://gist.github.com/Tyranwyn/8762f168861991ed8b51bca3db3115b1

ch Adrien Allemand Replied 5 years ago

It's been some time and i've been able to learn more about OSSN's internal setup. I foudn the SQL script and tried to apply it directly to the database but ossn doesn't setup properly.

As Docker is not familiar, 'll try to extend my research field with this question :"Is it possible (and how) to script OSSN deployement ?" I mean automate the configuration/installation part that goes through the Web interface ? I am loosing hours filling back in the same informations again and again as i am developping components and having to reinstall the server periodicly and i'd like to script the launch including :

-starting the server
-setup of DB user, host ...
-setup of an admin account
-creation of the database

I'd like to setup ossn in a more ore less stateless way so it can recover when crashed or on restart and i've found it difficult to do so. Even when the server doesn't crash, having to delete then reupload a new zip then re-enable the component is a pain to do and should be done with a script...

How do you guys do your testing/dev ?

German Michael Zülsdorff Replied 5 years ago

See https://www.opensource-socialnetwork.org/wiki/view/1137/how-to-find-something-a-word-pattern-in-the-source-code (case B)

Thus, running grep -Rni "create table" . will show the file you're looking for.

I'm in no way familiar with docker, but if there's something availbable like 'COPY' I assume something like 'EXECUTE' will be available, too. So you may either execute the mysql client or a php script in order to run the necessary sql commands.