docker-mautic icon indicating copy to clipboard operation
docker-mautic copied to clipboard

Mautic 4 stateless container

Open thinkl33t opened this issue 3 years ago • 19 comments

This update makes a few changes:

  • Moves local.php, cache, logs, media and spool into a volume at /data
  • Makes sure the above exist and are owned by www-data on startup
  • Drops mautic into /var/www/html and removes the copy on initial bringup

Should close at least #2, #90, #184, #203

thinkl33t avatar May 27 '21 14:05 thinkl33t

Tried this but installation was not successful.

I have not filled env vars MAUTIC_URL, MAUTIC_ADMIN_EMAIL, MAUTIC_ADMIN_PASSWORD because it is not mentioned in README.

When run it behaves like I filled them:

2021-05-31T02:26:01.520939806Z 
2021-05-31T02:26:01.520982383Z Ensuring Mautic database is present
2021-05-31T02:26:01.529807392Z 
2021-05-31T02:26:01.529834392Z MySQL Database Created
2021-05-31T02:26:01.537833883Z ========================================================================
2021-05-31T02:26:01.537861930Z This server is now configured to run Mautic!
2021-05-31T02:26:01.537868255Z The following information will be prefilled into the installer (keep password field empty):
2021-05-31T02:26:01.537910546Z Host Name: srv-captain--shared-maria-db
2021-05-31T02:26:01.537915447Z Database Name: mautic
2021-05-31T02:26:01.537918818Z Database Username: mautic
2021-05-31T02:26:01.537922247Z Database Password: xxx
2021-05-31T02:26:01.537925821Z ========================================================================
2021-05-31T02:26:01.537930169Z 
2021-05-31T02:26:01.537933441Z 
2021-05-31T02:26:01.537936722Z ========================================================================
2021-05-31T02:26:01.572933227Z Updating existing mautic config
2021-05-31T02:26:01.580907815Z ========================================================================
2021-05-31T02:26:01.580931061Z 
2021-05-31T02:26:01.580934982Z 
2021-05-31T02:26:01.610898760Z ========================================================================
2021-05-31T02:26:01.610924296Z Mautic not currently installed (no secret_key in local.php)
2021-05-31T02:26:01.610928723Z 
2021-05-31T02:26:01.610932252Z URL & Admin credentials supplied, attempting automated mautic installation.
2021-05-31T02:26:01.610936264Z 
2021-05-31T02:26:01.961278843Z Mautic Install
2021-05-31T02:26:01.961406612Z ==============
2021-05-31T02:26:01.961465415Z 
2021-05-31T02:26:01.961513857Z Parsing options and arguments...
2021-05-31T02:26:01.961689912Z 0 - Checking installation requirements...
2021-05-31T02:26:01.963124404Z Missing optional settings:
2021-05-31T02:26:01.963193814Z   - [0] It is recommended to secure your installation with an SSL certificate (https). Starting February 2020 Google Chrome will stop sending third-party cookies in cross-site requests unless the cookies are secure. Tracking will stop working for Mautic instances running on HTTP. Use HTTPS.
2021-05-31T02:26:01.973076893Z Continue with install anyway? [yes/no]========================================================================
2021-05-31T02:26:01.973161497Z 
2021-05-31T02:26:01.973254359Z 
2021-05-31T02:26:02.291497854Z ========================================================================
2021-05-31T02:26:02.291620632Z Applying any needed database migrations
2021-05-31T02:26:02.291689755Z 
2021-05-31T02:26:02.595702014Z 
2021-05-31T02:26:02.595895462Z [2021-05-31 02:26:02] ++ adding generated column generated_sent_date
2021-05-31T02:26:02.595977942Z [2021-05-31 02:26:02] -> ALTER TABLE email_stats ADD generated_sent_date DATE AS (CONCAT(YEAR(date_sent), '-', LPAD(MONTH(date_sent), 2, '0'), '-', LPAD(DAY(date_sent), 2, '0'))) COMMENT '(DC2Type:generated)';
2021-05-31T02:26:02.595987948Z             ALTER TABLE email_stats ADD INDEX `generated_sent_date_email_id`(generated_sent_date, email_id)
2021-05-31T02:26:02.598631416Z 
2021-05-31T02:26:02.599178109Z In AbstractMySQLDriver.php line 61:
2021-05-31T02:26:02.599246743Z                                                                                
2021-05-31T02:26:02.599322415Z   An exception occurred while executing 'ALTER TABLE email_stats ADD generate  
2021-05-31T02:26:02.599382891Z   d_sent_date DATE AS (CONCAT(YEAR(date_sent), '-', LPAD(MONTH(date_sent), 2,  
2021-05-31T02:26:02.599431637Z    '0'), '-', LPAD(DAY(date_sent), 2, '0'))) COMMENT '(DC2Type:generated)';    
2021-05-31T02:26:02.599504599Z               ALTER TABLE email_stats ADD INDEX `generated_sent_date_email_id  
2021-05-31T02:26:02.599561535Z   `(generated_sent_date, email_id)':                                           
2021-05-31T02:26:02.599609809Z                                                                                
2021-05-31T02:26:02.599681716Z   SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.email_sta  
2021-05-31T02:26:02.599738052Z   ts' doesn't exist                                                            
2021-05-31T02:26:02.599786285Z                                                                                
2021-05-31T02:26:02.599846379Z 
2021-05-31T02:26:02.600032136Z In Exception.php line 18:
2021-05-31T02:26:02.600087224Z                                                                                
2021-05-31T02:26:02.600134784Z   SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.email_sta  
2021-05-31T02:26:02.600217710Z   ts' doesn't exist                                                            
2021-05-31T02:26:02.600268852Z                                                                                
2021-05-31T02:26:02.600310870Z 
2021-05-31T02:26:02.600493447Z In PDOConnection.php line 132:
2021-05-31T02:26:02.600546725Z                                                                                
2021-05-31T02:26:02.600593965Z   SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.email_sta  
2021-05-31T02:26:02.600678256Z   ts' doesn't exist                                                            
2021-05-31T02:26:02.600729267Z                                                                                
2021-05-31T02:26:02.600768600Z 
2021-05-31T02:26:02.600972796Z doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--all-or-nothing [ALL-OR-NOTHING]] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]
2021-05-31T02:26:02.601032628Z 

iBobik avatar May 31 '21 02:05 iBobik

For anyone who wants to test it, I published this build here: https://hub.docker.com/r/bobik/mautic (v4-apache)

iBobik avatar May 31 '21 02:05 iBobik

When I filled variables it installed.

Btw, installation should work also without HTTPS because it ofter takes time before Let's Encrypt creates certificate.

iBobik avatar May 31 '21 02:05 iBobik

There are "PHP options" twice in the README.

iBobik avatar May 31 '21 02:05 iBobik

I'm now happy this is working - i've been running a slightly tweaked version of it (built using gitlab CI) for around month.

Thanks for the review @iBobik:

  • I have removed the 'default' username / password / url in #196 and rebased so install doesn't happen every time anymore
  • I'm pretty sure you can set your MAUTIC_URL to be HTTPS and install will complete fine, your instance just won't be accessible until letsencrypt has generated your certificate :)

thinkl33t avatar Aug 13 '21 10:08 thinkl33t

Added a commit that clears the cache fully on container startup, as mautic's built in cache clear was missing files and causing failures on upgrade from 4.0.0-beta to 4.0.0-rc

thinkl33t avatar Aug 13 '21 10:08 thinkl33t

@thinkl33t thank you very much for your work and time.. this is a very interesting resource, but i ask for a little patience so that we can finish the common image of mautic, then we dedicate time to this pull..

luizeof avatar Aug 27 '21 10:08 luizeof

@iBobik I just tested your image which works well on my side. There is just the MAUTIC_VERSION env variable in docker-compose that doesn't seem to be taken into account because when I change it to MAUTIC_VERSION=4.0.0 it installs version 4.0.0-rc Maybe with: ENV MAUTIC_VERSION=${MAUTIC_VERSION:-4.0.0} in the Dockerfile ?

The only thing missing would be the possibility to run Mautic with a slave mysql database in locked state to be able to do failover and high availability on a cluster, currently I get an error message when I run mautic on lock tables.

user592965 avatar Sep 22 '21 18:09 user592965

Hello, I will not continue on this for now, because my project was cancelled, so I will not test it.

Honza Pobořil

22. 9. 2021 v 20:05, user592965 @.***>:

 @iBobik I just tested your image which works well on my side. There is just the MAUTIC_VERSION variable that doesn't seem to be taken into account because when I change it to MAUTIC_VERSION=4.0.0 it installs version 4.0.0-rc The only thing missing would be the possibility to run Mautic with a slave mysql database in locked state to be able to do failover and high availability on a cluster, currently I get an error message when I run mautic on lock tables.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

iBobik avatar Sep 23 '21 09:09 iBobik

Any news on getting this merged? In my tests it worked fine? Codebase divergence is a thing though

jvlatzko avatar Jan 14 '22 12:01 jvlatzko

Pretty useful changes, as it looks like. The addressed issues are a main issue currently when deciding to go docker with Mautic or not.

dsp76 avatar Jan 18 '22 14:01 dsp76

Hello, I will not continue on this for now, because my project was cancelled, so I will not test it. Honza Pobořil

@iBobik Could you elaborate on which tasks need to be done? Any broken changes? This feature seems to be really useful and it would be a shame to see it wasted

ivanmonteiro avatar Mar 02 '22 19:03 ivanmonteiro

Check by fork I deployed into production: https://github.com/ibobik/docker-mautic

I have not tested it extensively, so not sure if everything works, but it seemed ok.

iBobik avatar Mar 02 '22 19:03 iBobik

thanks @iBobik ... I will check this pull this week ... many thanks.

luizeof avatar Mar 02 '22 19:03 luizeof

any news about this?

kimtiago avatar Jun 17 '22 01:06 kimtiago

Thanks for the review and testing @ivanmonteiro - much appreciated! @thinkl33t @wget @luizeof could you take a look at the feedback and decide where we want to go with this feature?

RCheesley avatar Jul 28 '22 10:07 RCheesley

@RCheesley I'm currently working on it.

valeu @ivanmonteiro ... muito bom ter brasileiros por aqui!

luizeof avatar Jul 28 '22 10:07 luizeof

@RCheesley I'm currently working on it.

valeu @ivanmonteiro ... muito bom ter brasileiros por aqui!

Apart from the cache delete problem I commented above, I really liked the lean folder structure. With only a couple of folders and configuration files instead of the whole mautic code.

@luizeof Se precisar de ajuda para testar me avisa e farei o possível para ajuda-lo

ivanmonteiro avatar Jul 28 '22 18:07 ivanmonteiro

Hi guys just checking if this is moving forward and If something else needs to be done (maybe I can help)

francoisauclair911 avatar Nov 15 '22 15:11 francoisauclair911