# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: websitecollection
spec:
    description: A collection of hosting website
    tags:
        - Website
        - Starter
        - Static
        - Tool
        - Monitoring
    readme: |-
        **Template Introduction: Website Collection**

        Hello fellow users! I am pleased to present to you the "Website Collection" template.This template is designed to provide you with a comprehensive set of tools and resources to kickstart your website development journey.

        **Features:**
        1. **2FA (Logto):** Enhance the security of your website by implementing two-factor authentication, ensuring only authorized users can access your platform.
        2. **Web Analytics (Umami):** Gain valuable insights into your website's performance and user behavior with the powerful web analytics tool, Umami.
        3. **WordPress:** Build and manage your website effortlessly with the popular and user-friendly WordPress content management system.
        4. **UPTIME KUMA:** Monitor the uptime and availability of your website in real-time, ensuring optimal performance and minimizing downtime.
        5. **PostgreSQL:** Leverage the power of PostgreSQL, a robust and scalable open-source database management system, to handle your website's data storage needs.

        Whether you're a beginner or an experienced developer, this template has got you covered. Start building your dream website today with this all-in-one solution! Feel free to customize and modify the template according to your specific requirements. Happy website building!
    services:
        - name: mysql-wordpress
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/mysql.svg
          template: PREBUILT
          spec:
            source:
                image: mysql:8.0.33
            ports:
                - id: database
                  port: 3306
                  type: TCP
            volumes:
                - id: data
                  dir: /var/lib/mysql
            instructions:
                - title: Command to connect to your MySQL
                  content: mysqlsh --sql --host=${PORT_FORWARDED_HOSTNAME} --port=${DATABASE_PORT_FORWARDED_PORT} --user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} --schema=${MYSQL_DATABASE}
                - title: MySQL username
                  content: ${MYSQL_USERNAME}
                - title: MySQL password
                  content: ${MYSQL_PASSWORD}
                - title: MySQL database
                  content: ${MYSQL_DATABASE}
                - title: MySQL host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: MySQL port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                MYSQL_DATABASE:
                    default: zeabur
                    expose: true
                MYSQL_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                MYSQL_PASSWORD:
                    default: ${MYSQL_ROOT_PASSWORD}
                    expose: true
                MYSQL_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                MYSQL_ROOT_PASSWORD:
                    default: ${PASSWORD}
                MYSQL_USERNAME:
                    default: root
                    expose: true
            configs:
                - path: /etc/my.cnf
                  template: |
                    [mysqld]
                    default-authentication-plugin=mysql_native_password
                    skip-host-cache
                    skip-name-resolve
                    datadir=/var/lib/mysql
                    socket=/var/run/mysqld/mysqld.sock
                    secure-file-priv=/var/lib/mysql-files
                    user=mysql
                    max_allowed_packet=10M

                    pid-file=/var/run/mysqld/mysqld.pid
                    [client]
                    socket=/var/run/mysqld/mysqld.sock

                    !includedir /etc/mysql/conf.d/
                  permission: null
                  envsubst: null
        - name: postgresql
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/postgresql.svg
          template: PREBUILT
          spec:
            source:
                image: postgres:16
                command:
                    - docker-entrypoint.sh
                    - -c
                    - config_file=/etc/postgresql/postgresql.conf
            ports:
                - id: database
                  port: 5432
                  type: TCP
            volumes:
                - id: data
                  dir: /var/lib/postgresql/data
            instructions:
                - title: Connection String
                  content: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}
                - title: PostgreSQL Connect Command
                  content: psql "postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}"
                - title: PostgreSQL username
                  content: ${POSTGRES_USERNAME}
                - title: PostgresSQL password
                  content: ${POSTGRES_PASSWORD}
                - title: PostgresSQL database
                  content: ${POSTGRES_DATABASE}
                - title: PostgreSQL host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: PostgreSQL port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                PGDATA:
                    default: /var/lib/postgresql/data/pgdata
                POSTGRES_CONNECTION_STRING:
                    default: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}
                    expose: true
                POSTGRES_DATABASE:
                    default: ${POSTGRES_DB}
                    expose: true
                POSTGRES_DB:
                    default: zeabur
                POSTGRES_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                POSTGRES_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                POSTGRES_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                POSTGRES_URI:
                    default: ${POSTGRES_CONNECTION_STRING}
                    expose: true
                POSTGRES_USER:
                    default: root
                POSTGRES_USERNAME:
                    default: ${POSTGRES_USER}
                    expose: true
            configs:
                - path: /etc/postgresql/postgresql.conf
                  template: |
                    # https://github.com/postgres/postgres/blob/master/src/backend/utils/misc/postgresql.conf.sample
                    listen_addresses = '*'
                    max_connections = 100
                    shared_buffers = 128MB
                    dynamic_shared_memory_type = posix
                    max_wal_size = 1GB
                    min_wal_size = 80MB
                    log_timezone = 'Etc/UTC'
                    datestyle = 'iso, mdy'
                    timezone = 'Etc/UTC'
                    lc_messages = 'en_US.utf8'
                    lc_monetary = 'en_US.utf8'
                    lc_numeric = 'en_US.utf8'
                    lc_time = 'en_US.utf8'
                    default_text_search_config = 'pg_catalog.english'
                  permission: null
                  envsubst: null
        - name: logto
          icon: https://dev-to-uploads.s3.amazonaws.com/uploads/organization/profile_image/6720/caee4597-8613-4fdc-902a-955dea9855b4.png
          template: PREBUILT
          spec:
            source:
                image: svhd/logto:1.15
                command:
                    - sh
                args:
                    - -c
                    - npm run cli db seed -- --swe && npm start
            ports:
                - id: web
                  port: 3001
                  type: HTTP
                - id: console
                  port: 3002
                  type: HTTP
            env:
                ADMIN_ENDPOINT:
                    default: ${ZEABUR_CONSOLE_URL}
                DB_URL:
                    default: postgres://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}
                ENDPOINT:
                    default: ${ZEABUR_WEB_URL}
                TRUST_PROXY_HEADER:
                    default: "true"
        - name: unami
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/umami.svg
          template: PREBUILT
          spec:
            source:
                image: ghcr.io/umami-software/umami:postgresql-latest
            ports:
                - id: web
                  port: 3000
                  type: HTTP
            env:
                DATABASE_TYPE:
                    default: postgresql
                DATABASE_URL:
                    default: ${POSTGRES_CONNECTION_STRING}
                HASH_SALT:
                    default: ${PASSWORD}
        - name: uptime-kuma
          icon: https://github.com/louislam/uptime-kuma/raw/master/public/icon.svg
          template: PREBUILT
          spec:
            source:
                image: louislam/uptime-kuma:1
            ports:
                - id: web
                  port: 3001
                  type: HTTP
            volumes:
                - id: data
                  dir: /app/data
        - name: wordpress
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/wordpress.png
          template: PREBUILT
          spec:
            source:
                image: wordpress:6-php8.2
                command:
                    - /bin/bash
                args:
                    - -c
                    - |-
                      echo -ne 'file_uploads = On
                      memory_limit = 10M
                      upload_max_filesize = 10M
                      post_max_size = 10M
                      max_execution_time = 120' > /usr/local/etc/php/conf.d/upload.ini && docker-entrypoint.sh apache2-foreground
            ports:
                - id: web
                  port: 80
                  type: HTTP
            volumes:
                - id: data
                  dir: /var/www/html/wp-content
            env:
                WORDPRESS_DB_HOST:
                    default: ${MYSQL_HOST}:${MYSQL_PORT}
                WORDPRESS_DB_NAME:
                    default: ${MYSQL_DATABASE}
                WORDPRESS_DB_PASSWORD:
                    default: ${MYSQL_PASSWORD}
                WORDPRESS_DB_USER:
                    default: ${MYSQL_USERNAME}
                WORDPRESS_DEBUG:
                    default: "0"
            configs:
                - path: /var/www/html/wp-config.php
                  template: "<?php\n\nif (!function_exists('getenv_docker')) {\n\tfunction getenv_docker($env, $default) {\n\t\tif ($fileEnv = getenv($env . '_FILE')) {\n\t\t\treturn rtrim(file_get_contents($fileEnv), \"\r\n\");\n\t\t}\n\t\telse if (($val = getenv($env)) !== false) {\n\t\t\treturn $val;\n\t\t}\n\t\telse {\n\t\t\treturn $default;\n\t\t}\n\t}\n}\n\ndefine( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpress') );\ndefine( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') );\ndefine( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') );\n\ndefine( 'DB_HOST', getenv_docker('WORDPRESS_DB_HOST', 'mysql') );\ndefine( 'DB_CHARSET', getenv_docker('WORDPRESS_DB_CHARSET', 'utf8') );\ndefine( 'DB_COLLATE', getenv_docker('WORDPRESS_DB_COLLATE', '') );\n\ndefine( 'AUTH_KEY',         getenv_docker('WORDPRESS_AUTH_KEY',         'b5703d7e2fff54eb27af2d5d71718418a4285d93') );\ndefine( 'SECURE_AUTH_KEY',  getenv_docker('WORDPRESS_SECURE_AUTH_KEY',  '266068c6a79054edb1549ef4e8d7ac9161d8ae22') );\ndefine( 'LOGGED_IN_KEY',    getenv_docker('WORDPRESS_LOGGED_IN_KEY',    '8d48501345a93e588fb364374d9c4e3d37ab42c6') );\ndefine( 'NONCE_KEY',        getenv_docker('WORDPRESS_NONCE_KEY',        'fa4dae194949d8530fdd337384a6dc91f1154b84') );\ndefine( 'AUTH_SALT',        getenv_docker('WORDPRESS_AUTH_SALT',        '10b42a9840a7fb7ff3d8a57275cef17451f85038') );\ndefine( 'SECURE_AUTH_SALT', getenv_docker('WORDPRESS_SECURE_AUTH_SALT', '45c7e22c7c005a39f32f9a338ae03af86f14c967') );\ndefine( 'LOGGED_IN_SALT',   getenv_docker('WORDPRESS_LOGGED_IN_SALT',   'ceda7f55fc77c0d7b8429a34f918ba7636594eb4') );\ndefine( 'NONCE_SALT',       getenv_docker('WORDPRESS_NONCE_SALT',       'e64aa6eb6b68c950b32f2e89e76581dbf6e6edd7') );\n\n$table_prefix = getenv_docker('WORDPRESS_TABLE_PREFIX', 'wp_');\n\ndefine( 'WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', '') );\n\nif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {\n\t$_SERVER['HTTPS'] = 'on';\n}\n\ndefine('FS_METHOD', 'direct');\n\nif ( ! defined( 'ABSPATH' ) ) {\n\tdefine( 'ABSPATH', __DIR__ . '/' );\n}\n\nrequire_once ABSPATH . 'wp-settings.php';\n"
                  permission: null
                  envsubst: null
