Skip to content
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
2 changes: 0 additions & 2 deletions .docker/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ KPAS_DOMAIN=kpas.staging.kompetanse.udir.no
GUNICORN_TIMEOUT=60
GUNICORN_LOG_LEVEL=debug

MATOMO_ACCESS_KEY=

##############################################################
# Database
##############################################################
Expand Down
11 changes: 9 additions & 2 deletions .docker/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ echo -e "\n\n\n[1/4] Copy and import .env variables to the current shell"
echo -e "##############################################################\n"
ENV_FILE=".env"
if [ ! -f "$ENV_FILE" ]; then
cp .docker/.env.template .env
cp .docker/.env.template .env
echo "- .env file created from template. Please review and update the .env file as needed before restarting the container."
else
echo "- .env file already exists, skipping copy. If you want to reset it, please delete the existing .env file and restart the container."
fi

set -o allexport
Expand All @@ -17,12 +20,16 @@ while IFS='=' read -r key value; do
export "$key=$value"
echo "- IMPORTED: $key"
else
echo "- ERROR: $key"
echo "- SKIPPED (already set): $key"
fi
fi
done < "$ENV_FILE"
set +o allexport

if ! grep -q "source /app/.env" /root/.bashrc 2>/dev/null; then
echo '[ -f /app/.env ] && set -o allexport && source /app/.env && set +o allexport' >> /root/.bashrc
fi

echo -e "\n\n\n[2/4] Install PIP packages"
echo -e "##############################################################\n"
pip3 --cache-dir=/app/.cache install -r requirements.txt
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
kpas_stats_db:
image: mysql:8.4
Expand Down Expand Up @@ -27,7 +26,6 @@ services:
kpas_stats_db:
condition: service_healthy
environment:
ENVIRONMENT: "local"
CANVAS_ACCESS_KEY: "" # Generate a new access key here: https://bibsys.test.instructure.com/profile/settings
MATOMO_ACCESS_KEY: ""
volumes:
Expand Down
2 changes: 1 addition & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-r requirements.txt
uritemplate==3.0.1
pyyaml==5.4
pyyaml==6.0.3
15 changes: 8 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
APScheduler==3.11.0
APScheduler==3.11.2
arrow==1.3.0
Django==4.2.19
Django==4.2.29
django-cors-headers==4.7.0
djangorestframework==3.15.2
gunicorn==23.0.0
mysql-connector-python==9.2.0
mysqlclient==2.2.7
mysqlclient==2.2.8
netifaces==0.11.0
PyMySQL==1.1.1
PyMySQL==1.1.2
python-decouple==3.8
python-graphql-client==0.4.3
requests==2.32.3
SQLAlchemy==2.0.38
requests==2.32.5
SQLAlchemy==2.0.48
SQLAlchemy-Utils==0.41.2
sentry-sdk[django]==2.20.0
sentry-sdk[django]==2.55.0
setuptools>=78.0.0
16 changes: 13 additions & 3 deletions statistics_api/definitions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import os
import socket
from distutils import util
import netifaces as ni
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import declarative_base


def strtobool(val):
val = str(val).strip().lower()
if val in ('y', 'yes', 't', 'true', 'on', '1'):
return True
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
return False
else:
raise ValueError(f'Invalid truth value {val!r}')


def get_ip_address():
try:
Expand Down Expand Up @@ -47,7 +57,7 @@ def get_ip_address():
"DATABASE_REFRESH_MINUTE") else "00"

DJANGO_SECRET_KEY = os.getenv("DJANGO_SECRET_KEY")
DJANGO_DEBUG = bool(util.strtobool(os.getenv("DJANGO_DEBUG"))) if os.getenv("DJANGO_DEBUG") is not None else False
DJANGO_DEBUG = bool(strtobool(os.getenv("DJANGO_DEBUG"))) if os.getenv("DJANGO_DEBUG") is not None else False

allowed_hosts = [s.strip() for s in os.getenv("DJANGO_ALLOWED_HOSTS", "").split(',')]
if not allowed_hosts:
Expand Down
4 changes: 2 additions & 2 deletions statistics_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration

app_env=os.getenv("ENVIRONMENT") if os.getenv("ENVIRONMENT") else "local"
app_env=os.getenv("ENVIRONMENT") if os.getenv("ENVIRONMENT") else "dev"
app_version=os.getenv("GIT_COMMIT") if os.getenv("GIT_COMMIT") else "1.0.0"
sentry_dsn=None

if app_env != "local":
if app_env != "dev":
sentry_dsn="https://b247741da7815fc43bddd20a6032a1a2@o4507468577701888.ingest.de.sentry.io/4508777538519120"

def before_send_transaction(event_item, event):
Expand Down
Loading