diff --git a/template/Dockerfile b/template/Dockerfile new file mode 100644 index 0000000..7d6e714 --- /dev/null +++ b/template/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.13-alpine + +ENV PYTHONPYCACHEPREFIX=/dev/null + +RUN apk update && apk add git gettext + +WORKDIR /code + +COPY requirements.txt /code/requirements.txt + +RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt + +CMD ["sh", "./entrypoint.sh"] \ No newline at end of file diff --git a/template/api/__init__.py b/template/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/template/api/admin.py b/template/api/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/template/api/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/template/api/apps.py b/template/api/apps.py new file mode 100644 index 0000000..878e7d5 --- /dev/null +++ b/template/api/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ApiConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "api" diff --git a/template/api/migrations/__init__.py b/template/api/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/template/api/models.py b/template/api/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/template/api/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/template/api/tests.py b/template/api/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/template/api/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/template/api/urls.py b/template/api/urls.py new file mode 100644 index 0000000..108460e --- /dev/null +++ b/template/api/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from .views import HealthView + +urlpatterns = [ + path("health/", HealthView.as_view()) +] \ No newline at end of file diff --git a/template/api/views.py b/template/api/views.py new file mode 100644 index 0000000..3877edb --- /dev/null +++ b/template/api/views.py @@ -0,0 +1,7 @@ +from rest_framework.views import APIView +from rest_framework.response import Response + + +class HealthView(APIView): + def get(self, *args, **kwargs): + return Response(data={"detail": "OK"}) \ No newline at end of file diff --git a/template/config/__init__.py b/template/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/template/config/asgi.py b/template/config/asgi.py new file mode 100644 index 0000000..19b90e3 --- /dev/null +++ b/template/config/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for config 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/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_asgi_application() diff --git a/template/config/settings.py b/template/config/settings.py new file mode 100644 index 0000000..bb269d2 --- /dev/null +++ b/template/config/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for config project. + +Generated by 'django-admin startproject' using Django 5.1.3. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.1/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "django-insecure-iv-iwjd(4d%g5&fyo*+xybkjhaik+r@3j0$h91u0^$u4fwuh53" + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [ + "*" +] + + +# Application definition + +INSTALLED_APPS = [ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "api", +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", +] + +ROOT_URLCONF = "config.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 = "config.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.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/5.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/5.1/howto/static-files/ + +STATIC_URL = "static/" + +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/template/config/urls.py b/template/config/urls.py new file mode 100644 index 0000000..de9a619 --- /dev/null +++ b/template/config/urls.py @@ -0,0 +1,7 @@ +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path("payment/api/", include("api.urls")), + path("payment/admin/", admin.site.urls), +] diff --git a/template/config/wsgi.py b/template/config/wsgi.py new file mode 100644 index 0000000..b2bb19f --- /dev/null +++ b/template/config/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for config 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/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_wsgi_application() diff --git a/template/db.sqlite3 b/template/db.sqlite3 new file mode 100644 index 0000000..ebf6887 Binary files /dev/null and b/template/db.sqlite3 differ diff --git a/template/entrypoint.sh b/template/entrypoint.sh new file mode 100644 index 0000000..b4bce27 --- /dev/null +++ b/template/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +python3 manage.py collectstatus --no-input +python3 manage.py migrate --no-input +python3 manage.py runserver 0.0.0.0:8000 \ No newline at end of file diff --git a/template/manage.py b/template/manage.py new file mode 100755 index 0000000..d28672e --- /dev/null +++ b/template/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == "__main__": + main() diff --git a/template/requirements.txt b/template/requirements.txt new file mode 100644 index 0000000..ddd6f0f --- /dev/null +++ b/template/requirements.txt @@ -0,0 +1,2 @@ +django==5.1.3 +djangorestframework==3.15.2 \ No newline at end of file