Skip to content

datasektionen/yoggi

Repository files navigation

Yoggi

Static files server

How it works

Yoggi uses AWS S3 to store the files. The frontend is written in React.

How to run

  1. Install Python
  2. Run npm install and npm run build (builds the frontend)
  3. Configure your environment variables in an .env-file, see Environment variables
  4. Change 'REACT_APP_BUCKET_NAME': JSON.stringify('dsekt-assets') to 'REACT_APP_BUCKET_NAME': JSON.stringify('dsekt-assets-dev') in webpack-production.config.js, if you are running npm run build to test locally
  5. Run pipenv install
  6. Run pipenv shell which loads environment variables and some other magic
  7. Run python yoggi.py

At this time, I don't know how to make the hot-reloading of React work. You simply have to run npm run build to make it work with the backend.

Tip: If your running your editor with the virtual environment you can instead run pipenv install --dev to also installs some type stubs.

Environment variables

When running locally, you can run nyckeln under dörrmattan instead of the production sso system. If you need access to the dsekt-assets-dev bucket, you can ask Systemansvarig: d-sys@datasektionen.se, but setting up an own bucket may be a better choice.

Name Description Default
OIDC_PROVIDER URL to sso from backend http://sso.nomad.dsekt.internal/op
OIDC_ID SSO ID yoggi
OIDC_SECRET Application API key secret for SSO ---
REDIRECT_URL Application URL which SSO should redirect to https://static.datasektionen.se/
JWT_SECRET Arbitrary secret string used to sign auth JWT ---
PORT Port to serve backend on 5000
S3_BUCKET Name of S3 bucket. When running locally, use dsekt-assets-dev ---
AWS_ACCESS_KEY_ID AWS IAM access key id ---
AWS_SECRET_ACCESS_KEY AWS IAM secret access key ---

Configuring the S3 bucket

Objects can be set as publicly accessible by adding the tag key-value-pair "public": "True" to the object. For this to work, the bucket needs to be configured with the following JSON (Bucket policy):

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::dsekt-assets/*",
            "Condition": {
                "StringEquals": {
                    "s3:ExistingObjectTag/public": "True"
                }
            }
        }
    ]
}

Protip

To allow larger file uploads, set the max size of file uploads to for example 100 MB.

echo "client_max_body_size 100M;" > /home/dokku/yoggi/nginx.conf.d/max_size.conf

Alernatively edit the file to edit the max size if the file already exists:

sudo nano /home/dokku/yoggi/nginx.conf.d/max_size.conf

About

Yoggi, som i yoghurt, som i fil, som i statiska filer. Bra jobbat Mauritz

Resources

Stars

Watchers

Forks

Contributors