Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

This is just a start #1

Merged
merged 3 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: PreBuild

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- name: install
run: yarn install
- name: lint
run: yarn lint
- name: build
run: yarn build
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# dependencies
node_modules
yarn-error.log
.cache/
.DS_Store

# build directory
public/
/.idea/
5 changes: 5 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"pre-commit": ["lint-staged"]
}
}
5 changes: 5 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"*.{js,ts,tsx}": ["tslint -p tsconfig.json --fix ", "git add"],
"*.scss": ["prettier --write", "stylelint --fix", "git add"],
"{*.{json,md}}": ["prettier --write", "git add"]
}
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"tabWidth": 2,
"printWidth": 140,
"singleQuote": true,
"trailingComma": "none"
}
15 changes: 15 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"rules": {
"selector-class-pattern": "^[0-9a-z\\-]+$",
"block-opening-brace-space-before": "always",
"rule-empty-line-before": [
"always",
{
"except": ["after-single-line-comment", "first-nested"]
}
],
"order/properties-alphabetical-order": true
},
"extends": ["stylelint-config-recommended-scss", "stylelint-config-css-modules", "stylelint-config-prettier"],
"plugins": ["stylelint-order"]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 gatsbyjs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# Exoframe Website
# Exoframe Documentation Website

<img alt="Exoframe" src="https://github.com/exoframejs/exoframe/raw/master/logo/png/exo_blue.png" width="300">

## License

Licensed under MIT.

### Deploy to Netlify

[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/exoframejs/exoframe-website)
155 changes: 155 additions & 0 deletions contents/Advanced.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
path: '/docs/advanced'
date: '2020-05-17T10:10:00Z'
title: 'Advanced topics'
categories: ['exoframe']
tags: ['exoframe', 'traefik']
excerpt: 'Since Traefik supports routing requests to specific path, you can also do that with Exoframe.'
---

## Routing requests to specific path

Since Traefik supports routing requests to specific path, you can also do that with Exoframe.
By default, Exoframe generates the following frontend string:

```js
// where config is project config json
Labels[`traefik.http.routers.${name}.rule`] = config.domain.includes('Host(')
? // if string already contains Host() - use it as is
config.domain
: // otherwise - wrap it into Host()
`Host(\`${config.domain}\`)`;
```

You can route requests to path instead by using Traefik [router rules](https://docs.traefik.io/routing/routers/#rule) and using them inside of `domain` field in config.
For example, you can route requests from `http://bots.domain.com/myhook` to your service.
To achieve this, you will need to simply set `domain` field in the config file to `` Host(`bots.domain.com`) && Path(`/myhook`) ``.
This will route all requests from `bots.domain.com/myhook` to `your.service.host/myhook`.

If you need to strip or replace path, you have to provide additional label for Traefik.
E.g. the following config will route `domain.com/myprefix` to `your.service.host`:

```json
{
"domain": "Host(`domain.com`) && Path(`/myprefix`)",
"labels": {
"traefik.http.middlewares.test-stripprefix.stripprefix.prefixes": "/myprefix"
}
}
```

For more info and options see the aforementioned Traefik [router rules](https://docs.traefik.io/routing/routers/#rule) as well as [middlewares](https://docs.traefik.io/middlewares/overview/) docs.

## Docker-compose based deployment

Deploying using docker compose works almost the same as using a normal docker compose file, but there are a few labels you should use to ensure Traefik can correctly access your application.

version: '2'
services:
web:
build: .
labels:
traefik.http.routers.web.rule: 'Host(`test.dev`)'
redis:
image: "redis:alpine"

Any of the [configuration options](https://docs.traefik.io/reference/dynamic-configuration/docker/) for the default Traefik docker setup can be used.

If you have a docker-compose.yml file, **any domain set in exoframe.json will be ignored**.

For the most part, Exoframe doesn't pass anything from `exoframe.json` to the compose.
However, one thing that is being passed is environmental variables.
You can use any variables defined in `exoframe.json` in your compose file.
First, define them in your `exoframe.json`:

```json
{
"name": "test-compose-deploy",
"env": {
"CUSTOM_LABEL": "custom-value",
"CUSTOM_SECRET": "@test-secret"
}
}
```

Then use them inside your `docker-compose.yml`:

version: '2'
services:
web:
build: .
labels:
traefik.http.routers.web.rule: 'Host(`test.dev`)'
custom.envvar: "${CUSTOM_LABEL}"
custom.secret: "${CUSTOM_SECRET}"
redis:
image: "redis:alpine"

## Rate limiting

Exoframe allows you to enable basic IP-based rate-limiting integrated into Traefik.
To do that, simply specify the following fields in the project config file:

```js
{
// adding this object will enable IP-based rate-limiting
"rate-limit": {
// average request rate over given time period
// defaults to 1 if not specified
"average": 5,
// maximal burst request rate over given time period
// defaults to 5 if not specified
"burst": 10
}
}
```

This will define how many requests (`average`) over given time (`period`) can be performed from one IP address.
For the example above - an average of 5 requests every second is allowed with busts of up to 10 requests.

For more information, see [Traefik rate-limiting docs](https://docs.traefik.io/middlewares/ratelimit/).

## Secrets

Exoframe allows you to create server-side secret values that can be used during service deployments.
To use secrets you first need to create one. This can be done by running:

```bash
$ exoframe secret new
```

Once you specify the name and value, Exoframe server will create new secret _for your current user_.
After creation the secret can be used in `exoframe.json` config file by using secret name and prefixing it with `@`, like so (in this example the secret was name `my-secret`):

```json
"env": {
"SECRET_KEY": "@my-secret"
},
```

Current caveats:

- Currently secrets only work for environment variables
- Currently secrets work only for normal deployments (any template or recipe that uses `startFromParams` won't have secrets expanded)

## Accessing Exoframe data from within the deployed application

Exoframe provides a set of environment variables that are set on each deployment to allow getting project info and settings.
Currently those are:

```bash
# owner of current deployment
EXOFRAME_USER=admin
# project of current deployment
EXOFRAME_PROJECT=projectName
# full deployment ID
EXOFRAME_DEPLOYMENT=exo-admin-deployName-ID
# host used to expose current deployment (if any)
EXOFRAME_HOST=exo-admin-deployName-ID.baseDomain
```

## Plugins

Exoframe-Server supports extension of core features using plugins.
Plugins are installed and loaded automatically once corresponding config is added to [server configuration](server-configuration).
Refer to specific plugins docs to see how to configure them.
Loading