Skip to content

Commit 1646fc2

Browse files
authored
Merge pull request #7 from MITLibraries/awsorg-cleanup
Repository Rename Cleanup
2 parents 490f48e + e4ee0e4 commit 1646fc2

File tree

12 files changed

+238
-182
lines changed

12 files changed

+238
-182
lines changed

.github/workflows/dev_build.yml renamed to .github/workflows/dev-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### This is the Terraform-generated dev-build.yml workflow for the matomo-dev app repository ###
1+
### This is the Terraform-generated dev-build.yml workflow for the docker-matomo-dev app repository ###
22
name: Dev Build and Deploy Fargate Container
33
on:
44
workflow_dispatch:
@@ -15,5 +15,5 @@ jobs:
1515
secrets: inherit
1616
with:
1717
AWS_REGION: "us-east-1"
18-
GHA_ROLE: "matomo-gha-dev"
19-
ECR: "matomo-dev"
18+
GHA_ROLE: "docker-matomo-gha-dev"
19+
ECR: "docker-matomo-dev"

.github/workflows/prod-promote.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### This is the Terraform-generated prod-promote.yml workflow for the matomo-prod app repository ###
1+
### This is the Terraform-generated prod-promote.yml workflow for the docker-matomo-prod app repository ###
22
name: Prod Promote Fargate Container
33
on:
44
workflow_dispatch:
@@ -12,7 +12,7 @@ jobs:
1212
secrets: inherit
1313
with:
1414
AWS_REGION: "us-east-1"
15-
GHA_ROLE_STAGE: matomo-gha-stage
16-
GHA_ROLE_PROD: matomo-gha-prod
17-
ECR_STAGE: "matomo-stage"
18-
ECR_PROD: "matomo-prod"
15+
GHA_ROLE_STAGE: docker-matomo-gha-stage
16+
GHA_ROLE_PROD: docker-matomo-gha-prod
17+
ECR_STAGE: "docker-matomo-stage"
18+
ECR_PROD: "docker-matomo-prod"

.github/workflows/stage-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### This is the Terraform-generated stage-build.yml workflow for the matomo-stage app repository ###
1+
### This is the Terraform-generated stage-build.yml workflow for the docker-matomo-stage app repository ###
22
name: Stage Build and Deploy Fargate Container
33
on:
44
workflow_dispatch:
@@ -15,5 +15,5 @@ jobs:
1515
secrets: inherit
1616
with:
1717
AWS_REGION: "us-east-1"
18-
GHA_ROLE: "matomo-gha-stage"
19-
ECR: "matomo-stage"
18+
GHA_ROLE: "docker-matomo-gha-stage"
19+
ECR: "docker-matomo-stage"

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ COPY ./files/config.ini.php /var/www/html/config/config.ini.php
99
# Create mount point for EFS partition
1010
RUN mkdir -p /mnt/efs
1111

12+
# Move in the "backup persistent files" script
13+
COPY --chmod=0755 ./files/backup-data.sh /usr/local/bin/backup-data.sh
14+
1215
EXPOSE 80

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.PHONY: help dist-dev publish-dev dist-stage publish-stage
22
SHELL=/bin/bash
3-
### This is the Terraform-generated header for matomo-dev ###
4-
ECR_NAME_DEV:=matomo-dev
5-
ECR_URL_DEV:=222053980223.dkr.ecr.us-east-1.amazonaws.com/matomo-dev
3+
### This is the Terraform-generated header for docker-matomo-dev ###
4+
ECR_NAME_DEV:=docker-matomo-dev
5+
ECR_URL_DEV:=222053980223.dkr.ecr.us-east-1.amazonaws.com/docker-matomo-dev
66
### End of Terraform-generated header ###
77

88
help: ## Print this message

README.md

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,22 @@ This repository supports MIT Libraries' implementation of [Matomo](https://matom
55
## Dependencies
66

77
* Deploying this container to AWS requires that the AWS ECR Repository for the container has been created by the [mitlib-tf-workloads-ecr](https://github.com/MITLibraries/mitlib-tf-workloads-ecr) repository.
8+
* Running this container in AWS requires the [mitlib-tf-workloads-matomo](https://github.com/mitlibraries/mitlib-tf-workloads-matomo) infrastructure repository.
89
* Building this container requires access to [Official Docker Matomo](https://hub.docker.com/_/matomo/).
910

10-
## Build
11+
## Dev/Test Build
1112

1213
Run `make dist-dev` to create a new container tagged as `matomo:latest`.
1314

14-
## Deploy
15+
## Dev/Test Deploy
1516

16-
Run `make publish-dev` to build, tag, and push a container to Dev1 for testing, or open a PR to `main`. Merge a PR to `main` to build, tag, and push the container to Stage-Workloads. After merging the PR to `main`, tag a release to promote to production.
17+
Run `make publish-dev` to build, tag, and push a container to Dev1 for testing, or open a PR to `main` (a GitHub Action will build, tag, push the container for you).
18+
19+
## Stage Builds and Promotion to Prod
20+
21+
Merge a PR to `main` to build, tag, and push the container to Stage-Workloads. After merging the PR to `main`, tag a release on the `main` branch to promote to production. GitHub Actions in this repo will take care of the build, tag, push to Stage and the copy from Stage to Production.
22+
23+
**Important Note**: There is no automation in GitHub to automatically deploy the new container after it is push to the ECR repository in AWS. At this time, the only method to deploy the updated container is to force a new deployment of the Matomo service via the AWS Console.
1724

1825
## Implementation notes
1926

@@ -24,15 +31,39 @@ For detailed instructions on initial setup, migration, database upgrades, and ap
2431
"State" for Matomo is managed/stored in at most two locations:
2532

2633
* the `config.ini.php` file
27-
* the MySQL database
34+
* the MariaDB database
35+
36+
The `config.ini.php` file contains some core Matomo configuration. There are a couple of sections worth addressing. First, a note about a special plugin we use.
37+
38+
#### The EnvironmentVariables Plugin
39+
40+
We use the [EnvironmentVariables](https://plugins.matomo.org/EnvironmentVariables) plugin that allows us to set configuration values for Matomo via environment variables via the [mitlib-tf-workloads-matomo](https://github.com/mitlibraries/mitlib-tf-workloads-matomo) infrastructure repo.
41+
42+
The current practice is to set the following core configuration information in `config.ini.php` via environment variables.
43+
44+
* Database connection information
45+
* SSL/TLS configuration
46+
* SMTP information
47+
48+
The remainder of the configuration values should be set by modifying the [config.ini.php](./files/config.ini.php) file and building an updated container.
2849

29-
The `config.ini.php` file contains some core Matomo configuration. There are a couple of sections worth addressing:
50+
#### [Plugins] and [PluginsInstalled]
3051

31-
1. The `[Plugins]` section tells Matomo which plugins to enable on installation. To disable a plugin, simply remove it from this section. Our preference is to modify this section and not the `PluginsInstalled` section, as removing a plugin from `PluginsInstalled` would remove it from the application completely. *Sadly, with the container-based Matomo, it seems to only way to activate a plugin is to use the Matomo web UI*.
32-
1. The `[mail]` section configures the SMTP server. Matomo uses mailers for several core functions, including password resets and reporting. Some related config values (e.g., `login_password_recovery_email_address`) are defined in the `[General]` section.
33-
1. The `[General]` section handles other configurations. A few of these settings are covered by the EnvironmentVariables plugin, but the rest are managed in this code.
52+
The `[Plugins]` section tells Matomo which plugins to enable on installation. To disable a plugin, simply remove it from this section. Our preference is to modify this section and not the `PluginsInstalled` section, as removing a plugin from `PluginsInstalled` would remove it from the application completely. While plugins can get installed in the container build, they are not automatically activated. There are two activation methods that can be used: via the web UI or via the CLI. See [Install a new plugin](https://matomo.org/faq/plugins/faq_21/) in the official Matomo documentation.
3453

35-
By using the [EnvironmentVariables](https://plugins.matomo.org/EnvironmentVariables) plugin for Matomo, we generally don't need to store much in the `config.ini.php` file. Instead, the [mitlib-tf-workloads-matomo](https://github.com/MITLibraries/mitlib-tf-workloads-matomo) code defines the key environment variables for the ECS service, overriding anything in `config.ini.php` and `global.ini.php`.
54+
Any time plugins are installed/removed, it is imperative to capture a backup of the `config.ini.php` file (via the EFS partition) before launching the updated container and then compare it to the `config.ini.php` file after verifying that the plugin is activated. This is one of the few situations where the Matomo application might update/overwrite the `config.ini.php` file.
55+
56+
#### [Mail]
57+
58+
The `[mail]` section configures the SMTP server. Matomo uses mailers for several core functions, including password resets and reporting. Some related config values (e.g., `login_password_recovery_email_address`) are defined in the `[General]` section.
59+
60+
All of the settings in `[mail]` are managed via environment variables that are set by the [mitlib-tf-workloads-matomo](https://github.com/mitlibraries/mitlib-tf-workloads-matomo) infrastructure repo.
61+
62+
#### [General]
63+
64+
The `[General]` section handles other configurations. A few of these settings are covered by the EnvironmentVariables plugin, but the rest are managed in this code.
65+
66+
#### Other configuration
3667

3768
The database stores the rest of the state of Matomo: all the data itself along with the Superuser credentials and the other user accounts and credentials.
3869

@@ -54,6 +85,10 @@ We generally assign the 'View' role to new users, unless they require a higher p
5485

5586
Matomo has built-in two-factor authentication, which we enforce for all accounts. When a user logs in to Matomo for the first time, they will be prompted to configure 2FA. At this time, we are recommending Duo as an authenticator.
5687

88+
#### Recover from lost 2FA
89+
90+
See the official [Recover from lost 2FA](https://matomo.org/faq/how-to/faq_27248) documentation. This allows us to recover the Superuser login if we lose the 2FA information.
91+
5792
## Additional documentation
5893

5994
* [MIT Libraries dev docs](https://mitlibraries.github.io/guides/misc/matomo.html) - includes information about setting up a website for tracking in Matomo.

docs/HOWTO.md

Lines changed: 0 additions & 159 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# How-to instructions
2+
3+
Detailed how-to instructions for upgrade scenarios.
4+
5+
## Upgrade Database Engine
6+
7+
The database engine is managed by [mitlib-tf-workloads-matomo](https://github.com/mitlibraries/mitlib-tf-workloads-matomo). In testing, Matomo had no problems with database engine upgrades through different MariaDB versions.
8+
9+
## Update Matomo version
10+
11+
1. Ensure that a backup of the current `config/config.ini.php` exists in the EFS mount.
12+
1. Publish updated container to ECR.
13+
1. Deploy updated container for ECS service.
14+
1. Verify via webUI that the Matomo installation is ready to be upgraded.
15+
1. SSH (via AWSCLI + Session Manager) to the container and run the upgrade on the CLI (see the [Troubleshooting](./HOWTO-miscellaneous.md) section). It might be possible to do this via the web UI, but there seems to be a timeout issue related to health checks.
16+
1. Copy updated `config/config.ini.php` to the EFS mount.
17+
1. Verify that there were no changes to the `config.ini.php` file that need to be captured here.
18+
1. Relaunch the container.

0 commit comments

Comments
 (0)