Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
INFRA-107 – switch to Composer installs + more custom Docker base (#4)
Browse files Browse the repository at this point in the history
* INFRA-107 – fix local DB params, maybe?

Possibly address:
"mautic  | warning: both MAUTIC_DB_HOST and MYSQL_PORT_3306_TCP found
 mautic  |   Connecting to MAUTIC_DB_HOST (mauticdb)
 mautic  |   instead of the linked mysql container"

* INFRA-107 – make entrypoint not use `sudo`

Because
* our container currently doesn't have it
* if the image has users/permissions set sensibly we shouldn't need it(?)

* INFRA-107 – start building with our own image as the base, getting Mautic thru Composer

* INFRA-107 – start Composer installing in build; add more extensions; add `cron` and [try to] explain why

* INFRA-107 – fix Composer cache bits; check in WIP readme updates

* INFRA-107 – fix (hopefully) an args thing inherited from the official image, which IDEA considers an error

* INFRA-107 – temporarily set Apache `LogLevel debug`

(Committing for future cherry picking if needed – think I've found the redirect issue)

* INFRA-107 – fix various local config vars

* Revert "INFRA-107 – temporarily set Apache `LogLevel debug`"

This reverts commit bbc2500.

* INFRA-107 – check in Mautic app scaffolding; update readme

* Revert "INFRA-107 – check in Mautic app scaffolding; update readme"

This reverts commit b93cd0e.

* INFRA-107 – `.gitignore` everything generated & update readme
  • Loading branch information
NoelLH authored Aug 3, 2023
1 parent e1ce454 commit 510a759
Show file tree
Hide file tree
Showing 11 changed files with 15,971 additions and 24 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
.idea/

# All generated as part of Mautic scaffolding.
.env
.env.dist
app/.htaccess
bin/*
autoload.php
docroot/
Gruntfile.js
package.json
package-lock.json
vendor/
29 changes: 23 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
FROM mautic/mautic:v4-apache
FROM thebiggive/php:8.0

# Install the AWS CLI - needed to load in secrets safely from S3. See https://aws.amazon.com/blogs/security/how-to-manage-secrets-for-amazon-ec2-container-service-based-applications-by-using-amazon-s3-and-docker/
RUN apt-get clean && apt-get update -qq && apt-get install -y awscli libzip-dev && \
# And `cron`, needed for old school tasks-in-a-web-server management of scheduled stuff inside Mautic, and libs for
# various extensions. See also https://stackoverflow.com/a/38526260/2803757
RUN apt-get clean && apt-get update -qq && apt-get install -y awscli cron libc-client-dev libkrb5-dev libpng-dev libzip-dev && \
rm -rf /var/lib/apt/lists/* /var/cache/apk/*

RUN docker-php-ext-install mysqli zip
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
&& docker-php-ext-install gd imap mysqli sockets zip

COPY ./docker-support/makeconfig.php /makeconfig.php
COPY ./docker-support/makedb.php /makedb.php

# Load secrets from S3 like with our custom ECS apps.
COPY ./secrets_entrypoint.sh /usr/local/etc/secrets_entrypoint.sh
Expand All @@ -17,9 +23,20 @@ COPY ./entrypoint.sh /entrypoint.sh
# Apply recommend PHP configuration for best stability and performance.
COPY ./php-conf/assert.ini /usr/local/etc/php/conf.d/assert.ini

# Increase threads allowed to reduce risk of Apache bail outs. (Probably redundant?)
COPY ./apache-conf/mpm-prefork.conf /etc/apache2/mods-available/mpm-prefork.conf
RUN ln -s /etc/apache2/mods-available/mpm-prefork.conf /etc/apache2/mods-enabled/mpm-prefork.conf
# Ensure Composer can cache in its default location
RUN mkdir /var/www/.composer
RUN chown www-data:www-data /var/www/.composer

USER www-data

COPY ./composer.json /var/www/html/composer.json
COPY ./composer.lock /var/www/html/composer.lock

# Install PHP dependencies, as www-data. This also generates all Mautic scaffolding
# files if not already there.
RUN composer install --no-interaction --optimize-autoloader --no-dev

USER root

EXPOSE 80

Expand Down
28 changes: 22 additions & 6 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
# The Big Give's Mautic

This repository is a thin layer for tooling used by the Big Give to
test and deploy Mautic.
We use Mautic's official Composer recommendation repository and its Composer
packages as the basis for building this, with scaffolding `.gitignore`d
to keep the repository compact.

The Docker tag `mautic/mautic:v4-apache`, managed by the Mautic community,
is the basis for the app code. Everything we do should extend and
minimally alter the app we pull from the upstream, official Docker images.
The `Dockerfile` runs `composer install`, which has a post-install script to
generate scaffolding whenever it's not present.

We don't use the official Docker image as it [is not really maintained](https://github.com/mautic/docker-mautic/issues/240)
as of August 2023, and when we tried Apache tags they were too old to be usable – as
well as e.g. not using Composer. We tried another unofficial experimental repo but also
found it to not quite work and be very different from other web things we deploy to ECS.

## `cron` tasks

In an effort to avoid re-working too much of the outdated Docker repo's entrypoint logic, we add `cron`
to our Linux base – everything in one container – which is not very Docker-y or horizontal scaling-safe.
We should probably take a closer look at what scheduled commands do and any locking ability before running
this live, particularly with more than one task in an ECS Service.

## Local runs

To test a build locally:

Expand All @@ -22,4 +36,6 @@ to `/usr/local/etc`.

Mautic's persisted data lives at `/var/www/html` – we don't modify the
official image's assumptions around this. On ECS a persistent volume
(e.g. an EFS mount) must be mapped to this internal path.
(e.g. an EFS mount) can be mapped to this internal path, or the S3 plugin
can be used to make the media approach more 12-factor-friendly. (The latter
would probably be better if it works, but is not yet tested!)
4 changes: 0 additions & 4 deletions apache-conf/mpm-prefork.conf

This file was deleted.

145 changes: 145 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"name": "mautic/recommended-project",
"description": "Project template for Mautic 4 projects with composer",
"type": "project",
"license": "GPL-2.0-or-later",
"homepage": "https://www.mautic.org/mautic-releases",
"support": {
"user-docs": "https://docs.mautic.org/en",
"developer-docs": "https://developer.mautic.org",
"chat": "https://www.mautic.org/slack"
},
"funding": [
{
"type": "other",
"url": "https://opencollective.com/mautic"
},
{
"type": "other",
"url": "https://github.com/sponsors/mautic"
}
],
"authors": [
{
"name": "",
"role": ""
}
],
"require": {
"php": "8.0.*",
"composer/installers": "^1.11",
"mautic/core-composer-scaffold": "4.x-dev",
"mautic/core-lib": "4.4.9",
"mautic/grapes-js-builder-bundle": "4.4.9",
"mautic/plugin-citrix": "4.4.9",
"mautic/plugin-clearbit": "4.4.9",
"mautic/plugin-cloudstorage": "4.4.9",
"mautic/plugin-crm": "4.4.9",
"mautic/plugin-emailmarketing": "4.4.9",
"mautic/plugin-focus": "4.4.9",
"mautic/plugin-fullcontact": "4.4.9",
"mautic/plugin-gmail": "4.4.9",
"mautic/plugin-outlook": "4.4.9",
"mautic/plugin-social": "4.4.9",
"mautic/plugin-tagmanager": "4.4.9",
"mautic/plugin-zapier": "4.4.9",
"mautic/theme-aurora": "4.4.9",
"mautic/theme-blank": "4.4.9",
"mautic/theme-brienz": "4.4.9",
"mautic/theme-cards": "4.4.9",
"mautic/theme-coffee": "4.4.9",
"mautic/theme-confirmme": "4.4.9",
"mautic/theme-fresh-center": "4.4.9",
"mautic/theme-fresh-fixed": "4.4.9",
"mautic/theme-fresh-left": "4.4.9",
"mautic/theme-fresh-wide": "4.4.9",
"mautic/theme-goldstar": "4.4.9",
"mautic/theme-mauve": "4.4.9",
"mautic/theme-nature": "4.4.9",
"mautic/theme-neopolitan": "4.4.9",
"mautic/theme-oxygen": "4.4.9",
"mautic/theme-paprika": "4.4.9",
"mautic/theme-skyline": "4.4.9",
"mautic/theme-sparse": "4.4.9",
"mautic/theme-sunday": "4.4.9",
"mautic/theme-trulypersonal": "4.4.9",
"mautic/theme-vibrant": "4.4.9",
"php-http/message-factory": "^1.1"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/mautic/FOSOAuthServerBundle.git"
}
],
"conflict": {
"mautic/mautic": "*",
"mautic/core": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true,
"allow-plugins": {
"composer/installers": true,
"symfony/flex": true,
"mautic/core-composer-scaffold": true,
"php-http/discovery": true
},
"platform": {
"php": "8.0.29"
}
},
"autoload": {
"psr-4": {
"MauticPlugin\\": "docroot/plugins/"
}
},
"extra": {
"mautic-scaffold": {
"locations": {
"web-root": "docroot/"
}
},
"installer-paths": {
"docroot/app": [
"type:mautic-core"
],
"docroot/plugins/{$name}": [
"type:mautic-plugin"
],
"docroot/themes/{$name}": [
"type:mautic-theme"
]
},
"mautic-core-project-message": {
"include-keys": [
"homepage",
"support"
],
"post-create-project-cmd-message": [
"<bg=blue;fg=white> </>",
"<bg=blue;fg=white> Congratulations, you’ve installed the Mautic codebase </>",
"<bg=blue;fg=white> from the mautic/recommended-project template! </>",
"<bg=blue;fg=white> </>",
"",
"<bg=yellow;fg=black>Next steps</>:",
" * Install Mautic",
" * Read the user guide",
" * Get support: https://www.mautic.org/support",
" * Get involved with the Mautic community:",
" https://www.mautic.org/getting-involved",
" * Remove the plugin that prints this message:",
" composer remove mautic/core-project-message"
]
}
},
"scripts": {
"post-install-cmd": [
"@composer mautic:scaffold"
],
"post-update-cmd": [
"@composer mautic:scaffold"
]
}
}
Loading

0 comments on commit 510a759

Please sign in to comment.