Skip to content

Commit

Permalink
🐳 Update docker files, integrate error templates with base
Browse files Browse the repository at this point in the history
  • Loading branch information
dariomory committed Sep 13, 2021
1 parent 5deb508 commit bae3c85
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 441 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ COPY --from=backend-build /app/src/ /app/src/

# copy frontend build statics
COPY --from=frontend-build /app/src/sdg/static /app/src/sdg/static
COPY --from=frontend-build /app/node_modules/formset.js /app/node_modules/formset.js

# copy source code
COPY ./src /app/src
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
# NOTE: No persistance storage configured.
# See: https://hub.docker.com/_/postgres/
image: postgres
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
# NOTE: this works for bitnami, not sure if this works for regular
# postgres image
volumes:
Expand Down
6 changes: 3 additions & 3 deletions docker-init-db.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE USER {{ project_name|lower }};
CREATE DATABASE {{ project_name|lower }};
GRANT ALL PRIVILEGES ON DATABASE {{ project_name|lower }} TO {{ project_name|lower }};
CREATE USER sdg;
CREATE DATABASE sdg;
GRANT ALL PRIVILEGES ON DATABASE sdg TO sdg;

2 changes: 1 addition & 1 deletion src/sdg/conf/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

# # Strongly suggested to not use this, but explicitly list the allowed hosts. It is
# used to verify if a redirect is safe or not (open redirect vulnerabilities etc.)
# os.environ.setdefault("ALLOWED_HOSTS", "*")
os.environ.setdefault("ALLOWED_HOSTS", "*")

from .production import * # noqa isort:skip
11 changes: 4 additions & 7 deletions src/sdg/templates/403.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{% extends 'master.html' %}
{% extends 'account/base.html' %}

{% block menu %}{% endblock %}

{% block content %}

<h1>Sorry, you don't have access to this page (403)</h1>


{% endblock content %}
{% block login_right %}
<h1>Sorry, you don't have access to this page (403)</h1>
{% endblock login_right %}
16 changes: 8 additions & 8 deletions src/sdg/templates/404.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% extends 'master.html' %}
{% extends 'account/base.html' %}

{% block menu %}{% endblock %}
{% load i18n %}

{% block content %}

<h1>Sorry, the requested page could not be found (404)</h1>


{% endblock content %}
{% block login_right %}
<h3 class="login__container-title">404</h3>
<p class="login__container-info">
{% trans 'Sorry, the request page could not be found.' %}
</p>
{% endblock login_right %}
219 changes: 12 additions & 207 deletions src/sdg/templates/500.html
Original file line number Diff line number Diff line change
@@ -1,210 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
{% extends 'account/base.html' %}

<title> - Server Error</title>
{% block menu %}{% endblock %}

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<style type="text/css">
/*
* Globals
*/

/* Links */
a,
a:focus,
a:hover {
color: #fff;
}

/* Custom default button */
.btn-default,
.btn-default:hover,
.btn-default:focus {
color: #333;
text-shadow: none; /* Prevent inheritence from `body` */
}


/*
* Base structure
*/

html,
body {
height: 100%;
background-color: #fff;
}
body {
color: #333;
text-align: center;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
}

/* Extra markup and styles for table-esque vertical and horizontal centering */
.site-wrapper {
display: table;
width: 100%;
height: 100%; /* For at least Firefox */
min-height: 100%;
}
.site-wrapper-inner {
display: table-cell;
vertical-align: top;
}
.cover-container {
margin-right: auto;
margin-left: auto;
}

/* Padding for spacing */
.inner {
padding: 30px;
}


/*
* Header
*/
.masthead-brand {
margin-top: 10px;
margin-bottom: 10px;
}

.masthead-nav > li {
display: inline-block;
}
.masthead-nav > li + li {
margin-left: 20px;
}
.masthead-nav > li > a {
padding-right: 0;
padding-left: 0;
font-size: 16px;
font-weight: bold;
color: #fff; /* IE8 proofing */
color: rgba(255,255,255,.75);
border-bottom: 2px solid transparent;
}
.masthead-nav > li > a:hover,
.masthead-nav > li > a:focus {
background-color: transparent;
border-bottom-color: #a9a9a9;
border-bottom-color: rgba(255,255,255,.25);
}
.masthead-nav > .active > a,
.masthead-nav > .active > a:hover,
.masthead-nav > .active > a:focus {
color: #fff;
border-bottom-color: #fff;
}

@media (min-width: 768px) {
.masthead-brand {
float: left;
}
.masthead-nav {
float: right;
}
}


/*
* Cover
*/

.cover {
padding: 0 20px;
}
.cover .btn-lg {
padding: 10px 20px;
font-weight: bold;
}


/*
* Footer
*/

.mastfoot {
color: #999; /* IE8 proofing */
color: rgba(255,255,255,.5);
}


/*
* Affix and center
*/

@media (min-width: 768px) {
/* Pull out the header and footer */
.masthead {
position: fixed;
top: 0;
}
.mastfoot {
position: fixed;
bottom: 0;
}
/* Start the vertical centering */
.site-wrapper-inner {
vertical-align: middle;
}
/* Handle the widths */
.masthead,
.mastfoot,
.cover-container {
width: 100%; /* Must be percentage or pixels for horizontal alignment */
}
}

@media (min-width: 992px) {
.masthead,
.mastfoot,
.cover-container {
width: 700px;
}
}
</style>

</head>

<body>
<div class="site-wrapper">

<div class="site-wrapper-inner">

<div class="cover-container">

<div class="inner cover">
<h1 class="cover-heading">Sorry, a server error has occurred (500)</h1>
<p class="lead">We have been automatically notified about the problem and will investigate as soon as possible.</p>
{% if request.sentry.id %}
<p>If you need assistance, you may reference this error as
{% block login_right %}
<h1 class="cover-heading">Sorry, a server error has occurred (500)</h1>
<p class="lead">We have been automatically notified about the problem and will investigate as soon as possible.</p>
{% if request.sentry.id %}
<p>If you need assistance, you may reference this error as
<strong>{{ request.sentry.id }}</strong>.</p>
{% endif %}
<p class="lead">
<a href="/" class="btn btn-lg btn-default">Back to home</a>
</p>
</div>

</div>

</div>

</div>
</body>

</html>
{% endif %}
<p class="lead">
<a href="/" class="btn btn-lg btn-default">Back to home</a>
</p>
{% endblock login_right %}
Loading

0 comments on commit bae3c85

Please sign in to comment.