Skip to content

Commit

Permalink
PS-586 matomo stats (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem authored Oct 25, 2023
1 parent 6452050 commit 0497e2f
Show file tree
Hide file tree
Showing 45 changed files with 843 additions and 379 deletions.
40 changes: 29 additions & 11 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COMPOSE_FILE=docker-compose.yml
COMPOSE_PROFILES=auth,databox,expose,notify,uploader,auth-worker,databox-worker,expose-worker,notify-worker,uploader-worker,db,report,tools,mailhog,dashboard

# Leave empty if 443, include ':' otherwise
HTTPS_PORT_PREFIX=
HTTPS_PORT_PREFIX=${HTTPS_PORT_PREFIX:-}
TRAEFIK_HTTPS_PORT=443
TRAEFIK_HTTP_PORT=80
TRAEFIK_PROVIDERS_FILE_FILENAME=/etc/traefik/dynamic_conf.yaml
Expand All @@ -19,9 +19,32 @@ LETS_ENCRYPT_PROVIDER=
#LETS_ENCRYPT_CA_SERVER=https://acme-v02.api.letsencrypt.org/directory
LETS_ENCRYPT_CA_SERVER=https://acme-staging-v02.api.letsencrypt.org/directory

PHRASEA_DOMAIN=phrasea.local

PHRASEA_DOMAIN=${PHRASEA_DOMAIN:-phrasea.local}
# URLs
AUTH_API_BASE_URL=https://api-auth.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
DASHBOARD_BASE_URL=https://dashboard.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
DATABOX_API_BASE_URL=https://api-databox.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
DATABOX_CLIENT_BASE_URL=https://databox.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
DATABOX_INDEXER_URL=https://databox-indexer.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
ELASTICHQ_BASE_URL=https://elastichq.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
EXPOSE_API_BASE_URL=https://api-expose.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
EXPOSE_CLIENT_BASE_URL=https://expose.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
MAILHOG_BASE_URL=https://mailhog.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
MATOMO_BASE_URL=https://matomo.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
MINIO_CONSOLE_BASE_URL=https://minio-console.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
NOTIFY_API_BASE_URL=https://api-notify.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
PGADMIN_BASE_URL=https://pgadmin.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
PHPMYADMIN_BASE_URL=https://pma.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
PHRASEANET_BASE_URL=https://phraseanet.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
RABBITMQ_CONSOLE_BASE_URL=https://rabbitmq-console.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
REPORT_API_BASE_URL=http://report-api
S3_ENDPOINT=https://minio.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
SAML2_BASE_URL=https://saml-idp2.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}/simplesaml
SAML_BASE_URL=https://saml-idp.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}/simplesaml
TRAEFIK_CONSOLE_BASE_URL=https://traefik-console.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
UPLOADER_API_BASE_URL=https://api-uploader.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
UPLOADER_CLIENT_BASE_URL=https://uploader.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}
ZIPPY_BASE_URL=https://zippy.${PHRASEA_DOMAIN}${HTTPS_PORT_PREFIX}

REGISTRY_NAMESPACE=alchemyfr/ps-
# Docker image TAG (used only for deployment)
Expand Down Expand Up @@ -133,6 +156,7 @@ EXPOSE_CLOUD_FRONT_PRIVATE_KEY=
EXPOSE_CLOUD_FRONT_KEY_PAIR_ID=
EXPOSE_CLOUD_FRONT_TTL=86400
EXPOSE_DISABLE_INDEX_PAGE=0
EXPOSE_MATOMO_SITE_ID=1

# Notify
NOTIFY_RABBITMQ_VHOST=notify
Expand Down Expand Up @@ -167,12 +191,12 @@ MAIL_FROM=noreply@phrasea.local
MAILHOG_PORT=8125

# Matomo
MATOMO_HOST=localhost:8170
MATOMO_PORT=8170
MATOMO_MYSQL_ROOT_PASSWORD=__CHANGE_ME_JDQm8ooetgjd6q8
MATOMO_DATABASE_DBNAME=matomo
MATOMO_DATABASE_USERNAME=matomo
MATOMO_DATABASE_PASSWORD=__CHANGE_ME_DyFTHnJO0smgU
MATOMO_SUPER_USER_USERNAME=admin@phrasea.local
MATOMO_SUPER_USER_PASSWORD=__CHANGE_ME_zBpJUAYDTu8

# Elasticsearch
ELASTICSEARCH_URL=http://elasticsearch:9200
Expand All @@ -186,11 +210,6 @@ REPORT_DB_NAME=report
ZIPPY_CLIENT_ID=client
ZIPPY_CLIENT_SECRET=secret

# SAML IDP Test 1
SAML_BASE_URL=https://saml-idp.${PHRASEA_DOMAIN:-"phrasea.local"}/simplesaml
# SAML IDP Test 2
SAML2_BASE_URL=https://saml-idp2.${PHRASEA_DOMAIN:-"phrasea.local"}/simplesaml

TRUSTED_PROXIES=127.0.0.1,REMOTE_ADDR
PS_SUBNET=172.30.202.0/16
PS_GATEWAY_IP=172.30.0.1
Expand All @@ -212,7 +231,6 @@ ELK_VERSION=7.11.2

VERIFY_SSL=true

PHRASEANET_BASE_URL=https://phraseanet.${PHRASEA_DOMAIN:-"phrasea.local"}
PHRASEANET_APP_OAUTH_TOKEN=define-me

# Indexer
Expand Down
6 changes: 6 additions & 0 deletions bin/dev/debug-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

. bin/functions.sh
load-env

env
11 changes: 6 additions & 5 deletions bin/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ function load-env {
exit 1
fi

tmp="/tmp/env-$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13 ; echo '')"
tmp="/tmp/env-$(cat /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9' | head -c 13 ; echo '')"
env > "${tmp}"

export_env_from_file ".env.local"
export_env_from_file ".env"
export_env_from_file ".env.local"

eval "$(
while read -r LINE; do
if [[ $LINE =~ ^[A-Za-z0-9]+= ]] && [[ $LINE != '#'* ]]; then
if [[ $LINE =~ ^[A-Za-z0-9_]+= ]] && [[ $LINE != '#'* ]]; then
key=$(printf '%s\n' "$LINE"| sed 's/"/\\"/g' | cut -d '=' -f 1)
value=$(printf '%s\n' "$LINE" | cut -d '=' -f 2- | sed 's/"/\\\"/g')
printf '%s\n' "export $key=\"$value\""
Expand All @@ -40,13 +41,13 @@ function load-env {

# execute a shell commmand in a container defined in docker-compose.yml
function exec_container() {
docker compose exec -T "$1" sh -c "$2"
docker compose exec -T "$1" sh -c "$2"
}

function exec_container_as() {
docker compose exec -T "$1" su "$3" sh -c "$2"
docker compose exec -T "$1" su "$3" sh -c "$2"
}

function create_db() {
exec_container db "psql -U \"${POSTGRES_USER}\" -tc \"SELECT 1 FROM pg_database WHERE datname = '$1'\" | grep -q 1 || psql -U \"${POSTGRES_USER}\" -c \"CREATE DATABASE $1\""
exec_container db "psql -U \"${POSTGRES_USER}\" -tc \"SELECT 1 FROM pg_database WHERE datname = '$1'\" | grep -q 1 || psql -U \"${POSTGRES_USER}\" -c \"CREATE DATABASE $1\""
}
8 changes: 0 additions & 8 deletions bin/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ bin/create-config.sh

set -ex

export AUTH_API_BASE_URL=https://api-auth.${PHRASEA_DOMAIN}
export UPLOADER_CLIENT_BASE_URL=https://uploader.${PHRASEA_DOMAIN}
export DATABOX_CLIENT_BASE_URL=https://databox.${PHRASEA_DOMAIN}
export UPLOADER_API_BASE_URL=https://api-uploader.${PHRASEA_DOMAIN}
export DATABOX_API_BASE_URL=https://api-databox.${PHRASEA_DOMAIN}
export NOTIFY_API_BASE_URL=https://api-notify.${PHRASEA_DOMAIN}
export EXPOSE_API_BASE_URL=https://api-expose.${PHRASEA_DOMAIN}

docker compose up -d

# Wait for services to be ready
Expand Down
2 changes: 0 additions & 2 deletions configs/config.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
}
},
"expose": {
"analytics": false,
"admin": {
"logo": {
"src": "https://www.phraseanet.com/wp-content/uploads/2014/05/PICTO_PHRASEANET.png",
Expand All @@ -160,7 +159,6 @@
}
},
"databox": {
"analytics": false,
"admin": {
"logo": {
"src": "https://www.phraseanet.com/wp-content/uploads/2014/05/PICTO_PHRASEANET.png",
Expand Down
2 changes: 2 additions & 0 deletions dashboard/src/index.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ <h3>Notify</h3>
Advanced
</button>
<ul style="display:none">
<li><a target="_blank" href="${MATOMO_BASE_URL}">Matomo</a></li>
<li><a target="_blank" href="${PGADMIN_BASE_URL}">PG Admin</a></li>
<li><a target="_blank" href="${PHPMYADMIN_BASE_URL}">PHPMyAdmin</a></li>
<li><a target="_blank" href="${RABBITMQ_CONSOLE_BASE_URL}">RabbitMQ Console</a></li>
<li><a target="_blank" href="${TRAEFIK_CONSOLE_BASE_URL}">Traefik Console</a></li>
<li><a target="_blank" href="${ELASTICHQ_BASE_URL}">Elastic HQ</a></li>
<li><a target="_blank" href="${MAILHOG_BASE_URL}">MailHog</a></li>
<li><a target="_blank" href="${ZIPPY_BASE_URL}">Zippy</a></li>
<li><a target="_blank" href="${SAML_BASE_URL}">SAML IdP</a></li>
<li><a target="_blank" href="${SAML2_BASE_URL}">SAML IdP 2</a></li>
</ul>
Expand Down
5 changes: 4 additions & 1 deletion databox/api/src/External/PhraseanetApiClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

class PhraseanetApiClientFactory
{
public function __construct(private readonly array $options = [])
private array $options;

public function __construct(array $options = [])
{
$this->options = $options;
}

public function create(string $baseUri, string $oauthToken): Client
Expand Down
2 changes: 0 additions & 2 deletions databox/api/src/Integration/AbstractIntegrationAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public function evaluateIf(JobExecutionContext $context): bool
return false;
}

dump($context->getInputs()->getArrayCopy());

$config = $this->getIntegrationConfig($context);
$workspaceIntegration = $config['workspaceIntegration'];
if (null !== $if = $workspaceIntegration->getIf()) {
Expand Down
9 changes: 0 additions & 9 deletions databox/client/.env

This file was deleted.

5 changes: 5 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ services:
- SECRETS_PUBLIC_KEY=${DATABOX_SECRETS_PUBLIC_KEY}
- SECRETS_SECRET_KEY=${DATABOX_SECRETS_SECRET_KEY}
- ALLOWED_FILE_TYPES=${UPLOADER_ALLOWED_FILE_TYPES}
- MATOMO_BASE_URL
- MATOMO_SITE_ID=${EXPOSE_MATOMO_SITE_ID}
- MATOMO_AUTH_TOKEN
- PHRASEANET_APP_OAUTH_TOKEN
- PHRASEANET_BASE_URL
working_dir: /var/workspace
volumes:
- ./:/var/workspace
Expand Down
Loading

0 comments on commit 0497e2f

Please sign in to comment.