Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setting up docker; installing sekizai; starting with base templates
- Loading branch information
1 parent
84392b6
commit 07989f2
Showing
18 changed files
with
244 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.idea | ||
*/__pycache__/* | ||
__pycache__ | ||
*test-*.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
version: "3.7" | ||
services: | ||
postgres: | ||
image: postgres:12-alpine | ||
ports: | ||
- "127.0.0.1:7777:5432" | ||
environment: | ||
POSTGRES_DB: minigigs | ||
POSTGRES_PASSWORD: verysecurepassword | ||
POSTGRES_USER: minigigs | ||
|
||
web: | ||
build: | ||
context: . | ||
dockerfile: docker/app/Dockerfile.local | ||
command: docker/app/scripts/migrate_and_serve.sh | ||
ports: | ||
- "127.0.0.1:8000:8000" | ||
depends_on: | ||
- postgres | ||
volumes: | ||
- .:/app:ro | ||
- staticfiles:/var/www/static | ||
environment: | ||
DATABASE_URL: postgres://minigigs:verysecurepassword@postgres:5432/minigigs | ||
DEBUG: "true" | ||
SECRET_KEY: suitable-for-development-only | ||
STATIC_ROOT: /var/www/static | ||
|
||
volumes: | ||
staticfiles: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
FROM bitnami/python:3.7-prod | ||
|
||
# I have no idea what this does. | ||
STOPSIGNAL SIGQUIT | ||
ARG EXTRAS=deploy | ||
|
||
# Create a user. | ||
RUN adduser \ | ||
--disabled-login \ | ||
--no-create-home \ | ||
--uid 1500 \ | ||
minigigs | ||
|
||
# Install prerequisites needed to complete the dependency installation. | ||
RUN apt-get update -y \ | ||
&& \ | ||
apt-get install --no-install-recommends -y \ | ||
gcc \ | ||
libc-dev \ | ||
libpq-dev \ | ||
git \ | ||
&& \ | ||
apt-get clean \ | ||
&& \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set up the working directory. | ||
WORKDIR /app | ||
COPY Pipfile Pipfile.lock /app/ | ||
|
||
# Pip install the stuff we'll need. | ||
RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \ | ||
pip install --no-cache-dir -U setuptools | ||
RUN python3 -m pip install pipenv \ | ||
&& python3 -m pipenv install --system --deploy \ | ||
&& pip install uwsgi==2.0.18 | ||
|
||
# Copy everything into the docker environment. | ||
COPY . . | ||
|
||
RUN SECRET_KEY=placeholder DATABASE_URL=sqlite:// python3 manage.py collectstatic --no-input --clear --verbosity 0 | ||
|
||
# Remove the prerequisites, dependency installation is now complete. | ||
RUN apt-get purge -y \ | ||
gcc \ | ||
libc-dev \ | ||
libpq-dev | ||
|
||
CMD ["uwsgi", "--ini", "docker/app/uwsgi.ini"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh -eu | ||
|
||
### NOTE | ||
# This file is intended to be used by local setups. | ||
# You do not want to run the Django development server | ||
# in production. The default Dockerfile command will | ||
# run using uWSGI, this script is provided purely as | ||
# a convenience to run migrations and start a development server. | ||
|
||
echo [i] Applying migrations. | ||
python manage.py migrate --verbosity 1 | ||
|
||
echo [i] Collecting static files. | ||
python manage.py collectstatic --no-input --clear --verbosity 1 | ||
|
||
echo [i] Creating a superuser. | ||
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin', 'admin') if not User.objects.filter(username='admin').exists() else print('Admin user already exists')" | python manage.py shell | ||
|
||
echo [i] Starting server. | ||
python manage.py runserver 0.0.0.0:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[uwsgi] | ||
### Exposed ports | ||
# uWSGI protocol socket | ||
socket = :4000 | ||
|
||
### File settings | ||
# WSGI application | ||
wsgi = website.wsgi:application | ||
# Directory to move into at startup | ||
chdir = /app | ||
|
||
### Concurrency options | ||
# Run a master to supervise the workers | ||
master = true | ||
# Keep a minimum of 1 worker | ||
cheaper = 1 | ||
# Allow a maximum of 4 workers | ||
workers = 4 | ||
# Automatically set up meanginful process names | ||
auto-procname = true | ||
# Prefix process names with `pydis_site : ` | ||
procname-prefix-spaced = minigigs_site : | ||
|
||
### Worker options | ||
# Kill workers if they take more than 30 seconds to respond. | ||
harakiri = 30 | ||
|
||
### Startup settings | ||
# Exit if we can't load the app | ||
need-app = true | ||
# `setuid` to an unprivileged user | ||
uid = 1500 | ||
# Do not use multiple interpreters | ||
single-interpreter = true | ||
|
||
### Hook setup | ||
# Gracefully kill workers on `SIGQUIT` | ||
hook-master-start = unix_signal:3 gracefully_kill_them_all |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class HomeConfig(AppConfig): | ||
name = 'website.home' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.urls import path | ||
|
||
from . import views | ||
|
||
urlpatterns = [ | ||
path('', views.index, name='index'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.http import HttpResponse | ||
|
||
|
||
def index(request): | ||
return HttpResponse("Hello, world. You're at the polls index.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{% load django_simple_bulma %} | ||
{% load sekizai_tags %} | ||
{% load static %} | ||
|
||
<!DOCTYPE html> | ||
<html lang="nl"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> | ||
<meta name="description" content="Website van het Minigigs Cycling Team"> | ||
<meta name="keywords" content="Minigigs Cycling Team, Minigigs, Cycling, Wielrennen, Den Haag"> | ||
<meta name="author" content="Sebastiaan Zeeff"> | ||
|
||
<title>Minigigs Cycling Team | {% block title %}Website{% endblock %}</title> | ||
|
||
{% bulma %} | ||
|
||
{# Font-awesome here is defined explicitly so that we can have Pro #} | ||
<script src="https://kit.fontawesome.com/ae6a3152d8.js"></script> | ||
|
||
<link rel="stylesheet" href="{% static "css/base/base.css" %}"> | ||
{% block head %}{% endblock %} | ||
|
||
{% render_block "css" %} | ||
</head> | ||
<body class="site"> | ||
<main class="site-content"> | ||
{% block content %} | ||
{{ block.super }} | ||
{% endblock %} | ||
</main> | ||
|
||
{% block site_footer %} | ||
{% include "base/footer.html" %} | ||
{% endblock %} | ||
|
||
{% render_block "js" %} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters