Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding raspberrypi docker-compose example #49

Merged
merged 2 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .examples/raspberrypi/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
APP_KEY=app_key
APP_URL="raspberrypi.local:8080"
DB_HOST=db

MAIL_MAILER=smtp
MAIL_HOST=smtp.domain.com
MAIL_PORT=587
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME=Monica
Comment on lines +1 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand the value of having a .env file, in all examples I prefer to put everything in the docker-compose.yml file for simplicity.
Appart from DB_HOST variable, all others will be env-specific, and should not be included (you should be able to get the example and run-it, the rest of the configuration is up to the person)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you ok including all of these variables in the docker-compose.yml? I found the exact variables required for the installation challenging to find and I think it would improve the dev UX if we include them directly in the example.

40 changes: 40 additions & 0 deletions .examples/raspberrypi/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3.4"

services:
app:
image: monica
env_file: .env
depends_on:
- db
ports:
- 8080:80
volumes:
- data:/var/www/html/storage
restart: always

cron:
image: monica
env_file: .env
restart: always
volumes:
- data:/var/www/html/storage
command: cron.sh
depends_on:
- db
Comment on lines +15 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not mix the example. Here it's for raspberry, and the cron part is not mandatory, please remove it from the example.

Suggested change
cron:
image: monica
env_file: .env
restart: always
volumes:
- data:/var/www/html/storage
command: cron.sh
depends_on:
- db

Copy link
Contributor Author

@iloveitaly iloveitaly May 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the cron is mandatory: without it, reminder emails are not sent (and therefore the application setup isn't complete). Am I missing something here? Is there another way for reminders and other async jobs to run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asbiin friendly reminder on my question about async jobs running when cron is not in place. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iloveitaly I stumbled upon the same issue and was about to give the cron thing a try, but looking further it seems that the supervisor method is the way to go: https://github.com/monicahq/docker/blob/master/.examples/supervisor/fpm/docker-compose.yml

and you need to copy the files from https://github.com/monicahq/docker/tree/master/.examples/supervisor/fpm/app as mentioned in the docs, once it was running with supervisor the reminder mails stared coming in as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lcx why is the supervisor method the way to go? Running cron in a separate container doesn't seem like a bad option, and has some benefits compared to the supervisor method (more configuration i docker vs lesser known unix tooling; easier monitoring and log analysis of separate processes; etc).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asbiin the cron part is mandatory if you want reminder emails and other async jobs to be run, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iloveitaly indeed, the cron part is here to run the schedule command, which aims at sending reminders, and other tasks. It's not mandatory to run the application, that's why it's not included in all examples, also because there are multiple ways to handle it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I agree with @iloveitaly : the "normal" way do create cron part with docker is running another container, not using supervisor. Each container has its own purpose, and it's easier to start/stop only one without touching the others.

Maybe it could be better to have a dedicated section about the cron/scheduler part - I would agree documentation is not the best part of this project!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asbiin what are your thoughts about merging this in and handling the future improvements to documentation in a separate PR? Having this example in this repo would have been super helpful for me as I was trying to host this on my pi.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asbiin friendly reminder on my last comment: thoughts on merging as-is and then tweaking later?


db:
image: jsurf/rpi-mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: monica
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
volumes:
- mysql:/var/lib/mysql
restart: always

volumes:
data:
name: data
mysql:
name: mysql
1 change: 1 addition & 0 deletions .examples/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ In this section you will find some examples about how to use monica's docker ima
| [`nginx-proxy-self-signed-ssl`](nginx-proxy-self-signed-ssl) | shows you how to run monica with a self signed ssl certificate.
| [`nginx-proxy`](nginx-proxy) | shows you how to run monica with https and generate a [Let's Encrypt](https://letsencrypt.org/) certificate.
| [`maxsize`](maxsize) | shows you how to adapt the max upload size of you php settings in the app container.
| [`raspberrypi`](raspberrypi) | shows you how to host monica on a raspberry pi.


## Run with docker-compose
Expand Down