-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
…s Unscripted 2024 workshop.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
.vscode | ||
|
||
# terraform | ||
.terraform.lock.hcl | ||
.terraform | ||
*.tfplan | ||
*.tfstate | ||
*.tfstate.backup |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# unscripted-workshop-2024 |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM python:3.11-slim | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
|
||
RUN python3 -m venv /opt/venv | ||
|
||
RUN /opt/venv/bin/pip install pip --upgrade && \ | ||
/opt/venv/bin/pip install -r requirements.txt && \ | ||
chmod +x entrypoint.sh | ||
|
||
|
||
CMD ["/bin/sh","/app/entrypoint.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for backend project. | ||
It exposes the ASGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings') | ||
|
||
application = get_asgi_application() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
""" | ||
Django settings for backend project. | ||
Generated by 'django-admin startproject' using Django 4.1. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/4.1/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/4.1/ref/settings/ | ||
""" | ||
from pathlib import Path | ||
import os | ||
|
||
# Build paths inside the project like this: BASE_DIR / 'subdir'. | ||
BASE_DIR = Path(__file__).resolve().parent.parent | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = "@5fid6o1gnqajs7*#@r*x(y-+=zhqi=$kws1jr+gc%+*&s=$j8" | ||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ | ||
|
||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = ['*'] | ||
|
||
DEPLOYMENT_VARIABLE = os.getenv('HOSTNAME') | ||
# Application definition | ||
|
||
SERVICE_NAME = os.getenv('SERVICE_NAME') | ||
EXECUTION_USER = os.getenv('EXECUTION_USER') | ||
LAST_EXECUTION_ID = os.getenv('LAST_EXECUTION_ID') | ||
APPLICATION_VERSION = os.getenv('APPLICATION_VERSION') | ||
ARTIFACT_VERSION = os.getenv('ARTIFACT_VERSION') | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'deploy', | ||
'rest_framework', | ||
'drf_yasg', | ||
] | ||
|
||
CORS_ALLOW_METHODS = [ | ||
"DELETE", | ||
"GET", | ||
"OPTIONS", | ||
"PATCH", | ||
"POST", | ||
"PUT" | ||
] | ||
|
||
MIDDLEWARE = [ | ||
'django.middleware.security.SecurityMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.common.CommonMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'corsheaders.middleware.CorsMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
] | ||
|
||
CORS_ALLOW_ALL_ORIGINS = True | ||
CSRF_ALLOW_ALL_ORIGINS = True | ||
ROOT_URLCONF = 'backend.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'backend.wsgi.application' | ||
REST_FRAMEWORK = { | ||
'DEFAULT_AUTHENTICATION_CLASSES': [ | ||
'rest_framework_simplejwt.authentication.JWTAuthentication', | ||
], | ||
'DEFAULT_THROTTLE_CLASSES': [ | ||
'rest_framework.throttling.AnonRateThrottle', | ||
'rest_framework.throttling.UserRateThrottle' | ||
], | ||
'DEFAULT_THROTTLE_RATES': { | ||
'anon': '500000000/day', | ||
'user': '100000000/day' | ||
} | ||
} | ||
|
||
# Database | ||
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': BASE_DIR / 'db.sqlite3', | ||
} | ||
} | ||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators | ||
|
||
AUTH_PASSWORD_VALIDATORS = [ | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | ||
}, | ||
] | ||
|
||
|
||
# Internationalization | ||
# https://docs.djangoproject.com/en/4.1/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
|
||
TIME_ZONE = 'UTC' | ||
|
||
USE_I18N = True | ||
|
||
USE_TZ = True | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/4.1/howto/static-files/ | ||
|
||
STATIC_URL = 'static/' | ||
|
||
# Default primary key field type | ||
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field | ||
|
||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""backend URL Configuration | ||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/4.1/topics/http/urls/ | ||
Examples: | ||
Function views | ||
1. Add an import: from my_app import views | ||
2. Add a URL to urlpatterns: path('', views.home, name='home') | ||
Class-based views | ||
1. Add an import: from other_app.views import Home | ||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') | ||
Including another URLconf | ||
1. Import the include() function: from django.urls import include, path | ||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) | ||
""" | ||
from django.contrib import admin | ||
from django.urls import path, include | ||
|
||
|
||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
path('deploy/', include('deploy.urls')), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for backend project. | ||
It exposes the WSGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings') | ||
|
||
application = get_wsgi_application() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. | ||
from .models import RequestEntry | ||
|
||
|
||
admin.site.register(RequestEntry) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class DeployConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'deploy' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 4.1 on 2024-01-27 23:13 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='RequestEntry', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=50)), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
], | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
|
||
class RequestEntry(models.Model): | ||
name = models.CharField(max_length=50) | ||
created_at = models.DateTimeField(auto_now_add=True) |