discourse-config-file

Description

n/a

Variables

Name Type Default Description

admin_emails

list --

The first email will also be set as the letsencrypt contact email. Required

discourse_smtp_address

string --

The SMTP server address. Required

discourse_smtp_password

string --

The SMTP password. Required

discourse_smtp_port

integer --

The SMTP port. Required

discourse_smtp_user_name

string --

The SMTP user name. Required

hostname

string --

The discourse hostname. Required

path

string --

The path to the file. Required

discourse_plugins

list []

A list of discourse plugin urls.

discourse_smtp_enable_start_tls

boolean True

Whether to use START_TLS when connecting to the SMTP server.

discourse_version

string stable

The version of discourse.

group

string --

The group of the file.

mode

string --

The permissions of the file.

owner

string --

The owner of the file.

set_from_email

string --

This only needs to be set/run once, at install time. Needs to be an address that is supported by your smtp settings.

use_https

boolean True

Whether to use https with letsencrypt.

Code

args:
  use_https:
    doc:
      short_help: Whether to use https with letsencrypt.
    type: boolean
    default: true
  cli:
    param_decls: --use-https/--no-use-https
  hostname:
    doc:
      short_help: The discourse hostname.
    type: string
    required: true
  admin_emails:
    doc:
      short_help: A list of email addresses that will be admins after install.
      help: |
        The first email will also be set as the letsencrypt contact email.
    required: true
    type: list
    schema:
      type: string
    empty: false
    cli:
      param_decls:
      - --admin-email
      metavar: EMAIL
  discourse_version:
    doc:
      short_help: The version of discourse.
    type: string
    default: stable
    required: false
  discourse_smtp_address:
    doc:
      short_help: The SMTP server address.
    type: string
    required: true
  discourse_smtp_port:
    doc:
      short_help: The SMTP port.
    type: integer
    required: true
  discourse_smtp_user_name:
    doc:
      short_help: The SMTP user name.
    type: string
    required: true
    # might be the same token as password, that's why it's secret
    secret: true
  discourse_smtp_password:
    doc:
      short_help: The SMTP password.
    type: string
    required: true
    secret: true
  discourse_smtp_enable_start_tls:
    doc:
      short_help: Whether to use START_TLS when connecting to the SMTP server.
    type: boolean
    default: true
    required: true
    cli:
      param_decls:
      - --start-tls/--no-start-tls
  set_from_email:
    doc:
      short_help: A custom 'from' email address (e.g. noreply@example.com).
      help: |
        This only needs to be set/run once, at install time. Needs to be an address that is supported by your smtp settings.
    type: string
    required: false
  discourse_plugins:
    doc:
      short_help: A list of discourse plugin urls.
    type: list
    schema:
      type: string
    required: false
    default: []
    empty: true
    cli:
      metavar: PLUGIN
      show_default: true
  _import:
  - file-with-content
frecklets:
- file-with-content:
    path: '{{:: path ::}}'
    group: '{{:: group ::}}'
    owner: '{{:: owner ::}}'
    mode: '{{:: mode ::}}'
    content: |-
      ## this is the all-in-one, standalone Discourse Docker container template
      ##
      ## After making changes to this file, you MUST rebuild
      ## /var/discourse/launcher rebuild app
      ##
      ## BE *VERY* CAREFUL WHEN EDITING!
      ## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
      ## visit http://www.yamllint.com/ to validate this file as needed

      templates:
        - "templates/postgres.template.yml"
        - "templates/redis.template.yml"
        - "templates/web.template.yml"
        - "templates/web.ratelimited.template.yml"
      ## Uncomment these two lines if you wish to add Lets Encrypt (https)
      {%:: if use_https ::%}
        - "templates/web.ssl.template.yml"
        - "templates/web.letsencrypt.ssl.template.yml"
      {%:: endif ::%}

      ## which TCP/IP ports should this container expose?
      ## If you want Discourse to share a port with another webserver like Apache or nginx,
      ## see https://meta.discourse.org/t/17247 for details
      expose:
        - "80:80"   # http
        - "443:443" # https

      params:
        db_default_text_search_config: "pg_catalog.english"

        ## Set db_shared_buffers to a max of 25% of the total memory.
        ## will be set automatically by bootstrap based on detected RAM, or you can override
        db_shared_buffers: "256MB"

        ## can improve sorting performance, but adds memory usage per-connection
        #db_work_mem: "40MB"

        ## Which Git revision should this container use? (default: tests-passed)
        version: "{{:: discourse_version ::}}"

      env:
        LANG: en_US.UTF-8
        # DISCOURSE_DEFAULT_LOCALE: en

        ## How many concurrent web requests are supported? Depends on memory and CPU cores.
        ## will be set automatically by bootstrap based on detected CPUs, or you can override
        UNICORN_WORKERS: 4

        ## TODO: The domain name this Discourse instance will respond to
        ## Required. Discourse will not work with a bare IP number.
        DISCOURSE_HOSTNAME: "{{:: hostname ::}}"

        ## Uncomment if you want the container to be started with the same
        ## hostname (-h option) as specified above (default "$hostname-$config")
        #DOCKER_USE_HOSTNAME: true

        ## TODO: List of comma delimited emails that will be made admin and developer
        ## on initial signup example 'user1@example.com,user2@example.com'
        DISCOURSE_DEVELOPER_EMAILS: {{:: admin_emails | join(',') ::}}

        ## TODO: The SMTP mail server used to validate new accounts and send notifications
        # SMTP ADDRESS, username, and password are required
        # WARNING the char '#' in SMTP password can cause problems!
        DISCOURSE_SMTP_ADDRESS: "{{:: discourse_smtp_address ::}}"
        DISCOURSE_SMTP_PORT: {{:: discourse_smtp_port ::}}
        DISCOURSE_SMTP_USER_NAME: "{{:: discourse_smtp_user_name ::}}"
        DISCOURSE_SMTP_PASSWORD: "{{:: discourse_smtp_password ::}}"
        DISCOURSE_SMTP_ENABLE_START_TLS: {{:: discourse_smtp_enable_start_tls | string_for_boolean("true", "false") ::}}           # (optional, default true)

        ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
        {%:: if use_https ::%}
        LETSENCRYPT_ACCOUNT_EMAIL: {{:: admin_emails[0] ::}}
        {%:: endif ::%}
        ## The CDN address for this Discourse instance (configured to pull)
        ## see https://meta.discourse.org/t/14857 for details
        #DISCOURSE_CDN_URL: //discourse-cdn.example.com

      ## The Docker container is stateless; all data is stored in /shared
      volumes:
        - volume:
            host: /var/discourse/shared/standalone
            guest: /shared
        - volume:
            host: /var/discourse/shared/standalone/log/var-log
            guest: /var/log

      ## Plugins go here
      ## see https://meta.discourse.org/t/19157 for details
      hooks:
        after_code:
          - exec:
              cd: $home/plugins
              cmd:{%:: for plugin in discourse_plugins ::%}
                - git clone {{:: plugin ::}}{%:: endfor ::%}



      ## Any custom commands to run after building
      run:
        - exec: echo "Beginning of custom commands"
        ## If you want to set the 'From' email address for your first registration, uncomment and change:
        ## After getting the first signup email, re-comment the line. It only needs to run once.
        {%:: if set_from_email ::%}
        - exec: rails r "SiteSetting.notification_email='{{:: set_from_email ::}}'"
        {%:: endif ::%}
        - exec: echo "End of custom commands"
frecklecute discourse-config-file --help

Usage: frecklecute discourse-config-file [OPTIONS] PATH

  n/a

Options:
  --admin-email EMAIL             A list of email addresses that will be
                                  admins after install.  [required]
  --discourse-smtp-address DISCOURSE_SMTP_ADDRESS
                                  The SMTP server address.  [required]
  --discourse-smtp-password DISCOURSE_SMTP_PASSWORD
                                  The SMTP password.  [required]
  --discourse-smtp-port DISCOURSE_SMTP_PORT
                                  The SMTP port.  [required]
  --discourse-smtp-user-name DISCOURSE_SMTP_USER_NAME
                                  The SMTP user name.  [required]
  --hostname HOSTNAME             The discourse hostname.  [required]
  --discourse-plugins PLUGIN      A list of discourse plugin urls.
  --start-tls / --no-start-tls    Whether to use START_TLS when connecting to
                                  the SMTP server.
  --discourse-version DISCOURSE_VERSION
                                  The version of discourse.
  --group GROUP                   The group of the file.
  --mode MODE                     The permissions of the file.
  --owner USER                    The owner of the file.
  --set-from-email SET_FROM_EMAIL
                                  A custom 'from' email address (e.g.
                                  noreply@example.com).
  --use-https / --no-use-https    Whether to use https with letsencrypt.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.discourse_config_file.DiscourseConfigFile
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class DiscourseConfigFile(AutoPycklet):
    """No documentation available.

       Args:
         admin_emails: A list of email addresses that will be admins after install.
         discourse_plugins: A list of discourse plugin urls.
         discourse_smtp_address: The SMTP server address.
         discourse_smtp_enable_start_tls: Whether to use START_TLS when connecting to the SMTP server.
         discourse_smtp_password: The SMTP password.
         discourse_smtp_port: The SMTP port.
         discourse_smtp_user_name: The SMTP user name.
         discourse_version: The version of discourse.
         group: The group of the file.
         hostname: The discourse hostname.
         mode: The permissions of the file.
         owner: The owner of the file.
         path: The path to the file.
         set_from_email: A custom 'from' email address (e.g. noreply@example.com).
         use_https: Whether to use https with letsencrypt.

    """

    FRECKLET_ID = "discourse-config-file"

    admin_emails: List = None
    discourse_plugins: List = None
    discourse_smtp_address: str = None
    discourse_smtp_enable_start_tls: bool = None
    discourse_smtp_password: str = None
    discourse_smtp_port: int = None
    discourse_smtp_user_name: str = None
    discourse_version: str = None
    group: str = None
    hostname: str = None
    mode: str = None
    owner: str = None
    path: str = None
    set_from_email: str = None
    use_https: bool = None


    def __post_init__(self):
        super(DiscourseConfigFile, self).__init__(var_names=["admin_emails", "discourse_plugins", "discourse_smtp_address", "discourse_smtp_enable_start_tls", "discourse_smtp_password", "discourse_smtp_port", "discourse_smtp_user_name", "discourse_version", "group", "hostname", "mode", "owner", "path", "set_from_email", "use_https"])


frecklet_class = DiscourseConfigFile
# -*- coding: utf-8 -*-


#
# module path: pycklets.discourse_config_file.DiscourseConfigFile
#


from pyckles import AutoPycklet

class DiscourseConfigFile(AutoPycklet):
    """No documentation available.

       Args:
         admin_emails: A list of email addresses that will be admins after install.
         discourse_plugins: A list of discourse plugin urls.
         discourse_smtp_address: The SMTP server address.
         discourse_smtp_enable_start_tls: Whether to use START_TLS when connecting to the SMTP server.
         discourse_smtp_password: The SMTP password.
         discourse_smtp_port: The SMTP port.
         discourse_smtp_user_name: The SMTP user name.
         discourse_version: The version of discourse.
         group: The group of the file.
         hostname: The discourse hostname.
         mode: The permissions of the file.
         owner: The owner of the file.
         path: The path to the file.
         set_from_email: A custom 'from' email address (e.g. noreply@example.com).
         use_https: Whether to use https with letsencrypt.

    """

    FRECKLET_ID = "discourse-config-file"

    def __init__(self, admin_emails=None, discourse_plugins=None, discourse_smtp_address=None, discourse_smtp_enable_start_tls=True, discourse_smtp_password=None, discourse_smtp_port=None, discourse_smtp_user_name=None, discourse_version="stable", group=None, hostname=None, mode=None, owner=None, path=None, set_from_email=None, use_https=True):

        super(DiscourseConfigFile, self).__init__(var_names=["admin_emails", "discourse_plugins", "discourse_smtp_address", "discourse_smtp_enable_start_tls", "discourse_smtp_password", "discourse_smtp_port", "discourse_smtp_user_name", "discourse_version", "group", "hostname", "mode", "owner", "path", "set_from_email", "use_https"])
        self._admin_emails = admin_emails
        self._discourse_plugins = discourse_plugins
        self._discourse_smtp_address = discourse_smtp_address
        self._discourse_smtp_enable_start_tls = discourse_smtp_enable_start_tls
        self._discourse_smtp_password = discourse_smtp_password
        self._discourse_smtp_port = discourse_smtp_port
        self._discourse_smtp_user_name = discourse_smtp_user_name
        self._discourse_version = discourse_version
        self._group = group
        self._hostname = hostname
        self._mode = mode
        self._owner = owner
        self._path = path
        self._set_from_email = set_from_email
        self._use_https = use_https

    @property
    def admin_emails(self):
        return self._admin_emails

    @admin_emails.setter
    def admin_emails(self, admin_emails):
        self._admin_emails = admin_emails

    @property
    def discourse_plugins(self):
        return self._discourse_plugins

    @discourse_plugins.setter
    def discourse_plugins(self, discourse_plugins):
        self._discourse_plugins = discourse_plugins

    @property
    def discourse_smtp_address(self):
        return self._discourse_smtp_address

    @discourse_smtp_address.setter
    def discourse_smtp_address(self, discourse_smtp_address):
        self._discourse_smtp_address = discourse_smtp_address

    @property
    def discourse_smtp_enable_start_tls(self):
        return self._discourse_smtp_enable_start_tls

    @discourse_smtp_enable_start_tls.setter
    def discourse_smtp_enable_start_tls(self, discourse_smtp_enable_start_tls):
        self._discourse_smtp_enable_start_tls = discourse_smtp_enable_start_tls

    @property
    def discourse_smtp_password(self):
        return self._discourse_smtp_password

    @discourse_smtp_password.setter
    def discourse_smtp_password(self, discourse_smtp_password):
        self._discourse_smtp_password = discourse_smtp_password

    @property
    def discourse_smtp_port(self):
        return self._discourse_smtp_port

    @discourse_smtp_port.setter
    def discourse_smtp_port(self, discourse_smtp_port):
        self._discourse_smtp_port = discourse_smtp_port

    @property
    def discourse_smtp_user_name(self):
        return self._discourse_smtp_user_name

    @discourse_smtp_user_name.setter
    def discourse_smtp_user_name(self, discourse_smtp_user_name):
        self._discourse_smtp_user_name = discourse_smtp_user_name

    @property
    def discourse_version(self):
        return self._discourse_version

    @discourse_version.setter
    def discourse_version(self, discourse_version):
        self._discourse_version = discourse_version

    @property
    def group(self):
        return self._group

    @group.setter
    def group(self, group):
        self._group = group

    @property
    def hostname(self):
        return self._hostname

    @hostname.setter
    def hostname(self, hostname):
        self._hostname = hostname

    @property
    def mode(self):
        return self._mode

    @mode.setter
    def mode(self, mode):
        self._mode = mode

    @property
    def owner(self):
        return self._owner

    @owner.setter
    def owner(self, owner):
        self._owner = owner

    @property
    def path(self):
        return self._path

    @path.setter
    def path(self, path):
        self._path = path

    @property
    def set_from_email(self):
        return self._set_from_email

    @set_from_email.setter
    def set_from_email(self, set_from_email):
        self._set_from_email = set_from_email

    @property
    def use_https(self):
        return self._use_https

    @use_https.setter
    def use_https(self, use_https):
        self._use_https = use_https



frecklet_class = DiscourseConfigFile