Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ env/
venv/
.vscode/
__pycache__/
db/
db/
.venv
30 changes: 13 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

jobs:
run_unit_tests:
run_tests:
runs-on: ubuntu-latest
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
Expand All @@ -14,36 +14,32 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: '3.13'
version: "0.10.4"

- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
run: uv sync

- name: Run Ruff linter
uses: astral-sh/ruff-action@v3

- name: Run Django checks
run: |
source venv/bin/activate
python manage.py check && python manage.py makemigrations --check --dry-run
- name: Run Django system check
run: uv run manage.py check

- name: Run Django makemigrations check
run: uv run manage.py makemigrations --check --dry-run

- name: Run Django unit tests
run: |
source venv/bin/activate
python manage.py test
run: uv run manage.py test

build_docker_image:
runs-on: ubuntu-latest
needs: [run_unit_tests]
needs: [run_tests]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build Docker image
run: docker build --file Dockerfile.prod .
run: docker build --file Dockerfile .
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ db.sqlite3
/env/*
env
venv
.venv
__pycache__
db/
staticfiles/
node_modules
static/js/bundles
static/favicons
*.override.yml
*.override.yml
64 changes: 34 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
FROM node:25.2.1-alpine3.23 AS node-builder

WORKDIR /usr/src/app
COPY package.json package-lock.json ./

RUN ["/bin/sh", "-c", "npm install"]
## NODE BUILDER ##
FROM node:25.6-slim AS node-builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY assets ./assets
COPY webpack.config.js .
RUN npm run build

RUN ["/bin/sh", "-c", "npm run dev"]

FROM python:3.14.2-alpine3.23

# Security updates
# RUN apt-get update && apt-get upgrade -y && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN ["/bin/sh", "-c", "apk update && apk upgrade && rm -rf /var/cache/apk/*"]

# alpine dependencies
RUN ["/bin/sh", "-c", "apk add --no-cache python3-dev py3-setuptools \
musl-dev gcc cargo \
tiff-dev jpeg-dev openjpeg-dev zlib-dev freetype-dev lcms2-dev \
libwebp-dev tcl-dev tk-dev harfbuzz-dev fribidi-dev libimagequant-dev \
libxcb-dev libpng-dev"]

## PYTHON BUILDER ##
FROM python:3.14-slim AS python-builder
WORKDIR /app

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

RUN ["/bin/sh", "-c", "pip install --upgrade pip"]
COPY ./requirements.txt .
RUN ["/bin/sh", "-c", "pip install -r requirements.txt"]

COPY --from=ghcr.io/astral-sh/uv:0.10.4 /uv /uvx /bin/
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1

## DEVELOPMENT STAGE ##
FROM python-builder AS development
RUN apt-get update && apt-get install -y nodejs npm && rm -rf /var/lib/apt/lists/*
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
uv sync --frozen --group dev
COPY . .
ENV PATH="/app/.venv/bin:$PATH"

## PRODUCTION STAGE ##
FROM python-builder AS production
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -g 1001 app && \
useradd -u 1001 -g app -s /bin/sh -m app
WORKDIR /app
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
uv sync --frozen --no-dev
COPY --from=node-builder /app/static/js/bundles ./static/js/bundles
COPY . .
COPY --from=node-builder /usr/src/app/static/js/bundles ./static/js/bundles
RUN chown -R app:app /app
USER app
ENV PATH="/app/.venv/bin:$PATH"
62 changes: 0 additions & 62 deletions Dockerfile.prod

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Personal website that includes a portfolio and a blog. Made with [Django](https:
- ``package.json``

#### Installation
- ``pip install -r requirements.txt`` (or ``requirements.dev.txt``)
- ``uv sync [--group dev]``
- ``npm install``

### Environment variables
Expand Down Expand Up @@ -64,7 +64,8 @@ Personal website that includes a portfolio and a blog. Made with [Django](https:

## Development
### Generating the requirements lock
``./pip-compile.sh``
- ``uv lock [--upgrade]``
- ``npm update``

### Making changes to models
1. Make changes in ``models.py``
Expand Down
2 changes: 0 additions & 2 deletions constraints.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
services:
portfolio:
build:
dockerfile: Dockerfile.prod
target: production
command: >
sh -c "
python manage.py migrate &&
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ services:
build:
context: .
dockerfile: Dockerfile
target: development
command: >
sh -c "
npm run dev &&
python manage.py migrate &&
python manage.py collectstatic --noinput &&
python manage.py runserver 0.0.0.0:8000"
Expand Down
2 changes: 0 additions & 2 deletions pip-compile.sh

This file was deleted.

17 changes: 12 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "portfolio"
version = "2025.12"
readme = "README.md"
requires-python = ">=3.14.2"
requires-python = ">=3.14"
authors = [
{name = "Bryan Grigorie", email = "bryangrigorie@gmail.com"},
]
Expand All @@ -20,9 +20,16 @@ dependencies = [
"django-constance==4.3.4",
]

[project.optional-dependencies]
dev = [
"pip-tools >= 7.5.2",
"wheel >= 0.46.2",
[dependency-groups]
lint = [
"ruff",
]
dev = [
{include-group = "lint"},
]

[tool.uv]
constraint-dependencies = [
"cryptography>=46.0.5",
"sqlparse>=0.5.4",
]
92 changes: 0 additions & 92 deletions requirements.dev.txt

This file was deleted.

Loading