Skip to content
Open
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
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
venv
.venv
.dockerignore
Dockerfile
.git
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,6 @@ cython_debug/

# PyPI configuration file
.pypirc
node_modules

node_modules/
party_app/static/css/output.css
48 changes: 27 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
###########

# pull official base image
FROM python:3.13-slim-bookworm as builder
FROM python:3.14-slim-bookworm AS builder

# install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# install system dependencies
RUN apt-get update \
&& apt-get -y install g++ ca-certificates curl gnupg \
&& apt-get -y install ca-certificates curl gnupg \
&& apt-get clean

# install node
ENV NODE_MAJOR=22
ENV NODE_MAJOR=24
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
Expand All @@ -21,26 +24,31 @@ RUN mkdir -p /etc/apt/keyrings && \
WORKDIR /usr/src/app

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# install python dependencies
COPY . .
RUN pip install --upgrade pip && pip wheel --no-cache-dir --wheel-dir /usr/src/app/wheels -r requirements.txt
# export production dependencies and install them
COPY pyproject.toml uv.lock ./
RUN uv export --no-hashes --no-dev > requirements.txt \
&& uv pip install --system --no-cache -r requirements.txt

# Install Node.js dependencies
# install Node.js dependencies
COPY package.json package-lock.json ./
RUN npm install

# Build Tailwind
RUN pip install -r requirements.txt && npm run tailwind:build
# build Tailwind
COPY . .
RUN npm run tailwind:build

#########
# FINAL #
#########

# pull official base image
FROM python:3.13-slim-bookworm
FROM python:3.14-slim-bookworm

# install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# upgrade system packages
RUN apt-get update && apt-get upgrade -y && apt-get clean
Expand All @@ -58,17 +66,15 @@ RUN mkdir $APP_HOME
WORKDIR $APP_HOME

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV ENVIRONMENT prod
ENV TESTING 0
ENV PYTHONPATH $APP_HOME
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV ENVIRONMENT=prod
ENV TESTING=0
ENV PYTHONPATH=$APP_HOME

# install dependencies
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*
RUN uv pip install --system --no-cache -r requirements.txt

# copy project
COPY . $APP_HOME
Expand All @@ -79,4 +85,4 @@ RUN chown -R app:app $HOME
# change to the app user
USER app
# serve the application
CMD exec uvicorn party_app.main:app --host 0.0.0.0 --port $PORT --proxy-headers --forwarded-allow-ips="*"
CMD exec fastapi run party_app/main.py --port $PORT --proxy-headers --forwarded-allow-ips="*"
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# End project for Full-stack FastAPI with HTMX and Tailwind course

This is how the project should looks like at then of the [Full-stack FastAPI with HTMX and Tailwind](https://testdriven.io/courses/fastapi-htmx/) course.

To see it in browser, run:
```shell
uv run alembic upgrade head
uv run fastapi dev party_app/main.py
```

To load the pre-prepared test data, run:
```shell
uv run python -m party_app.initial_data.load_initial_data_to_db
```
File renamed without changes.
2 changes: 2 additions & 0 deletions alembic/script.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}


def upgrade() -> None:
"""Upgrade schema."""
${upgrades if upgrades else "pass"}


def downgrade() -> None:
"""Downgrade schema."""
${downgrades if downgrades else "pass"}
4 changes: 2 additions & 2 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {defineConfig} = require('cypress');
import { defineConfig } from 'cypress';

module.exports = defineConfig({
export default defineConfig({
e2e: {
baseUrl: 'http://127.0.0.1:8000/',
},
Expand Down
2 changes: 1 addition & 1 deletion cypress/fixtures/party.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"party_date": "2028-08-26",
"party_date": "2029-08-26",
"party_time": "12:00",
"venue": "the party place",
"invitation": "Come to my awesome party!"
Expand Down
9 changes: 9 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
17 changes: 17 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
Binary file modified database.db
Binary file not shown.
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
version: "3.9"
services:
db:
image: postgres:17-alpine
image: postgres:18-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
- postgres_data:/var/lib/postgresql
environment:
POSTGRES_USER: party_user
POSTGRES_PASSWORD: party_password
Expand All @@ -17,5 +16,6 @@ services:
- "8000:8000"
depends_on:
- db

volumes:
postgres_data:
1 change: 0 additions & 1 deletion node_modules/.bin/detect-libc

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/jiti

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/tailwindcss

This file was deleted.

21 changes: 0 additions & 21 deletions node_modules/@parcel/watcher-darwin-arm64/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/@parcel/watcher-darwin-arm64/README.md

This file was deleted.

30 changes: 0 additions & 30 deletions node_modules/@parcel/watcher-darwin-arm64/package.json

This file was deleted.

Binary file not shown.
21 changes: 0 additions & 21 deletions node_modules/@parcel/watcher/LICENSE

This file was deleted.

Loading