Static files server
Yoggi uses AWS S3 to store the files. The frontend is written in React.
- Install Python
- Run
npm install
andnpm 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 build
to test locally - Run
pipenv install
- Run
pipenv shell
which 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.
When running locally, you can run nyckeln under dörrmattan instead of the production login system. If you need access to the dsekt-assets-dev
bucket, you can ask Systemansvarig: [email protected], but setting up an own bucket may be a better choice.
Name | Description | Default |
---|---|---|
LOGIN_FRONTEND_URL | URL to login from frontend | https://logout.datasektionen.se/legacyapi |
LOGIN_API_URL | URL to login from backend | https://logout.datasektionen.se/legacyapi |
LOGIN_API_KEY | API key for KTH authentication | --- |
PLS_URL | URL to pls server | https://pls.datasektionen.se |
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.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