GithubHelp home page GithubHelp logo

brightsky-infrastructure's Introduction

Bright Sky - Infrastructure

Stackable Docker Compose configurations to set up your own instance of Bright Sky.

This is the exact configuration used for the public Bright Sky instance at https://api.brightsky.dev/, which runs on a Hetzner CPX31 VPS, usually not using more than 4 GB of the available 8 GB of memory, and occupying about 40 GB of disk space for all weather records starting January 1, 2010. The smaller CX31 VPS worked well for handling about half a million requests per day with an average response time near 30 ms, and only needed to be replaced with the CPX31 when we hit a million requests per day.

Setup instructions

You will need a machine with Docker Engine and Docker Compose installed. Then, copy or clone this repository to your machine, e.g.:

$ git clone https://github.com/jdemaeyer/brightsky-infrastructure.git brightsky
$ cd brightsky

If you are not interested in historical data past a certain date, now is a good time to configure it. Add a file brightsky.env with the following content:

BRIGHTSKY_MIN_DATE=2020-01-01

The next steps depend on how public you want your Bright Sky instance to be:

Run a local (network-internal) instance

Run:

# ./brightsky up -d

This will start all necessary containers and then detach from them. You can view the live logs by running ./brightsky logs -f, and stop the containers by running ./brightsky down.

The API will be available at http://localhost:5000/.

Run a public instance behind a Traefik router

First, you will need a hostname with DNS records pointing to your server. Add a file named .env with the following content:

HOSTNAME=your.host.name
[email protected]

Next, create a file named config with the following content:

brightsky
traefik

Finally, run:

# ./brightsky up -d

This will start a Bright Sky and Traefik router, acquire a TLS certificate from Let's Encrypt, and make the API available at https://your.host.name/.

Authentication

If you wish to require authentication for your Bright Sky instance, you can easily do so using Traefik's BasicAuth middleware. Add a line containing auth to your config file, so that it reads:

brightsky
traefik
auth

And run this command for every user/password combination you wish to allow (replace USERNAME with the actual username, you will be prompted for the password):

# ./brightsky adduser USERNAME

Then use

# ./brightsky up -d

to start your Bright Sky instance.

Run a public instance behind a Traefik router with basic usage analytics

Make sure you have a separate hostname with DNS records pointing to your server. Add it to your .env file as HOSTNAME_GRAFANA, e.g.:

HOSTNAME=your.host.name
HOSTNAME_GRAFANA=grafana.your.host.name
[email protected]

Next, add an additional line containing analytics to your config file. Then simply follow the instructions for setting up a public instance above.

Make sure to log into your Grafana instance and change the default admin password.

Additional Configuration

Configuring Bright Sky options

Bright Sky allows configurating all its options through environment variables. You can set these variables in brightsky.env. E.g. this brightsky.env would only parse/store data from 2018 onwards, allow cross-origin requests from myweatherapp.com, and poll the DWD server only every 10 minutes:

BRIGHTSKY_MIN_DATE=2018-01-01
BRIGHTSKY_CORS_ALLOWED_ORIGINS=https://myweatherapp.com
BRIGHTSKY_POLLING_CRONTAB_MINUTE=*/10

Add Sentry error tracking

Add your Sentry DSN to brightsky.env, e.g.:

SENTRY_DSN=https://your_sentry_dsn_here

brightsky-infrastructure's People

Contributors

jdemaeyer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.