Compare commits

...

26 Commits
master ... beta

Author SHA1 Message Date
Martin Quarda
1f8d092dd0 maybe smaller dockerimage 2024-10-31 11:34:17 +01:00
Martin Quarda
ba4ed4de37 pip in Dockerfile 2024-10-30 16:07:40 +01:00
Martin Quarda
754d2d7c2b django prometheus in Dockerfile 2024-10-30 16:04:21 +01:00
Martin Quarda
c5fa34446e fix zaloha.alkator.cz/admin 2024-10-30 15:59:45 +01:00
Martin Quarda
1fd44949eb maybe fix? 2024-10-30 15:57:27 +01:00
Martin Quarda
a280cabff1 metrics 2024-10-30 08:04:52 +01:00
Martin Quarda
882f1e26b3 fix 2024-10-25 07:14:38 +02:00
Martin Quarda
c207a26814 fix 2024-10-25 07:07:54 +02:00
Martin Quarda
c1afe21457 fix addres 2024-10-24 17:11:27 +02:00
Martin Quarda
3bd7e0f1b4 fix requests 2024-10-24 17:08:46 +02:00
Martin Quarda
8b53d213e9 maybe fix? 2024-10-24 16:58:53 +02:00
Martin Quarda
64d13090dc update image 2024-10-24 16:40:45 +02:00
Martin Quarda
00274fd033 changes from angoosh 2024-10-24 16:15:29 +02:00
Martin Quarda
ef502854ee fixes 2024-10-24 16:12:39 +02:00
Martin Quarda
b85c6e7b53 fixes 2024-10-24 15:08:05 +02:00
Martin Quarda
44aefef3dd rename docker.yaml 2024-10-24 14:54:11 +02:00
8c05dd48e7 added networks 2024-10-24 14:47:59 +02:00
2fda59f451 changed nginx external port, because port 80 is set for traefik 2024-10-24 14:45:59 +02:00
61149eadee Update compose.yaml 2024-10-24 14:44:43 +02:00
Martin Quarda
a3c51f3b5f fixes 2024-10-24 14:28:23 +02:00
Martin Quarda
c6aaccda67 fixes 2024-10-24 14:06:30 +02:00
Martin Quarda
4abf616637 fix 2024-10-24 13:58:35 +02:00
Martin Quarda
211f6c75ad commit 2024-10-24 13:55:52 +02:00
Martin Quarda
e411e71b89 build page 2024-10-24 11:18:03 +02:00
Martin Quarda
d7411d90c4 test dockerfile 2024-10-24 10:57:10 +02:00
Martin Quarda
abdb62fd55 fixes 2024-10-18 16:25:56 +02:00
9 changed files with 132 additions and 9 deletions

9
Dockerfile Normal file
View 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"]

View File

@ -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!
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
INSTALLED_APPS = [
'daphne',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
@ -39,9 +40,11 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'alkatorapi',
'django_prometheus',
]
MIDDLEWARE = [
'django_prometheus.middleware.PrometheusBeforeMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
@ -49,8 +52,12 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'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'
TEMPLATES = [
@ -70,6 +77,7 @@ TEMPLATES = [
]
WSGI_APPLICATION = 'alkator.wsgi.application'
ASGI_APPLICATION = 'alkator.asgi.application'
SESSION_COOKIE_SECURE = True
@ -78,12 +86,11 @@ SESSION_COOKIE_SECURE = True
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'ENGINE': 'django_prometheus.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
COMGATE_MERCHANT = 484757
COMGATE_TEST = True
COMGATE_SECRET = '2c07bfabd1a5e4a312dc49929de60aa2'

View File

@ -15,7 +15,7 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
from alkatorapi.views import (
register_user, register_racer,
login, logout,
@ -51,4 +51,5 @@ urlpatterns = [
path('api/cart/select_delivery', select_delivery),
path('api/cart/delivery', delivery),
path('api/forgotten_password', forgotten_password),
path('', include('django_prometheus.urls')),
]

View File

@ -10,7 +10,7 @@ class RacerAdmin(admin.ModelAdmin):
@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
list_display = ("name", "description", "price", "quantity")
list_display = ("name", "description", "price", "hidden", "quantity")
@admin.register(Invoice)

View File

@ -118,8 +118,10 @@ ALKÁTOR TEAM
email: info@alkator.cz
tel: + 420 728 018 088
web: https://alkator.cz""", "info@alkator.cz", [email])
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')
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')
else:
return HttpResponse('{"reason":"Nepovedlo se odelat email"}', status=400, content_type='application/json')
else:
try:
user = authenticate(request, username=request.POST['email'], password=request.POST['password'])

2
build.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/bash
docker build -t gitea.angoosh.com/meiri/alkator/api:latest .

31
docker-compose.yml Normal file
View 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
View 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;
}
}
}

2
push.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/bash
docker push gitea.angoosh.com/meiri/alkator/api:latest