Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1f8d092dd0 | ||
|
ba4ed4de37 | ||
|
754d2d7c2b | ||
|
c5fa34446e | ||
|
1fd44949eb | ||
|
a280cabff1 | ||
|
882f1e26b3 | ||
|
c207a26814 | ||
|
c1afe21457 | ||
|
3bd7e0f1b4 | ||
|
8b53d213e9 | ||
|
64d13090dc | ||
|
00274fd033 | ||
|
ef502854ee | ||
|
b85c6e7b53 | ||
|
44aefef3dd | ||
8c05dd48e7 | |||
2fda59f451 | |||
61149eadee | |||
|
a3c51f3b5f | ||
|
c6aaccda67 | ||
|
4abf616637 | ||
|
211f6c75ad | ||
|
e411e71b89 | ||
|
d7411d90c4 | ||
|
abdb62fd55 |
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM greyltc/archlinux-aur:yay
|
||||||
|
WORKDIR /alkator
|
||||||
|
COPY alkator alkator
|
||||||
|
COPY alkatorapi alkatorapi
|
||||||
|
RUN pacman -Syu python python-weasyprint python-dateutil python-django python-requests python-pip --noconfirm
|
||||||
|
RUN sudo -u ab -D~ bash -c 'yay -Syu --removemake --needed --noprogressbar --noconfirm python-daphne'
|
||||||
|
RUN pip install django_prometheus --break-system-packages
|
||||||
|
EXPOSE 8005
|
||||||
|
CMD ["/usr/bin/daphne", "alkator.asgi:application", "-b", "0.0.0.0", "-p", "8005"]
|
@ -25,13 +25,14 @@ SECRET_KEY = 'django-insecure-#q!-odx05#6o&1dek)4shtqdw!)s5oonenb(tcmuwclu^dy4!#
|
|||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['https://alkator.cz', 'https://beta.alkator.cz', 'localhost']
|
ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1', 'api', 'https://alkator.cz', 'https://beta.alkator.cz', 'localhost']
|
||||||
|
|
||||||
CSRF_TRUSTED_ORIGINS = ['https://alkator.cz', 'https://beta.alkator.cz']
|
CSRF_TRUSTED_ORIGINS = ['https://alkator.cz', 'https://beta.alkator.cz', 'https://zaloha.alkator.cz']
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
'daphne',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
@ -39,9 +40,11 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'alkatorapi',
|
'alkatorapi',
|
||||||
|
'django_prometheus',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
'django_prometheus.middleware.PrometheusBeforeMiddleware',
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
@ -49,8 +52,12 @@ MIDDLEWARE = [
|
|||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
'django_prometheus.middleware.PrometheusAfterMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
PROMETHEUS_LATENCY_BUCKETS = (0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0, 25.0, 50.0, 75.0, float("inf"),)
|
||||||
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'alkator.urls'
|
ROOT_URLCONF = 'alkator.urls'
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
@ -70,6 +77,7 @@ TEMPLATES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
WSGI_APPLICATION = 'alkator.wsgi.application'
|
WSGI_APPLICATION = 'alkator.wsgi.application'
|
||||||
|
ASGI_APPLICATION = 'alkator.asgi.application'
|
||||||
|
|
||||||
SESSION_COOKIE_SECURE = True
|
SESSION_COOKIE_SECURE = True
|
||||||
|
|
||||||
@ -78,12 +86,11 @@ SESSION_COOKIE_SECURE = True
|
|||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django_prometheus.db.backends.sqlite3',
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
'NAME': BASE_DIR / 'db.sqlite3',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
COMGATE_MERCHANT = 484757
|
COMGATE_MERCHANT = 484757
|
||||||
COMGATE_TEST = True
|
COMGATE_TEST = True
|
||||||
COMGATE_SECRET = '2c07bfabd1a5e4a312dc49929de60aa2'
|
COMGATE_SECRET = '2c07bfabd1a5e4a312dc49929de60aa2'
|
||||||
|
@ -15,7 +15,7 @@ Including another URLconf
|
|||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path, include
|
||||||
from alkatorapi.views import (
|
from alkatorapi.views import (
|
||||||
register_user, register_racer,
|
register_user, register_racer,
|
||||||
login, logout,
|
login, logout,
|
||||||
@ -51,4 +51,5 @@ urlpatterns = [
|
|||||||
path('api/cart/select_delivery', select_delivery),
|
path('api/cart/select_delivery', select_delivery),
|
||||||
path('api/cart/delivery', delivery),
|
path('api/cart/delivery', delivery),
|
||||||
path('api/forgotten_password', forgotten_password),
|
path('api/forgotten_password', forgotten_password),
|
||||||
]
|
path('', include('django_prometheus.urls')),
|
||||||
|
]
|
@ -10,7 +10,7 @@ class RacerAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
@admin.register(Product)
|
@admin.register(Product)
|
||||||
class ProductAdmin(admin.ModelAdmin):
|
class ProductAdmin(admin.ModelAdmin):
|
||||||
list_display = ("name", "description", "price", "quantity")
|
list_display = ("name", "description", "price", "hidden", "quantity")
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Invoice)
|
@admin.register(Invoice)
|
||||||
|
@ -118,8 +118,10 @@ ALKÁTOR TEAM
|
|||||||
email: info@alkator.cz
|
email: info@alkator.cz
|
||||||
tel: + 420 728 018 088
|
tel: + 420 728 018 088
|
||||||
web: https://alkator.cz""", "info@alkator.cz", [email])
|
web: https://alkator.cz""", "info@alkator.cz", [email])
|
||||||
mail.send()
|
if mail.send():
|
||||||
return HttpResponse('{"success":"Úspěšně poslán kód pro obnovení hesla uživatele '+ user.email + '", "redirect":"/#forgotten_password"}', content_type='application/json')
|
return HttpResponse('{"success":"Úspěšně poslán kód pro obnovení hesla uživatele '+ user.email + '", "redirect":"/#forgotten_password"}', content_type='application/json')
|
||||||
|
else:
|
||||||
|
return HttpResponse('{"reason":"Nepovedlo se odelat email"}', status=400, content_type='application/json')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
user = authenticate(request, username=request.POST['email'], password=request.POST['password'])
|
user = authenticate(request, username=request.POST['email'], password=request.POST['password'])
|
||||||
|
2
build.sh
Normal file
2
build.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
docker build -t gitea.angoosh.com/meiri/alkator/api:latest .
|
31
docker-compose.yml
Normal file
31
docker-compose.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
services:
|
||||||
|
api:
|
||||||
|
image: gitea.angoosh.com/meiri/alkator/api:latest
|
||||||
|
volumes:
|
||||||
|
- /home/meiri/alkator/db.sqlite3:/alkator/db.sqlite3
|
||||||
|
ports:
|
||||||
|
- "8005:8005"
|
||||||
|
networks:
|
||||||
|
- alkator
|
||||||
|
nginx:
|
||||||
|
image: nginx:1.27.2
|
||||||
|
ports:
|
||||||
|
- "8004:80"
|
||||||
|
volumes:
|
||||||
|
- /home/meiri/alkator/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
|
- /home/meiri/alkator/:/alkator
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.routers.alkatorweb.rule=Host(`zaloha.alkator.cz`)"
|
||||||
|
- "traefik.http.routers.alkatorweb.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.alkatorweb.tls.certresolver=letsencrypt"
|
||||||
|
- "traefik.http.services.alkatorweb.loadbalancer.server.port=80"
|
||||||
|
networks:
|
||||||
|
- alkator
|
||||||
|
- default
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: gateway
|
||||||
|
external: true
|
||||||
|
alkator:
|
69
nginx.conf
Normal file
69
nginx.conf
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
worker_processes 2;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
map $http_referer $httpReferer {
|
||||||
|
default "$http_referer";
|
||||||
|
"" "(direct)";
|
||||||
|
}
|
||||||
|
map $http_user_agent $httpAgent {
|
||||||
|
default "$http_user_agent";
|
||||||
|
"" "Unknown";
|
||||||
|
}
|
||||||
|
log_format json escape=json '{'
|
||||||
|
'"time_local": "$time_local", '
|
||||||
|
'"remote_addr": "$remote_addr", '
|
||||||
|
'"request_uri": "$request_uri", '
|
||||||
|
'"status": "$status", '
|
||||||
|
'"http_referer": "$httpReferer", '
|
||||||
|
'"http_user_agent": "$httpAgent", '
|
||||||
|
'"server_name": "$server_name", '
|
||||||
|
'"request_time": "$request_time" '
|
||||||
|
'}';
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
server_name zaloha.alkator.cz;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log json;
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
root /alkator/frontend/build;
|
||||||
|
|
||||||
|
location /api{
|
||||||
|
proxy_read_timeout 300;
|
||||||
|
proxy_pass http://api:8005;
|
||||||
|
}
|
||||||
|
location /api/upload_files{
|
||||||
|
client_max_body_size 100M;
|
||||||
|
proxy_pass http://api:8005;
|
||||||
|
}
|
||||||
|
location /admin {
|
||||||
|
proxy_pass http://api:8005;
|
||||||
|
}
|
||||||
|
location /static {
|
||||||
|
root /alkator;
|
||||||
|
}
|
||||||
|
location /photos {
|
||||||
|
root /alkator;
|
||||||
|
}
|
||||||
|
location /favicon.ico {
|
||||||
|
root /alkator;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/index.html =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user