Static files server
Yoggi uses AWS S3 to store the files. The frontend is written in React.
- Install Python
- Run
npm installandnpm run build(builds the frontend) - Configure your environment variables in an
.env-file, see Environment variables - 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 runningnpm run buildto test locally - Run
pipenv install - Run
pipenv shellwhich loads environment variables and some other magic - 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.
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 | --- |
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"
}
}
}
]
}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.confAlernatively edit the file to edit the max size if the file already exists:
sudo nano /home/dokku/yoggi/nginx.conf.d/max_size.conf