diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 2128ada1..0188efd3 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -7,7 +7,7 @@ runs: - name: install poetry uses: snok/install-poetry@v1 with: - version: 1.6.1 + version: 1.8.2 - name: install python id: setup-python diff --git a/Makefile b/Makefile index cefffa1b..a361c757 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,16 @@ -remove-prev-generated-project-if-exists: - if [ -d "testproject" ]; then \ - cd testproject && docker compose down --volumes; \ - cd .. && rm -Rf testproject; \ - fi +setup-dev-environment: + cp {{\ cookiecutter.name\ }}/docker-compose.yml ./ -bootstrap: remove-prev-generated-project-if-exists + docker-compose down --volumes + docker-compose up --detach + + rm -rf testproject + +bootstrap: setup-dev-environment poetry run cookiecutter --no-input ./ + rm docker-compose.yml + fmt: poetry run toml-sort pyproject.toml diff --git a/README.md b/README.md index 1a333e5b..695ece3b 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ ## Installation +First, make sure you have `PostgreSQL` up and running (check the `{{ cookiecutter.name }}/src/app/.env.ci` `DATABASE_URL` and `{{ cookiecutter.name }}/docker-compose.yml` for configuration). After that: + ```bash poetry install diff --git a/hooks/post_gen_project.sh b/hooks/post_gen_project.sh index 984636f4..b5d0f7c2 100644 --- a/hooks/post_gen_project.sh +++ b/hooks/post_gen_project.sh @@ -2,15 +2,14 @@ cp src/app/.env.ci src/app/.env -docker compose up --detach - poetry install poetry run python src/manage.py collectstatic poetry run python src/manage.py startapp some_app poetry run python src/manage.py makemigrations -n "initial" -poetry run python src/manage.py migrate poetry run isort src/users/migrations/0001_initial.py +poetry run python src/manage.py migrate + make lint test diff --git a/pyproject.toml b/pyproject.toml index 12482758..b20f5181 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ requires = ["poetry-core"] authors = ["Fedor Borshev "] description = "" name = "django-fandsdev" +package-mode = false readme = "README.md" version = "2023.11.29" diff --git a/{{ cookiecutter.name }}/.github/actions/build/action.yml b/{{ cookiecutter.name }}/.github/actions/build/action.yml index c3ebdd03..41a6ed4e 100644 --- a/{{ cookiecutter.name }}/.github/actions/build/action.yml +++ b/{{ cookiecutter.name }}/.github/actions/build/action.yml @@ -15,7 +15,7 @@ runs: if: steps.cached-poetry.outputs.cache-hit != true uses: snok/install-poetry@v1 with: - version: 1.6.1 + version: 1.8.2 - name: install python id: setup-python diff --git a/{{ cookiecutter.name }}/Dockerfile b/{{ cookiecutter.name }}/Dockerfile index 5958e3db..ae69f989 100644 --- a/{{ cookiecutter.name }}/Dockerfile +++ b/{{ cookiecutter.name }}/Dockerfile @@ -1,23 +1,31 @@ ARG PYTHON_VERSION +# +# Compile custom uwsgi, cuz debian's one is weird +# FROM python:${PYTHON_VERSION}-slim-bookworm as uwsgi-compile - ENV _UWSGI_VERSION 2.0.24 - RUN apt-get update && apt-get --no-install-recommends install -y build-essential wget && rm -rf /var/lib/apt/lists/* RUN wget -O uwsgi-${_UWSGI_VERSION}.tar.gz https://github.com/unbit/uwsgi/archive/${_UWSGI_VERSION}.tar.gz \ && tar zxvf uwsgi-*.tar.gz \ && UWSGI_BIN_NAME=/uwsgi make -C uwsgi-${_UWSGI_VERSION} \ && rm -Rf uwsgi-* +# +# Build poetry and export compiled dependecines as plain requirements.txt +# FROM python:${PYTHON_VERSION}-slim-bookworm as deps-compile WORKDIR / COPY poetry.lock pyproject.toml / +# Version is taken from poetry.lock, assuming it is generated with up-to-date version of poetry RUN pip install --no-cache-dir poetry==$(cat poetry.lock |head -n1|awk -v FS='(Poetry |and)' '{print $2}') RUN poetry export --format=requirements.txt > requirements.txt +# +# Base image with django dependecines +# FROM python:${PYTHON_VERSION}-slim-bookworm as base LABEL maintainer="{{ cookiecutter.email }}" LABEL com.datadoghq.ad.logs='[{"service": "django", "source": "uwsgi"}]' diff --git a/{{ cookiecutter.name }}/pyproject.toml b/{{ cookiecutter.name }}/pyproject.toml index b986f1a0..e96048ef 100644 --- a/{{ cookiecutter.name }}/pyproject.toml +++ b/{{ cookiecutter.name }}/pyproject.toml @@ -6,6 +6,7 @@ requires = ["poetry-core"] authors = ["{{ cookiecutter.author }} <{{ cookiecutter.email }}>"] description = "{{ cookiecutter.description }}" name = "{{ cookiecutter.name }}" +package-mode = false readme = "README.md" version = "0.0.0-dev"