This commit is contained in:
Andras Bacsai 2022-11-29 10:35:56 +01:00
parent 55b80132c4
commit c48654160d
7 changed files with 1155 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,148 @@
- templateVersion: 1.0.0
defaultVersion: 1.5.0-rc.0
documentation: https://plausible.io/doc/
type: plausibleanalytics-arm
name: Plausible Analytics (ARM)
description: A lightweight and open-source website analytics tool.
labels:
- analytics
- statistics
- plausible
- gdpr
- no-cookie
- google analytics
services:
$$id:
name: Plausible Analytics
command: >-
sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate
&& /entrypoint.sh db init-admin && /entrypoint.sh run"
depends_on:
- $$id-postgresql
- $$id-clickhouse
image: plausible/analytics:$$core_version
environment:
- ADMIN_USER_EMAIL=$$config_admin_user_email
- ADMIN_USER_NAME=$$config_admin_user_name
- ADMIN_USER_PWD=$$secret_admin_user_pwd
- BASE_URL=$$config_base_url
- SECRET_KEY_BASE=$$secret_secret_key_base
- DISABLE_AUTH=$$config_disable_auth
- DISABLE_REGISTRATION=$$config_disable_registration
- DATABASE_URL=$$secret_database_url
- CLICKHOUSE_DATABASE_URL=$$secret_clickhouse_database_url
ports:
- "8000"
$$id-postgresql:
name: PostgreSQL
image: postgres:14-alpine
volumes:
- $$id-postgresql-data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=$$secret_postgres_password
- POSTGRES_USER=$$config_postgres_user
- POSTGRES_DB=$$config_postgres_db
$$id-clickhouse:
name: Clickhouse
volumes:
- $$id-clickhouse-data:/var/lib/clickhouse
image: clickhouse/clickhouse-server:22.6-alpine
ulimits:
nofile:
soft: 262144
hard: 262144
files:
- location: /etc/clickhouse-server/users.d/logging.xml
content: >-
<yandex><logger><level>warning</level><console>true</console></logger><query_thread_log
remove="remove"/><query_log remove="remove"/><text_log
remove="remove"/><trace_log remove="remove"/><metric_log
remove="remove"/><asynchronous_metric_log
remove="remove"/><session_log remove="remove"/><part_log
remove="remove"/></yandex>
- location: /etc/clickhouse-server/config.d/logging.xml
content: >-
<yandex><profiles><default><log_queries>0</log_queries><log_query_threads>0</log_query_threads></default></profiles></yandex>
- location: /docker-entrypoint-initdb.d/init.query
content: CREATE DATABASE IF NOT EXISTS plausible;
- location: /docker-entrypoint-initdb.d/init-db.sh
content: >-
clickhouse client --queries-file
/docker-entrypoint-initdb.d/init.query
variables:
- id: $$config_base_url
name: BASE_URL
label: Base URL
defaultValue: $$generate_fqdn
description: >-
You must set this to the FQDN of the Plausible Analytics instance. This is
used to generate the links to the Plausible Analytics instance.
- id: $$secret_database_url
name: DATABASE_URL
label: Database URL for PostgreSQL
defaultValue: >-
postgresql://$$config_postgres_user:$$secret_postgres_password@$$id-postgresql:5432/$$config_postgres_db
description: ""
- id: $$secret_clickhouse_database_url
name: CLICKHOUSE_DATABASE_URL
label: Database URL for Clickhouse
defaultValue: http://$$id-clickhouse:8123/plausible
description: ""
- id: $$config_admin_user_email
name: ADMIN_USER_EMAIL
label: Admin Email Address
defaultValue: admin@example.com
description: This is the admin email. Please change it.
- id: $$config_admin_user_name
name: ADMIN_USER_NAME
label: Admin User Name
defaultValue: $$generate_username
description: This is the admin username. Please change it.
- id: $$secret_admin_user_pwd
name: ADMIN_USER_PWD
label: Admin User Password
defaultValue: $$generate_password
description: This is the admin password. Please change it.
showOnConfiguration: true
- id: $$secret_secret_key_base
name: SECRET_KEY_BASE
label: Secret Key Base
defaultValue: $$generate_hex(64)
description: ""
- id: $$config_disable_auth
name: DISABLE_AUTH
label: Disable Authentication
defaultValue: "false"
description: ""
- id: $$config_disable_registration
name: DISABLE_REGISTRATION
label: Disable Registration
defaultValue: "true"
description: ""
- id: $$config_postgres_user
main: $$id-postgresql
name: POSTGRES_USER
label: PostgreSQL Username
defaultValue: postgresql
description: ""
- id: $$secret_postgres_password
main: $$id-postgresql
name: POSTGRES_PASSWORD
label: PostgreSQL Password
defaultValue: $$generate_password
description: ""
showOnConfiguration: true
- id: $$config_postgres_db
main: $$id-postgresql
name: POSTGRES_DB
label: PostgreSQL Database
defaultValue: plausible
description: ""
- id: $$config_scriptName
name: SCRIPT_NAME
label: Custom Script Name
defaultValue: plausible.js
description: This is the default script name.
- templateVersion: 1.0.0
defaultVersion: "1.17"
documentation: https://docs.gitea.io
@ -2317,6 +2462,7 @@
ignore: true
defaultVersion: latest
documentation: https://docs.ghost.org
arch: amd64
type: ghost-mariadb
name: Ghost
subname: (MariaDB)
@ -2979,6 +3125,7 @@
- templateVersion: 1.0.0
defaultVersion: stable
documentation: https://plausible.io/doc/
arch: amd64
type: plausibleanalytics
name: Plausible Analytics
description: A lightweight and open-source website analytics tool.
@ -3013,7 +3160,7 @@
- "8000"
$$id-postgresql:
name: PostgreSQL
image: "bitnami/postgresql:13.2.0"
image: "bitnami/postgresql:14"
volumes:
- "$$id-postgresql-data:/bitnami/postgresql"
environment:
@ -3024,7 +3171,7 @@
name: Clickhouse
volumes:
- "$$id-clickhouse-data:/var/lib/clickhouse"
image: "yandex/clickhouse-server:21.3.2.5"
image: "clickhouse/clickhouse-server:22.6-alpine"
ulimits:
nofile:
soft: 262144

View File

@ -1492,7 +1492,7 @@ export function errorHandler({
message: string | any;
}) {
if (message.message) message = message.message;
Sentry.captureException({ status, message });
Sentry.captureException(message);
throw { status, message };
}
export async function generateSshKeyPair(): Promise<{ publicKey: string; privateKey: string }> {

View File

@ -1,12 +1,15 @@
import { isDev } from "./common";
import { isARM, isDev } from "./common";
import fs from 'fs/promises';
export async function getTemplates() {
const templatePath = isDev ? './templates.json' : '/app/templates.json';
const open = await fs.open(templatePath, 'r');
let data;
try {
data = await open.readFile({ encoding: 'utf-8' });
return JSON.parse(data);
let data = await open.readFile({ encoding: 'utf-8' });
let jsonData = JSON.parse(data)
if (isARM(process.arch)) {
jsonData = jsonData.filter(d => d.arch !== 'amd64')
}
return jsonData;
} catch (error) {
return []
} finally {

View File

@ -239,13 +239,13 @@ export async function parseAndFindServiceTemplates(service: any, workdir?: strin
if (value === '$$generate_fqdn') {
strParsedTemplate = strParsedTemplate.replaceAll(regex, service.fqdn + '"' || '' + '"')
} else if (value === '$$generate_fqdn_slash') {
strParsedTemplate = strParsedTemplate.replaceAll(regex, service.fqdn + '/' + '"')
strParsedTemplate = strParsedTemplate.replaceAll(regex, service.fqdn + '/' + '"')
} else if (value === '$$generate_domain') {
strParsedTemplate = strParsedTemplate.replaceAll(regex, getDomain(service.fqdn) + '"')
} else if (service.destinationDocker?.network && value === '$$generate_network') {
strParsedTemplate = strParsedTemplate.replaceAll(regex, service.destinationDocker.network + '"')
strParsedTemplate = strParsedTemplate.replaceAll(regex, service.destinationDocker.network + '"')
} else {
strParsedTemplate = strParsedTemplate.replaceAll(regex, value + '"')
strParsedTemplate = strParsedTemplate.replaceAll(regex, value + '"')
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long