static-website-from-folder

Description

This is under development, for now only 'nginx' is supported.

Resources

Variables

Name Type Default Description

gzip_enabled

boolean True

Whether to enable gzip (only supported for nginx for now).

hostname

string localhost

The domain name the webserver should listen on.

index

list ['index.html', 'index.htm']

The index file name(s).

letsencrypt_staging

boolean False

Whether to use the letsencrypt staging server (for developing -- production only allows a few requests per day).

path

string /var/www/html

The document root.

server_admin

string --

The server admin email.

skip_cert_request

boolean False

Useful if the https certificate(s) is/are already set up.

use_https

boolean False

Whether to use https (and request a letsencrypt certificate).

webserver

string nginx

The webserver type.

webserver_user

string --

The webserver user.

Code

doc:
  short_help: Install and configure webserver for static site.
  help: |
    This is under development, for now only 'nginx' is supported.

  references:
    blog post: https://medium.com/@jgefroh/a-guide-to-using-nginx-for-static-websites-d96a9d034940

args:
  hostname:
    doc:
      short_help: The domain name the webserver should listen on.
    type: string
    required: false
    default: localhost
  use_https:
    doc:
      short_help: Whether to use https (and request a letsencrypt certificate).
    type: boolean
    required: false
    default: false
  path:
    doc:
      short_help: The document root.
    type: string
    required: false
    default: /var/www/html
  webserver_user:
    doc:
      short_help: The webserver user.
    type: string
    required: false
  gzip_enabled:
    doc:
      short_help: Whether to enable gzip (only supported for nginx for now).
    type: boolean
    required: false
    default: true
    cli:
      param_decls:
      - --gzip-enabled/--gzip-disabled
  index:
    doc:
      short_help: The index file name(s).
    type: list
    schema:
      type: string
    default:
    - index.html
    - index.htm
    required: false
    cli:
      metavar: FILENAME
      show_default: true
  letsencrypt_staging:
    doc:
      short_help: Whether to use the letsencrypt staging server (for developing --
        production only allows a few requests per day).
    type: boolean
    required: false
    default: false
    cli:
      is_flag: true
  server_admin:
    doc:
      short_help: The server admin email.
    type: string
    required: false
    cli:
      metavar: EMAIL
  skip_cert_request:
    doc:
      short_help: Skip letsencrypt certificate request.
      help: |
        Useful if the https certificate(s) is/are already set up.
    type: boolean
    default: false
    required: false
  webserver:
    doc:
      short_help: The webserver type.
    type: string
    allowed:
    - nginx
    - apache
    default: nginx

frecklets:
- nginx-vhost-from-folder:
    frecklet::skip: "{{:: webserver | false_if_equal('nginx') ::}}"
    hostname: '{{:: hostname ::}}'
    use_https: '{{:: use_https ::}}'
    document_root: '{{:: path ::}}'
    gzip_enabled: '{{:: gzip_enabled ::}}'
    index: '{{:: index ::}}'
    server_admin: '{{:: server_admin ::}}'
- apache-vhost-from-folder:
    frecklet::skip: "{{:: webserver | false_if_equal('apache') ::}}"
    hostname: '{{:: hostname ::}}'
    use_https: '{{:: use_https ::}}'
    document_root: '{{:: path ::}}'
    server_admin: '{{:: server_admin ::}}'
    index: '{{:: index ::}}'
- webserver-service:
    webserver: '{{:: webserver ::}}'
    letsencrypt_webroot: '{{:: path ::}}'
    use_https: '{{:: use_https ::}}'
    skip_cert_request: '{{:: skip_cert_request ::}}'
    letsencrypt_email: '{{:: server_admin ::}}'
    letsencrypt_staging: '{{:: letsencrypt_staging ::}}'
    letsencrypt_domains:
    - '{{:: hostname ::}}'
    webserver_user: '{{:: webserver_user ::}}'
frecklecute static-website-from-folder --help

Usage: frecklecute static-website-from-folder [OPTIONS]

  This is under development, for now only 'nginx' is supported.

Options:
  --gzip-enabled / --gzip-disabled
                                  Whether to enable gzip (only supported for
                                  nginx for now).
  --hostname HOSTNAME             The domain name the webserver should listen
                                  on.
  --index FILENAME                The index file name(s).
  --letsencrypt-staging / --no-letsencrypt-staging
                                  Whether to use the letsencrypt staging
                                  server (for developing -- production only
                                  allows a few requests per day).
  --path PATH                     The document root.
  --server-admin EMAIL            The server admin email.
  --skip-cert-request / --no-skip-cert-request
                                  Skip letsencrypt certificate request.
  --use-https / --no-use-https    Whether to use https (and request a
                                  letsencrypt certificate).
  --webserver WEBSERVER           The webserver type.
  --webserver-user WEBSERVER_USER
                                  The webserver user.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.static_website_from_folder.StaticWebsiteFromFolder
#


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

@dataclass
class StaticWebsiteFromFolder(AutoPycklet):
    """This is under development, for now only 'nginx' is supported.

       Args:
         gzip_enabled: Whether to enable gzip (only supported for nginx for now).
         hostname: The domain name the webserver should listen on.
         index: The index file name(s).
         letsencrypt_staging: Whether to use the letsencrypt staging server (for developing -- production only allows a few requests per day).
         path: The document root.
         server_admin: The server admin email.
         skip_cert_request: Skip letsencrypt certificate request.
         use_https: Whether to use https (and request a letsencrypt certificate).
         webserver: The webserver type.
         webserver_user: The webserver user.

    """

    FRECKLET_ID = "static-website-from-folder"

    gzip_enabled: bool = None
    hostname: str = None
    index: List = None
    letsencrypt_staging: bool = None
    path: str = None
    server_admin: str = None
    skip_cert_request: bool = None
    use_https: bool = None
    webserver: str = None
    webserver_user: str = None


    def __post_init__(self):
        super(StaticWebsiteFromFolder, self).__init__(var_names=["gzip_enabled", "hostname", "index", "letsencrypt_staging", "path", "server_admin", "skip_cert_request", "use_https", "webserver", "webserver_user"])


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


#
# module path: pycklets.static_website_from_folder.StaticWebsiteFromFolder
#


from pyckles import AutoPycklet

class StaticWebsiteFromFolder(AutoPycklet):
    """This is under development, for now only 'nginx' is supported.

       Args:
         gzip_enabled: Whether to enable gzip (only supported for nginx for now).
         hostname: The domain name the webserver should listen on.
         index: The index file name(s).
         letsencrypt_staging: Whether to use the letsencrypt staging server (for developing -- production only allows a few requests per day).
         path: The document root.
         server_admin: The server admin email.
         skip_cert_request: Skip letsencrypt certificate request.
         use_https: Whether to use https (and request a letsencrypt certificate).
         webserver: The webserver type.
         webserver_user: The webserver user.

    """

    FRECKLET_ID = "static-website-from-folder"

    def __init__(self, gzip_enabled=True, hostname="localhost", index=['index.html', 'index.htm'], letsencrypt_staging=None, path="/var/www/html", server_admin=None, skip_cert_request=None, use_https=None, webserver="nginx", webserver_user=None):

        super(StaticWebsiteFromFolder, self).__init__(var_names=["gzip_enabled", "hostname", "index", "letsencrypt_staging", "path", "server_admin", "skip_cert_request", "use_https", "webserver", "webserver_user"])
        self._gzip_enabled = gzip_enabled
        self._hostname = hostname
        self._index = index
        self._letsencrypt_staging = letsencrypt_staging
        self._path = path
        self._server_admin = server_admin
        self._skip_cert_request = skip_cert_request
        self._use_https = use_https
        self._webserver = webserver
        self._webserver_user = webserver_user

    @property
    def gzip_enabled(self):
        return self._gzip_enabled

    @gzip_enabled.setter
    def gzip_enabled(self, gzip_enabled):
        self._gzip_enabled = gzip_enabled

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

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

    @property
    def index(self):
        return self._index

    @index.setter
    def index(self, index):
        self._index = index

    @property
    def letsencrypt_staging(self):
        return self._letsencrypt_staging

    @letsencrypt_staging.setter
    def letsencrypt_staging(self, letsencrypt_staging):
        self._letsencrypt_staging = letsencrypt_staging

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

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

    @property
    def server_admin(self):
        return self._server_admin

    @server_admin.setter
    def server_admin(self, server_admin):
        self._server_admin = server_admin

    @property
    def skip_cert_request(self):
        return self._skip_cert_request

    @skip_cert_request.setter
    def skip_cert_request(self, skip_cert_request):
        self._skip_cert_request = skip_cert_request

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

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

    @property
    def webserver(self):
        return self._webserver

    @webserver.setter
    def webserver(self, webserver):
        self._webserver = webserver

    @property
    def webserver_user(self):
        return self._webserver_user

    @webserver_user.setter
    def webserver_user(self, webserver_user):
        self._webserver_user = webserver_user



frecklet_class = StaticWebsiteFromFolder