9 Commits

Author SHA1 Message Date
615d4e59c6 Fix collectstaticfiles causing error when restarting container
All checks were successful
continuous-integration/drone/push Build is passing
Fixes #23
2023-01-08 15:38:56 +01:00
83f075e49d Update version, changelog
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-08 15:31:35 +01:00
d3682368b4 Fix CSRF error
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-08 15:23:04 +01:00
c9b2d5bd8d Update changelog
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-07 22:08:57 +01:00
0d20b543b0 Do not load the admin interface in prod
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-07 21:59:54 +01:00
f7b69f7704 Add more utilities to Makefile 2023-01-07 21:59:34 +01:00
1ccfdc321a Start caddy in the background 2023-01-07 21:59:17 +01:00
25a58c2732 Be more explicit in docker-compose.yml 2023-01-07 21:59:09 +01:00
270d9f7296 Ignore static folder when building container 2023-01-07 21:58:22 +01:00
9 changed files with 36 additions and 16 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
src/web/static/*

View File

@ -1,3 +1,15 @@
## Unreleased
* Fix collectstaticfiles causing error when restarting container (https://git.kucharczyk.xyz/lukas/timetracker/issues/23)
## 0.1.3 / 2023-01-08 15:23+01:00
* Fix CSRF error (https://git.kucharczyk.xyz/lukas/timetracker/pulls/22)
## 0.1.2 / 2023-01-07 22:05+01:00
* Switch to Uvicorn/Gunicorn + Caddy (https://git.kucharczyk.xyz/lukas/timetracker/pulls/4)
## 0.1.1 / 2023-01-05 23:26+01:00
* Order by timestamp_start by default
* Add pre-commit hook to update version

View File

@ -6,10 +6,11 @@ RUN npm install && \
FROM python:3.10.9-alpine
ENV VERSION_NUMBER 0.1.1-3-gd029fda
ENV VERSION_NUMBER 0.1.2-3-g83f075e
ENV PROD 1
RUN apk add \
bash \
vim \
curl \
caddy

View File

@ -1,5 +1,3 @@
.PHONY: createsuperuser shell cleanstatic
all: css migrate
initialize: npm css migrate sethookdir loadplatforms
@ -24,8 +22,11 @@ migrate: makemigrations
dev: migrate sethookdir
poetry run python src/web/manage.py runserver_plus
caddy:
caddy run --watch
dev-prod: migrate collectstatic sethookdir
cd src/web/; poetry run python -m gunicorn --bind 0.0.0.0:8001 web.asgi:application -k uvicorn.workers.UvicornWorker
cd src/web/; PROD=1 poetry run python -m gunicorn --bind 0.0.0.0:8001 web.asgi:application -k uvicorn.workers.UvicornWorker
dumptracker:
poetry run python src/web/manage.py dumpdata --format yaml tracker --output tracker_fixture.yaml
@ -43,7 +44,7 @@ shell:
poetry run python src/web/manage.py shell
collectstatic:
poetry run python src/web/manage.py collectstatic
poetry run python src/web/manage.py collectstatic -c --no-input
poetry.lock: pyproject.toml
poetry install

View File

@ -1,9 +1,10 @@
---
version: "2.1"
services:
timetracker:
image: registry.kucharczyk.xyz/timetracker
build: Dockerfile
build:
context: .
dockerfile: Dockerfile
container_name: timetracker
environment:
- TZ=Europe/Prague

View File

@ -5,9 +5,9 @@ echo "Apply database migrations"
poetry run python src/web/manage.py migrate
echo "Collect static files"
poetry run python src/web/manage.py collectstatic
poetry run python src/web/manage.py collectstatic --clear --no-input
echo "Starting server"
caddy run
caddy start
cd src/web || exit
poetry run python -m gunicorn --bind 0.0.0.0:8001 web.asgi:application -k uvicorn.workers.UvicornWorker

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "timetracker"
version = "0.1.1"
version = "0.1.2"
description = "A simple time tracker."
authors = ["Lukáš Kucharczyk <lukas@kucharczyk.xyz>"]
license = "GPL"

View File

@ -145,7 +145,8 @@ LOGGING = {
},
}
CSRF_TRUSTED_ORIGINS = []
if os.environ.get("PROD"):
CSRF_TRUSTED_ORIGINS.append(os.environ.get("CSRF_TRUSTED_ORIGINS"))
_csrf_trusted_origins = os.environ.get("CSRF_TRUSTED_ORIGINS")
if _csrf_trusted_origins:
CSRF_TRUSTED_ORIGINS = _csrf_trusted_origins.split(",")
else:
CSRF_TRUSTED_ORIGINS = []

View File

@ -16,10 +16,13 @@ Including another URLconf
from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView
from django.conf import settings
urlpatterns = [
path("admin/", admin.site.urls),
path("", RedirectView.as_view(url="/tracker/list-sessions")),
path("tracker/", include("tracker.urls")),
]
if settings.DEBUG:
urlpatterns.append(path("admin/", admin.site.urls))