Skip to content

Commit

Permalink
squashed commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hnthh committed Mar 30, 2024
1 parent b4ae7ad commit 3e90953
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions hooks/post_gen_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ requires = ["poetry-core"]
authors = ["Fedor Borshev <[email protected]>"]
description = ""
name = "django-fandsdev"
package-mode = false
readme = "README.md"
version = "2023.11.29"

Expand Down
2 changes: 1 addition & 1 deletion {{ cookiecutter.name }}/.github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions {{ cookiecutter.name }}/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"}]'
Expand Down
1 change: 1 addition & 0 deletions {{ cookiecutter.name }}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 3e90953

Please sign in to comment.