New app: Monica CRM

119 views
Skip to first unread message

Robert Schmid

unread,
Feb 7, 2021, 1:10:28 PM2/7/21
to Sandstorm Development
Hey all,

I've started a project for packaging Monica (an open source contact and relationship manager, https://www.monicahq.com/) as a Sandstorm App: https://github.com/rs22/monica-sandstorm 
I think this application is really well aligned with the Sandstorm philosophy.

There also is a prebuilt spk available, if you would like to try it: https://github.com/rs22/monica-sandstorm/releases/tag/v2.19.1-pre

The main things I needed to change were user authentication and passing CSRF tokens in a custom HTTP header, which apparently is a common practice of the underlying Laravel framework. Some things are still left to do (e.g. removing outgoing links, exposing CalDAV/CardDAV APIs), but most of the app is working.

I've also taken a somewhat different approach to packaging, by first creating a Docker image that is based on the official Monica image and then extended by nginx and mysql (the installation of which I've mostly copied from the vagrant-spk lemp stack).
The final image filesystem is then mounted and picked up by the spk tooling.

Before I publish the app to the App Market, I would like to know if you have any comments or remarks -- so please let me know if you do!

- Robert

Jacob Weisz

unread,
Feb 7, 2021, 2:09:40 PM2/7/21
to sandst...@googlegroups.com
I've had "try to package Monica" on my todo list for... years, so I'm extremely excited to try this!

--
  Jacob Weisz

--
You received this message because you are subscribed to the Google Groups "Sandstorm Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sandstorm-de...@googlegroups.com.

Julian Foad

unread,
Feb 7, 2021, 4:26:17 PM2/7/21
to sandst...@googlegroups.com
Nice work, Robert.  I have been meaning to try Monica (not expecting to do it inside Sandstorm) so, seeing this, I tried your .spk.  It seems to work.  I haven't tried anything deep, just adding a couple of contacts and changing some settings.

Are you planning to tackle the slightly deeper integration issues such as getting rid of the initial sign-up page (making it automatically sign up to Monica using Sandstorm's info) and the "Invite a new user to access your account" feature which I imagine may be a little harder to integrate with Sandstorm's "share with user" feature?

- Julian

Jacob Weisz

unread,
Feb 7, 2021, 8:06:30 PM2/7/21
to sandst...@googlegroups.com
I think I am pretty happy with this package as-is. If it were in the approval queue, I'd approve it. I noticed there's no screenshots in the metadata yet, and the footer links do not open in new tab, which is needed for external links to work. But there's really not much to complain about here, the app works as expected in any sort of basic functionality.

There's plenty of room to work on sharing, API access, etc. but I don't feel like that's critical to be very useful as a Sandstorm app.

--
  Jacob Weisz

--
You received this message because you are subscribed to the Google Groups "Sandstorm Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sandstorm-de...@googlegroups.com.

Ian Denhardt

unread,
Feb 8, 2021, 12:59:22 PM2/8/21
to Robert Schmid, Sandstorm Development
Hm, I tried creating a grain from the built spk and it never seemsto
finish booting; it gets to a step where the debug log is saying:

waiting for php-fpm to be available at /var/run/php/php-fpm.sock

Over and over again, and it never stops. I'll see if I can dig in a bit
more later and provide a more useful bug report.

Quoting Robert Schmid (2021-02-07 13:10:28)

> and passing CSRF tokens in a custom HTTP header, which apparently is a
> common practice of the underlying Laravel framework.

Can you elaborate a bit more here? What was the problem exactly, and
what did you do to fix it? It sounds like you're saying you had to
change the header that was being used to pass the csrf token (presumably
because it was something Sandstorm blocks), but I'm not sure my
interpretation is correct. If it is, the better long-term solution would
be to add the particular header to the list of allowed values (as we've
done in a few other cases) so packagers of other apps using the same
framework don't have to work around it.


> I've also taken a somewhat different approach to packaging, by first
> creating a Docker image that is based on the official Monica image and
> then extended by nginx and mysql (the installation of which I've
> mostly copied from the vagrant-spk lemp stack).

Are you aware of docker-spk?

https://github.com/zenhack/docker-spk

-Ian

Jacob Weisz

unread,
Feb 8, 2021, 1:16:31 PM2/8/21
to sandst...@googlegroups.com
It looks like X-Requested-With may be the problematic header, we already allow X-CSRF-TOKEN, unless it's case sensitive.

Regarding starting up, I wonder if I also saw that on my first grain load: I was in a car traveling through a forest in the middle of nowhere when I tested the grain, so I assumed that was poor connectivity on my part. However, since I got the grain up, I've had no issues. Perhaps it's just got a really slow initial spin-up.

--
Jacob Weisz
goo...@jacobweisz.com
> --
> You received this message because you are subscribed to the Google
> Groups "Sandstorm Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sandstorm-de...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sandstorm-dev/161280715190.2868.13060951372055188886%40localhost.localdomain.
>

Jacob Weisz

unread,
Feb 8, 2021, 1:30:15 PM2/8/21
to sandst...@googlegroups.com
I would say a fresh Monica grain for me takes about 15-16 seconds to load. You can determine it is "working" because the grain size is steadily increasing to 65 MB, which is the base grain size for a Monica grain. Successive loads are near instantaneous.

--
Jacob Weisz
goo...@jacobweisz.com
> https://groups.google.com/d/msgid/sandstorm-dev/d644c786-91af-4324-8741-fae25fd3b5d7%40www.fastmail.com.
>

Ian Denhardt

unread,
Feb 8, 2021, 3:25:41 PM2/8/21
to Jacob Weisz, sandst...@googlegroups.com
Quoting Jacob Weisz (2021-02-08 13:16:29)

> It looks like X-Requested-With may be the problematic header, we
> already allow X-CSRF-TOKEN, unless it's case sensitive.

Headers are case-insensitive in general. I see no reason not to support
X-Requested-With.

> Regarding starting up, I wonder if I also saw that on my first grain load: I was in a car traveling through a forest in the middle of nowhere when I tested the grain, so I assumed that was poor connectivity on my part. However, since I got the grain up, I've had no issues. Perhaps it's just got a really slow initial spin-up.

Having left the window open and come back a few hours later, I can
confirm it did *eventually* come up, though the app is sluggish going
from page to page (despite me being about 3 feet from the server). It
came up within a more typical timeframe after a reboot, and I just tried
spinning up another grain and it's similarly taking a ridiculously long
time to start, so this does seem to be a first-run issue. Lots of apps
have this problem to some degree, but this is... extreme.

I agree the integration issues shouldn't be considered blockers.

Jacob Weisz

unread,
Feb 8, 2021, 3:51:26 PM2/8/21
to Ian Denhardt, sandst...@googlegroups.com
Interesting. As I said, I'd say 15 seconds is about what I see on my machine, but then I might also be running it on a higher performance box than many Sandstorm boxes might be. (Ian, if you want to, I gave you user rights on my box if you want to test against it at all.)

It looks like from the grain log it runs a few dozen migrations, each taking a few fractions of a second to complete, before the PHP socket is created. I imagine it might be a better experience if there was some sort of loading screen there, but it didn't strike me as crazy for a first run.

--
Jacob Weisz
goo...@jacobweisz.com

Ian Denhardt

unread,
Feb 8, 2021, 7:55:00 PM2/8/21
to Jacob Weisz, sandst...@googlegroups.com
Ok, now I'm seeing after some comparable amount of time the spinner goes
away and I just get a blank page, which the browser console tells me
involves a 500 error code, and results in the below in the grain's debug
log. So it looks like the database initialization is actually failing
for me.

---

In PDOConnection.php line 61:

[PDOException (42S02)]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'monica.instances
' doesn't exist


Exception trace:
at /opt/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:61
PDO->prepare() at /opt/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:61
Doctrine\DBAL\Driver\PDOConnection->prepare() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:331
Illuminate\Database\Connection->Illuminate\Database\{closure}() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
Illuminate\Database\Connection->runQueryCallback() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:631
Illuminate\Database\Connection->run() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:339
Illuminate\Database\Connection->select() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2260
Illuminate\Database\Query\Builder->runSelect() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2248
Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2743
Illuminate\Database\Query\Builder->onceWithColumns() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2249
Illuminate\Database\Query\Builder->get() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:547
Illuminate\Database\Eloquent\Builder->getModels() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:531
Illuminate\Database\Eloquent\Builder->get() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:143
Illuminate\Database\Eloquent\Builder->first() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:23
Illuminate\Database\Eloquent\Model->forwardCallTo() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1736
Illuminate\Database\Eloquent\Model->__call() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1748
Illuminate\Database\Eloquent\Model::__callStatic() at /opt/www/html/app/Console/Commands/PingVersionServer.php:45
App\Console\Commands\PingVersionServer->handle() at n/a:n/a
call_user_func_array() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php:37
Illuminate\Container\Util::unwrapIfClosure() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:95
Illuminate\Container\BoundMethod::callBoundMethod() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:39
Illuminate\Container\BoundMethod::call() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:596
Illuminate\Container\Container->call() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:134
Illuminate\Console\Command->execute() at /opt/www/html/vendor/symfony/console/Command/Command.php:258
Symfony\Component\Console\Command\Command->run() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
Illuminate\Console\Command->run() at /opt/www/html/vendor/symfony/console/Application.php:916
Symfony\Component\Console\Application->doRunCommand() at /opt/www/html/vendor/symfony/console/Application.php:264
Symfony\Component\Console\Application->doRun() at /opt/www/html/vendor/symfony/console/Application.php:140
Symfony\Component\Console\Application->run() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:93
Illuminate\Console\Application->run() at /opt/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129
Illuminate\Foundation\Console\Kernel->handle() at /opt/www/html/artisan:37


✓ Maintenance mode: off
'/usr/local/bin/php' 'artisan' up
waiting for php-fpm to be available at /var/run/php/php-fpm.sock
waiting for php-fpm to be available at /var/run/php/php-fpm.sock
Application is now live.

Monica v2.19.1 is set up, enjoy.

Jake W

unread,
May 28, 2021, 1:29:18 PM5/28/21
to Sandstorm Development
Oh, I probably should've let people know here too, in case nobody's staring at the Sandstorm app market for updates: Monica 3.0.1 is now in the app market. rs22 is planning to look at improving startup performance and integration support in the future, and there are issues to track those on the GitHub repo now.
Reply all
Reply to author
Forward
0 new messages