Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Docker Setup using log mailer (some gotchas) #273

Closed
njelich opened this issue Oct 31, 2022 · 7 comments · Fixed by #316
Closed

Docker Setup using log mailer (some gotchas) #273

njelich opened this issue Oct 31, 2022 · 7 comments · Fixed by #316

Comments

@njelich
Copy link
Contributor

njelich commented Oct 31, 2022

Hey guys!

Setting up Docker locally had some unexpected gotchas, so I'd like to just leave a few tips for those new to the flow. This guide continues from the "docker installed, image builds and runs okay point" - meaning you've successfully ran the following commands:

docker build -t monica-next -f scripts/docker/Dockerfile .

docker run --name monica-p 8080:80 -e MAIL_MAILER=log monica-next

Registration

After this point you'll be faced with the login screen, where you have to register.

Screen Shot 2022-10-31 at 10 38 44

Screen Shot 2022-10-31 at 10 39 07

Mail verification

Great, you filled out the registration info and got to the verification mail stage. So where do you find the verification mail?

In my case it is delivered to the Docker Desktop log handler - so open up Docker desktop, pick Containers from the nav bar on the left and click on your monica container.

Screen Shot 2022-10-31 at 11 07 13

Here you can see part of the raw mail HTML being sent to the log mailer. The part containing the verification URL is obfuscated - however, we have = at the end of each line and a few other bits we need to remove before this works fine.

http://localh= ost:8080/email/verify/2/4b8e02cde907e88a3f481928de3e3cc6ca61686c?expires=3D= 1667212743&signature=3Dd545eebd0f5fdff467acb06d2ed4e29f6dd0e255e66c9ffb= 1274fb01a2dcda1a

To clean this up we need to remove the = that were added as line ends, remove the newlines that are unnecessary, replace & with & and (this is a tricky one) remove the 3D after signature= and expires=.

Then we can copy the raw verification url and paste it into the browser to actually get into the app.

http://localhost:8080/email/verify/2/4b8e02cde907e88a3f481928de3e3cc6ca61686c?expires=1667212743&signature=d545eebd0f5fdff467acb06d2ed4e29f6dd0e255e66c9ffb1274fb01a2dcda1a

Congrats, now you have a basic development/usage loop using a locally built docker container.

NOTE: I'll hopefully write a docker-sync setup for development without rebuilding the container soon, making contributing without setting up your local system possible

@djaiss
Copy link
Member

djaiss commented Oct 31, 2022

Thanks for the very detailed instructions. We appreciate it. We know the current process is not super ideal, and we'll improve it so the Docker installation is easier to use.

@njelich
Copy link
Contributor Author

njelich commented Nov 2, 2022

I've been playing around with the builds and I think the dockerfile can be optimized to build waaay faster using the --cache-from flag.

It would require ordering some of the COPY operations so the minor source changes are the last stuff that gets copied. That way the entire container doesn't need a rebuild every time I change a tiny bit of code.

I'm gonna play around with this because it really speeds up the development loop (just the initial caching that already works by default cut my build time by 60%).

@asbiin
Copy link
Member

asbiin commented Nov 5, 2022

The issue with the Mailer are not related to the docker image.
When you register a new account, an email is sent to the email address to validate it.
What we could do instead is make this behavior optional, and send this email only if the mailer is ready/setup.
In this case there will be no need to tweak the docker image configuration.

@njelich
Copy link
Contributor Author

njelich commented Nov 9, 2022

I don't see this as an issue per see, just wrote a description of the process because it took some work to set it up. I tried disabling email confirmation in the correct PHP middlewareish file, but it didn't do anything, just made the app throw 500.

Btw, I feel a lot of the grunt work and minor issues (based on the current issues on monica) will be frontend stuff in the future. (minor broken layouts, mixed up copy etc)

@asbiin
Is there any chance we can get a simple guide on setting up for just frontend development, for the non-PHP crew. E.g. I'd be eager to contribute more but I've been having trouble getting the actual local setup to play nice (hence this docker setup tutorial and push for build cycle improvements - since docker runs for me).

@djaiss
Copy link
Member

djaiss commented Nov 12, 2022

@njelich if you use macOS, setting up Valet makes creating the dev environment a breeze and would deal with PHP and so on. As soon as you have ngninx and PHP working, it's super easy to do dev work.

I don't know how you could use the Docker image to actually do dev work.

If you successfully make it work, after the usual composer install and yarn to install dependancies, we use yarn dev that launches Vite which will give you an URL to copy and paste in your browser.

I have no idea if this helps you in any way, though.

@njelich
Copy link
Contributor Author

njelich commented Nov 17, 2022

A docker compose is usually the way a local environment is set up.

@developStorm
Copy link

The email is encoded as quoted-printable so have it go through a decoder will give you the correct URL as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants