diff --git a/.github/workflows/deploy_to_aws.yml b/.github/workflows/deploy_to_aws.yml index f4a7889..f05aa6f 100644 --- a/.github/workflows/deploy_to_aws.yml +++ b/.github/workflows/deploy_to_aws.yml @@ -46,8 +46,12 @@ jobs: run: | ssh -o StrictHostKeyChecking=no -i ec2-key.pem ec2-user@ec2-35-173-190-74.compute-1.amazonaws.com << 'EOF' + # Stop and remove everything + docker stop $(docker ps -aq) + docker rm $(docker ps -aq) + # Setup environment variables - export DJANGO_ALLOWED_HOSTS=softwarefailures.com,35.173.190.74 + export DJANGO_ALLOWED_HOSTS="softwarefailures.com,$(ifconfig enX0 | grep 'inet ' | awk '{print $2}'),$(curl -s http://checkip.amazonaws.com)" export REDIS_URL=redis://redis:6379/0 export $(aws secretsmanager get-secret-value --secret-id prod/failure/postgres --region us-east-1 --query SecretString --output text | jq -r '. as $secret | "POSTGRES_HOST=\($secret | .host)\nPOSTGRES_PORT=5432\nPOSTGRES_DB=\($secret | .dbname)\nPOSTGRES_USER=\($secret | .username)\nPOSTGRES_PASSWORD=\($secret | .password)\nDATABASE_URL=postgres://\($secret | .username):\($secret | .password)@\($secret | .host):5432/\($secret | .dbname)"') @@ -55,16 +59,12 @@ jobs: aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_REPOSITORY_URL }} docker pull ${{ secrets.AWS_ECR_REPOSITORY_URL }}:latest - # Stop and remove everything - docker stop $(docker ps -aq) - docker rm $(docker ps -aq) - # Start the container with the new image docker run -d --name redis -p 6379:6379 redis:alpine docker run -d --name django-prod -p 80:80 -e POSTGRES_HOST -e POSTGRES_PORT -e POSTGRES_DB -e POSTGRES_USER -e POSTGRES_PASSWORD -e DATABASE_URL -e REDIS_URL -e DJANGO_ALLOWED_HOSTS ${{ secrets.AWS_ECR_REPOSITORY_URL }}:latest /start # Clean up - docker rmi $(docker images -q) + docker image prune -f --all docker volume prune -f docker network prune -f diff --git a/config/settings/base.py b/config/settings/base.py index df504e6..fe06540 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -13,6 +13,7 @@ # Fix to Chroma requires sqlite3 >= 3.35.0 __import__('pysqlite3') import sys + sys.modules['sqlite3'] = sys.modules.pop('pysqlite3') @@ -171,6 +172,14 @@ X_FRAME_OPTIONS = "DENY" +SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") + +SECURE_SSL_REDIRECT = env.bool("DJANGO_SECURE_SSL_REDIRECT", default=True) + +SESSION_COOKIE_SECURE = True + +CSRF_COOKIE_SECURE = True + # EMAIL # ------------------------------------------------------------------------------ EMAIL_BACKEND = env( diff --git a/config/settings/local.py b/config/settings/local.py index 0436d2b..34f1e6b 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -13,6 +13,8 @@ ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"] ALLOWED_HOSTS += env.list("DJANGO_ALLOWED_HOSTS", default=[]) +CSRF_TRUSTED_ORIGINS = ["https://softwarefailures.com"] + ALLOWED_HOSTS + # CACHES # ------------------------------------------------------------------------------ CACHES = { diff --git a/config/urls.py b/config/urls.py index f6bffb4..5bd4ae8 100644 --- a/config/urls.py +++ b/config/urls.py @@ -10,9 +10,9 @@ urlpatterns = [ # Django Admin, use {% url 'admin:index' %} path(settings.ADMIN_URL, admin.site.urls), - path("failures/", include("failures.articles.urls", namespace="articles")), path('health/', lambda request: JsonResponse({"status": "healthy"}, status=200), name='health_check'), - path("", public_admin.urls), + path("", include("failures.articles.urls", namespace="articles")), + # path("", public_admin.urls), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/failures/static/images/jamieWeb.png b/failures/static/images/jamieWeb.png new file mode 100644 index 0000000..a93540f Binary files /dev/null and b/failures/static/images/jamieWeb.png differ diff --git a/failures/templates/articles/incident_detail.html b/failures/templates/articles/incident_detail.html index e9c5e44..3e16f1b 100644 --- a/failures/templates/articles/incident_detail.html +++ b/failures/templates/articles/incident_detail.html @@ -68,10 +68,13 @@

Incident: {{ incident.title }}

{{ incident.impacts }} - Preventions & Fixes - {{ incident.preventions }} {{ incident.fixes }} + Preventions + {{ incident.preventions }} + Fixes + {{ incident.fixes }} + References {{ incident.references }} diff --git a/failures/templates/articles/public_page.html b/failures/templates/articles/public_page.html index 4430ee8..9167b47 100644 --- a/failures/templates/articles/public_page.html +++ b/failures/templates/articles/public_page.html @@ -14,19 +14,38 @@ + {% load static %} +
- -