diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..c4f55ef --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,13 @@ +#!/bin/bash +set -euo pipefail +echo "----------------" +echo "Pre-commit hooks" +echo "================" +VERSION_NUMBER=$(git describe --tags) +echo "Updating "VERSION_NUMBER" in Dockerfile to $VERSION_NUMBER" +sed -i "s/^ENV VERSION_NUMBER.*$/ENV VERSION_NUMBER ${VERSION_NUMBER}/" Dockerfile +echo "Updating "version" in pyproject.toml to $VERSION_NUMBER" +sed -i "s/^version = \".*\"$/version = \"${VERSION_NUMBER}\"/" pyproject.toml +git add Dockerfile +git add pyproject.toml +echo "----------------" diff --git a/CHANGELOG.md b/CHANGELOG.md index cb7f530..ed9b58b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## Unreleased +* Add pre-commit hook to update version * Improve the newcomer experience by guiding through each step * Fix errors with empty database * Fix negative playtimes being considered positive diff --git a/Dockerfile b/Dockerfile index b0d53a2..db1bd4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,23 @@ +FROM node as css +COPY . / +RUN apt install -y npm && \ + npm install && \ + npx tailwindcss -i ./src/input.css -o ./src/web/tracker/static/base.css --minify + FROM python:3.10-slim-bullseye -ENV VIRTUAL_ENV=/opt/venv -RUN python3 -m venv pip $VIRTUAL_ENV -ENV PATH="$VIRTUAL_ENV/bin:$PATH" -RUN pip install --no-cache-dir poetry -RUN useradd --create-home --uid 1000 timetracker + +ENV VERSION_NUMBER 0.1.0-34-g8efce77 + +RUN useradd --create-home --uid 1000 timetracker && \ + pip install --no-cache-dir poetry && \ + poetry install --without dev + WORKDIR /home/timetracker/app COPY . /home/timetracker/app/ RUN chown -R timetracker:timetracker /home/timetracker/app -RUN poetry install --without dev + COPY entrypoint.sh / RUN chmod +x /entrypoint.sh USER timetracker EXPOSE 8000 -ENV VERSION_NUMBER 0.1.0-18-gb8a15e4 ENTRYPOINT [ "/entrypoint.sh" ] \ No newline at end of file diff --git a/Makefile b/Makefile index 25323e6..e34d4ff 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ all: css migrate -initialize: npm css migrate loadplatforms +initialize: npm css migrate sethookdir loadplatforms HTMLFILES := $(shell find src/web/tracker/templates -type f) @@ -21,7 +21,7 @@ makemigrations: migrate: makemigrations poetry run python src/web/manage.py migrate -dev: migrate +dev: migrate sethookdir TZ=Europe/Prague poetry run python src/web/manage.py runserver dumptracker: @@ -43,4 +43,7 @@ poetry.lock: pyproject.toml poetry install test: poetry.lock - poetry run pytest \ No newline at end of file + poetry run pytest + +sethookdir: + git config core.hooksPath .githooks \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 0cd21cf..a988d0a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "timetracker" -version = "0.0.0" +version = "0.1.0-34-g8efce77" description = "A simple time tracker." authors = ["Lukáš Kucharczyk "] license = "GPL" @@ -15,6 +15,10 @@ black = "^22.12.0" mypy = "^0.991" pyyaml = "^6.0" pytest = "^7.2.0" +django-extensions = "^3.2.1" +werkzeug = "^2.2.2" +djlint = "^1.19.11" +djhtml = "^1.5.2" [build-system] requires = ["poetry-core"]