Skip to content

Commit 1093649

Browse files
committed
M6 doesn't need custom dockerfile as it already has NPM and compsoer in it. Let's simplify
1 parent 0ee917a commit 1093649

5 files changed

Lines changed: 75 additions & 37 deletions

File tree

.env

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
COMPOSE_PROJECT_NAME=basic
22
COMPOSE_NETWORK=${COMPOSE_PROJECT_NAME}-docker
3+
4+
# Mautic Configuration
5+
MAUTIC_VERSION=6.0.5-apache
6+
7+
# Mautic Packages (comma-separated, leave empty if none needed)
8+
MAUTIC_THEMES=
9+
MAUTIC_PLUGINS=
10+
11+
# Example:
12+
# MAUTIC_THEMES=vendor/theme-name:^1.0,another/theme:^2.0
13+
# MAUTIC_PLUGINS=vendor/plugin-name:^1.0,another/plugin:^2.0
14+
15+
# Database Configuration
316
MYSQL_HOST=db.${COMPOSE_NETWORK}
417
MYSQL_PORT=3306
518
MYSQL_DATABASE=mautic_db

Dockerfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Hosting Mautic 5 on a VPS with Docker Compose
1+
# Hosting Mautic 6 on a VPS with Docker Compose
22

3-
This is a working example of automate hosting Mautic 5 instance(s) on Virtual Private Server (VPS) on [digitalocean.com](https://m.do.co/c/d0ce234a41be)
3+
This is a working example of automate hosting Mautic 6 instance(s) on Virtual Private Server (VPS) on [digitalocean.com](https://m.do.co/c/d0ce234a41be)
44

55
## Mautic Conference Global 2024 video about this project
66

@@ -24,7 +24,7 @@ This is a bit different from your normal "execute a bunch of commands" tutorials
2424

2525
It allows you to:
2626
- Install Mautic within 10 minutes.
27-
- Upgrade Mautic with 1 line change.
27+
- Upgrade Mautic with 1 line change in `.env` file.
2828
- Downgrade with commit revert.
2929
- Install themes and plugins via Composer.
3030
- Anyone from your team can do this. Avoid the [Bus Factor](https://en.wikipedia.org/wiki/Bus_factor). GitHub allows you to set rules that someone needs to approve all changes before they are applied.
@@ -93,7 +93,7 @@ A container is a list or a recipe of commands that needs to be executed to build
9393

9494
**Docker Compose** enables simplified networking between the containers and [1 config file](docker-compose.yml) where all that interconnection is described.
9595

96-
The [docker-compose.yml](docker-compose.yml) in this repository was copied from https://github.com/mautic/docker-mautic/tree/mautic5/examples/basic
96+
The [docker-compose.yml](docker-compose.yml) in this repository uses the official [Mautic Docker images](https://hub.docker.com/r/mautic/mautic).
9797

9898
### Containers
9999

@@ -123,8 +123,23 @@ Volumes are basically files and directories that are shared between a container
123123

124124
One of the goals of this deployment is to have a trace of everything related to the Mautic instance configuration. Installing a plugin or a theme can break your Mautic so it's good to have a way to roll back if it happens. And to have a trace of who installed what, when and why is also great to have. Git gives us all that.
125125

126-
In the [Dockerfile](Dockerfile) there is an example of how to install a package. In this case it is a [`chimpino/theme-air`](https://chimpino.com/themes) theme. If you need to install anyting else, you'll just add a new line with the package you need and commit this one line change.
126+
### Configuration via Environment Variables
127127

128+
Themes and plugins are now configured in the [`.env`](.env) file using environment variables:
129+
130+
```bash
131+
# Mautic Packages (comma-separated, leave empty if none needed)
132+
MAUTIC_THEMES=vendor/theme-name:^1.0,another/theme:^2.0
133+
MAUTIC_PLUGINS=vendor/plugin-name:^1.0,another/plugin:^2.0
134+
```
135+
136+
### Mautic Version Configuration
137+
138+
You can also configure the Mautic version in the `.env` file:
139+
140+
```bash
141+
MAUTIC_VERSION=6.0.5-apache
142+
```
128143

129144
## Cron jobs
130145

docker-compose.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ services:
2626
- default
2727

2828
mautic_web:
29-
build:
30-
context: .
31-
dockerfile: Dockerfile
29+
image: mautic/mautic:${MAUTIC_VERSION:-6.0.5-apache}
3230
links:
3331
- db:mysql
3432
ports:
@@ -52,9 +50,7 @@ services:
5250
- default
5351

5452
mautic_cron:
55-
build:
56-
context: .
57-
dockerfile: Dockerfile
53+
image: mautic/mautic:${MAUTIC_VERSION:-6.0.5-apache}
5854
links:
5955
- db:mysql
6056
volumes: *mautic-volumes
@@ -69,9 +65,7 @@ services:
6965
- default
7066

7167
mautic_worker:
72-
build:
73-
context: .
74-
dockerfile: Dockerfile
68+
image: mautic/mautic:${MAUTIC_VERSION:-6.0.5-apache}
7569
links:
7670
- db:mysql
7771
volumes: *mautic-volumes

setup-dc.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,45 @@ else
3333
fi
3434
echo "## Installing Mautic..."
3535
docker compose exec -T -u www-data -w /var/www/html mautic_web php ./bin/console mautic:install --force --admin_email {{EMAIL_ADDRESS}} --admin_password {{MAUTIC_PASSWORD}} http://{{IP_ADDRESS}}:{{PORT}}
36+
37+
echo "## Installing custom themes and plugins..."
38+
39+
# Load environment variables
40+
if [ -f "/var/www/.env" ]; then
41+
source /var/www/.env
42+
fi
43+
44+
# Install themes
45+
if [ ! -z "$MAUTIC_THEMES" ]; then
46+
echo "### Processing themes..."
47+
IFS=',' read -ra THEME_ARRAY <<< "$MAUTIC_THEMES"
48+
for package in "${THEME_ARRAY[@]}"; do
49+
package=$(echo "$package" | xargs) # trim whitespace
50+
if [ ! -z "$package" ]; then
51+
echo "#### Installing theme: $package"
52+
docker compose exec -T -u www-data -w /var/www/html mautic_web composer require "$package" --no-scripts --no-interaction || echo "Warning: Failed to install theme $package"
53+
fi
54+
done
55+
else
56+
echo "### No themes defined in MAUTIC_THEMES"
57+
fi
58+
59+
# Install plugins
60+
if [ ! -z "$MAUTIC_PLUGINS" ]; then
61+
echo "### Processing plugins..."
62+
IFS=',' read -ra PLUGIN_ARRAY <<< "$MAUTIC_PLUGINS"
63+
for package in "${PLUGIN_ARRAY[@]}"; do
64+
package=$(echo "$package" | xargs) # trim whitespace
65+
if [ ! -z "$package" ]; then
66+
echo "#### Installing plugin: $package"
67+
docker compose exec -T -u www-data -w /var/www/html mautic_web composer require "$package" --no-scripts --no-interaction || echo "Warning: Failed to install plugin $package"
68+
fi
69+
done
70+
else
71+
echo "### No plugins defined in MAUTIC_PLUGINS"
72+
fi
73+
74+
echo "## Custom extensions installation completed"
3675
fi
3776

3877
echo "## Starting all the containers"

0 commit comments

Comments
 (0)