-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,067 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,20 @@ | ||
FROM python:3.11-alpine as builder | ||
FROM python:3.11.5-slim | ||
|
||
ENV PYTHONFAULTHANDLER=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
POETRY_VERSION=1.2.2 \ | ||
POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_CREATE=false \ | ||
POETRY_CACHE_DIR='/var/cache/pypoetry' \ | ||
PATH="$PATH:/root/.local/bin" | ||
|
||
RUN apk add --no-cache \ | ||
gcc \ | ||
musl-dev \ | ||
postgresql-dev \ | ||
libffi-dev \ | ||
openssl-dev \ | ||
cargo \ | ||
curl \ | ||
gettext \ | ||
git | ||
|
||
RUN curl -sSL https://install.python-poetry.org | python3 - && poetry --version | ||
UV_NO_SYNC=1 \ | ||
UV_COMPILE_BYTECODE=1 | ||
|
||
WORKDIR /usr/local/src/hexlet-friends | ||
|
||
COPY . . | ||
|
||
RUN poetry install --extras psycopg2-binary --only main | ||
|
||
FROM python:3.11-alpine as runner | ||
|
||
ENV PYTHONFAULTHANDLER=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 | ||
|
||
RUN apk add --no-cache libpq gettext | ||
|
||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup | ||
COPY pyproject.toml uv.lock ./ | ||
|
||
COPY --from=builder /usr/local/src/hexlet-friends /usr/local/src/hexlet-friends | ||
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages | ||
COPY --from=builder /usr/local/bin /usr/local/bin | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends make git | ||
|
||
RUN chown -R appuser:appgroup /usr/local/src/hexlet-friends | ||
|
||
USER appuser | ||
|
||
WORKDIR /usr/local/src/hexlet-friends | ||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | ||
|
||
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] | ||
RUN git config --global --add safe.directory "$(pwd)" | ||
RUN uv sync |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,18 +2,17 @@ | |
test ! -f .env && cp .env.example .env | ||
|
||
build-production: | ||
poetry install --extras psycopg2-binary | ||
pip install -r requirements.txt | ||
$(MAKE) collectstatic | ||
$(MAKE) migrate | ||
|
||
build: | ||
poetry install --extras psycopg2-binary | ||
poetry run python manage.py migrate | ||
uv run python manage.py migrate | ||
|
||
check: lint test requirements.txt | ||
|
||
collectstatic: | ||
poetry run python manage.py collectstatic --no-input | ||
uv run python manage.py collectstatic --no-input | ||
|
||
compose-build: .env | ||
docker compose build | ||
|
@@ -40,68 +39,68 @@ deploy: | |
git push heroku | ||
|
||
setup-pre-commit-hooks: | ||
poetry run pre-commit install | ||
uv run pre-commit install | ||
|
||
install-dependencies: .env | ||
poetry install --extras psycopg2-binary | ||
uv sync | ||
|
||
install: install-dependencies setup-pre-commit-hooks | ||
|
||
lint: | ||
poetry run flake8 | ||
uv run ruff check | ||
|
||
migrate: | ||
poetry run python manage.py migrate | ||
uv run python manage.py migrate | ||
|
||
requirements.txt: poetry.lock | ||
poetry export --format requirements.txt --output requirements.txt --extras psycopg2 --without-hashes | ||
requirements.txt: | ||
uv pip compile pyproject.toml -o requirements.txt | ||
|
||
secretkey: | ||
poetry run python -c 'from django.utils.crypto import get_random_string; print(get_random_string(40))' | ||
uv run python -c 'from django.utils.crypto import get_random_string; print(get_random_string(40))' | ||
|
||
setup: install | ||
$(MAKE) migrate | ||
$(MAKE) updatesuperuser | ||
|
||
updatesuperuser: | ||
poetry run python manage.py updatesuperuser --username admin --email [email protected] | ||
uv run python manage.py updatesuperuser --username admin --email [email protected] | ||
|
||
shell: | ||
poetry run python manage.py shell_plus --plain | ||
uv run python manage.py shell_plus --plain | ||
|
||
start-deploy: | ||
gunicorn config.wsgi | ||
uv run gunicorn config.wsgi | ||
|
||
start-production: | ||
gunicorn -b 0.0.0.0:8000 config.wsgi:application | ||
uv run gunicorn -b 0.0.0.0:8000 config.wsgi:application | ||
|
||
start: | ||
poetry run python manage.py runserver 0.0.0.0:8000 | ||
uv run python manage.py runserver 0.0.0.0:8000 | ||
|
||
sync: | ||
poetry run python manage.py fetchdata $(ARGS) | ||
uv run python manage.py fetchdata $(ARGS) | ||
|
||
test-coverage-report-xml: | ||
poetry run coverage xml | ||
uv run coverage xml | ||
|
||
test-coverage-report: test | ||
poetry run coverage report -m $(ARGS) | ||
poetry run coverage erase | ||
uv run coverage report -m $(ARGS) | ||
uv run coverage erase | ||
|
||
test: | ||
poetry run coverage run --source='.' manage.py test | ||
uv run coverage run --source='.' manage.py test | ||
|
||
transcompile: | ||
poetry run django-admin compilemessages | ||
uv run django-admin compilemessages | ||
|
||
# Need to have GNU gettext installed | ||
transprepare: | ||
poetry run django-admin makemessages --locale ru --add-location file | ||
poetry run django-admin makemessages --locale ru --add-location file --domain djangojs | ||
uv run django-admin makemessages --locale ru --add-location file | ||
uv run django-admin makemessages --locale ru --add-location file --domain djangojs | ||
|
||
# Need to have graphviz installed | ||
erd-dot: | ||
poetry run python manage.py graph_models -a -g > erd.dot | ||
uv run python manage.py graph_models -a -g > erd.dot | ||
|
||
erd-in-png: erd-dot | ||
dot -Tpng erd.dot -o erd.png | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.