Compare commits

..

79 Commits

Author SHA1 Message Date
Sebastián Ramírez 7e5ca88dc2 🔖 Release version 0.7.1 2024-09-27 15:30:04 +02:00
github-actions 451c656fb0 📝 Update release notes 2024-09-24 09:53:03 +00:00
Sebastián Ramírez 911223516c 👷 Use uv cache on GitHub Actions (#1366) 2024-09-24 11:52:42 +02:00
github-actions 1f666c4907 📝 Update release notes 2024-09-23 22:29:32 +00:00
Sebastián Ramírez 32227c4020 👷 Update GitHub Actions format (#1363) 2024-09-24 00:29:10 +02:00
github-actions cdc7b50fec 📝 Update release notes 2024-09-23 22:05:47 +00:00
Sebastián Ramírez 284527b7bc 👷 Use uv for Python env to generate client (#1362) 2024-09-24 00:05:29 +02:00
github-actions 6ed7aee371 📝 Update release notes 2024-09-23 21:27:39 +00:00
Sebastián Ramírez 39325ad421 👷 Run tests from Python environment (with uv), not from Docker container (#1361) 2024-09-23 23:27:21 +02:00
github-actions b3a77946cb 📝 Update release notes 2024-09-23 20:36:34 +00:00
Sebastián Ramírez 9b2e5813ae 🔨 Update generate-client.sh script, make it fail on errors, fix generation (#1360) 2024-09-23 22:36:14 +02:00
github-actions 55ad3b21ee 📝 Update release notes 2024-09-23 20:09:35 +00:00
Sebastián Ramírez d2020c1a37 ♻️ Update settings to use top level .env file (#1359) 2024-09-23 22:09:11 +02:00
github-actions 6fc03d1bf4 📝 Update release notes 2024-09-23 19:35:36 +00:00
Sebastián Ramírez 0435937f8e 👷 Add GitHub Actions workflow to lint backend apart from tests (#1358) 2024-09-23 21:35:18 +02:00
github-actions 8d9af8cb80 📝 Update release notes 2024-09-23 16:53:28 +00:00
Sebastián Ramírez 4fc9610175 💡 Add comments to Dockerfile with uv references (#1357) 2024-09-23 16:53:08 +00:00
github-actions 4b6fb7c465 📝 Update release notes 2024-09-23 14:11:09 +00:00
Sebastián Ramírez 81048277c7 ⬆️ Migrate from Poetry to uv (#1356) 2024-09-23 16:10:46 +02:00
github-actions fa97b372b4 📝 Update release notes 2024-09-23 11:40:12 +00:00
Sebastián Ramírez c8104d8ced 🔥 Remove logic for development dependencies and Jupyter, it was never documented, and I no longer use that trick (#1355) 2024-09-23 13:39:54 +02:00
github-actions 7ed8694643 📝 Update release notes 2024-09-22 22:29:44 +00:00
Sebastián Ramírez 4cd67f3483 ♻️ Use Docker Compose watch (#1354) 2024-09-23 00:29:23 +02:00
github-actions b262c2053c 📝 Update release notes 2024-09-22 16:25:47 +00:00
Sebastián Ramírez 651643982b 🔧 Use plain base official Python Docker image (#1351) 2024-09-22 18:25:29 +02:00
github-actions 224d0e31a8 📝 Update release notes 2024-09-22 16:20:17 +00:00
Sebastián Ramírez 87254dd79e 🚚 Move location of scripts to simplify file structure (#1352) 2024-09-22 18:19:57 +02:00
github-actions 68a7fe0899 📝 Update release notes 2024-09-20 15:13:01 +00:00
Sebastián Ramírez 8fe66c1cc1 ♻️ Refactor prestart (migrations), move that to its own container (#1350) 2024-09-20 17:12:40 +02:00
github-actions d87b6391b5 📝 Update release notes 2024-09-20 12:53:11 +00:00
Sebastián Ramírez 889a9bf5bf ⬆️ Upgrade FastAPI (#1349) 2024-09-20 14:52:45 +02:00
github-actions 44ff5730b7 📝 Update release notes 2024-09-20 12:43:51 +00:00
Sebastián Ramírez e64c9100ec ♻️ Include FRONTEND_HOST in CORS origins by default (#1348) 2024-09-20 14:43:32 +02:00
github-actions a292dbe10d 📝 Update release notes 2024-09-19 18:11:52 +00:00
Sebastián Ramírez 79d240f5b7 ♻️ Simplify domains with api.example.com for API and dashboard.example.com for frontend, improve local development with localhost (#1344) 2024-09-19 18:11:33 +00:00
github-actions 110a59c71d 📝 Update release notes 2024-09-16 22:26:45 +00:00
Sebastián Ramírez 2062b5b671 🔥 Simplify Traefik, remove www-redirects that add complexity (#1343) 2024-09-17 00:26:26 +02:00
github-actions 07b568b4f6 📝 Update release notes 2024-09-16 19:52:57 +00:00
Sebastián Ramírez 8a8a90459d 🩺 Add DB healthcheck (#1342) 2024-09-16 21:52:33 +02:00
github-actions eb88b52ff8 📝 Update release notes 2024-09-16 19:43:09 +00:00
Sebastián Ramírez 18a5cb21db 🔥 Enable support for Arm Docker images in Mac, remove old patch (#1341) 2024-09-16 21:42:50 +02:00
github-actions 46ac6a3c6f 📝 Update release notes 2024-09-12 13:21:44 +00:00
Patrick Arminio 97d04cd7ff 👷 Improve playwright CI job (#1335) 2024-09-12 15:21:24 +02:00
github-actions b3a49ae32e 📝 Update release notes 2024-09-07 15:20:44 +00:00
Sebastián Ramírez 4af652aa73 👷 Update issue-manager.yml (#1329) 2024-09-07 17:20:24 +02:00
github-actions ad3580703c 📝 Update release notes 2024-09-02 20:48:36 +00:00
Sofie Van Landeghem 2241d75131 set include-hidden-files to true for actions/upload-artifact@v4 (#1327) 2024-09-02 22:48:18 +02:00
github-actions 33b379bd46 📝 Update release notes 2024-08-29 18:11:08 +00:00
Alejandra bbad34aa8d 👷🏻 Auto-generate frontend client (#1320) 2024-08-29 20:10:49 +02:00
github-actions e8c73ff614 📝 Update release notes 2024-08-29 15:46:18 +00:00
Alejandra 644de7f186 🐛 Fix in .github/labeler.yml (#1322) 2024-08-29 17:46:02 +02:00
github-actions 90e3e337cb 📝 Update release notes 2024-08-29 15:38:45 +00:00
Alejandra 2fb7354923 👷 Update .github/labeler.yml (#1321) 2024-08-29 15:38:22 +00:00
github-actions 05bc1412b3 📝 Update release notes 2024-08-26 02:18:04 +00:00
Sebastián Ramírez 375170c386 👷 Update latest-changes GitHub Action (#1315) 2024-08-26 02:17:32 +00:00
github-actions 5005e5a5c1 📝 Update release notes 2024-08-17 18:59:41 +00:00
Alejandra 77040adf86 📝 Add Email Templates to backend/README.md (#1311) 2024-08-17 13:59:22 -05:00
github-actions 65c66f2050 📝 Update release notes 2024-08-15 20:43:14 +00:00
Sebastián Ramírez 8187a5283f 👷 Update configs for labeler (#1308) 2024-08-15 15:42:54 -05:00
github-actions 66c4ff169d 📝 Update release notes 2024-08-15 18:49:23 +00:00
Sebastián Ramírez d7d245a108 👷 Do not sync labels as it overrides manually added labels (#1307) 2024-08-15 13:48:43 -05:00
github-actions 6eff776fc1 📝 Update release notes 2024-08-14 19:12:46 +00:00
Sebastián Ramírez de57a7bac1 👷 Update GitHub Action labeler to add only one label (#1304) 2024-08-14 14:12:29 -05:00
github-actions 0f082d1265 📝 Update release notes 2024-08-14 14:57:14 +00:00
dependabot[bot] 5a138697ec ⬆️ Bump axios from 1.6.2 to 1.7.4 in /frontend (#1301)
Bumps [axios](https://github.com/axios/axios) from 1.6.2 to 1.7.4.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.6.2...v1.7.4)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alejandra <90076947+alejsdev@users.noreply.github.com>
2024-08-14 09:56:53 -05:00
github-actions 79ed422871 📝 Update release notes 2024-08-14 03:58:27 +00:00
Sebastián Ramírez d275c6224b 👷 Update GitHub Action labeler dependencies (#1302) 2024-08-13 22:57:33 -05:00
github-actions 972714512b 📝 Update release notes 2024-08-13 22:34:48 +00:00
Sebastián Ramírez 4b9285643a 👷 Update GitHub Action labeler permissions (#1300) 2024-08-13 17:34:30 -05:00
github-actions cdf9a6548e 📝 Update release notes 2024-08-13 05:36:01 +00:00
Sebastián Ramírez 10c6cc72eb 👷 Add GitHub Action label-checker (#1299) 2024-08-13 05:35:21 +00:00
github-actions 7351d21fae 📝 Update release notes 2024-08-13 03:58:49 +00:00
jjaakko 974340c8ff ♻️ Remove duplicated information in the ItemCreate model (#1287) 2024-08-12 22:58:31 -05:00
github-actions 572f513458 📝 Update release notes 2024-08-13 02:45:00 +00:00
Sebastián Ramírez b4c34c63d6 👷 Add GitHub Action labeler (#1298) 2024-08-13 02:44:18 +00:00
github-actions ee82165ec7 📝 Update release notes 2024-08-13 02:11:43 +00:00
Sebastián Ramírez e46ba68301 👷 Add GitHub Action add-to-project (#1297) 2024-08-13 02:11:24 +00:00
github-actions 7a6107ff41 📝 Update release notes 2024-08-03 19:24:01 +00:00
Sebastián Ramírez df94e73a5a 👷 Update issue-manager (#1288) 2024-08-03 19:23:42 +00:00
43 changed files with 2275 additions and 2444 deletions
+8
View File
@@ -1,6 +1,14 @@
# Domain
# This would be set to the production domain with an env var on deployment
# used by Traefik to transmit traffic and aqcuire TLS certificates
DOMAIN=localhost
# To test the local Traefik config
# DOMAIN=localhost.tiangolo.com
# Used by the backend to generate links in emails to the frontend
FRONTEND_HOST=http://localhost:5173
# In staging and production, set this env var to the frontend host, e.g.
# FRONTEND_HOST=https://dashboard.example.com
# Environment: local, staging, production
ENVIRONMENT=local
+6 -6
View File
@@ -1,16 +1,16 @@
version: 2
updates:
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: github-actions
directory: /
schedule:
interval: "daily"
interval: daily
commit-message:
prefix: ⬆
# Python
- package-ecosystem: "pip"
directory: "/"
- package-ecosystem: pip
directory: /
schedule:
interval: "daily"
interval: daily
commit-message:
prefix: ⬆
+25
View File
@@ -0,0 +1,25 @@
docs:
- all:
- changed-files:
- any-glob-to-any-file:
- '**/*.md'
- all-globs-to-all-files:
- '!frontend/**'
- '!backend/**'
- '!.github/**'
- '!scripts/**'
- '!.gitignore'
- '!.pre-commit-config.yaml'
internal:
- all:
- changed-files:
- any-glob-to-any-file:
- .github/**
- scripts/**
- .gitignore
- .pre-commit-config.yaml
- all-globs-to-all-files:
- '!./**/*.md'
- '!frontend/**'
- '!backend/**'
+18
View File
@@ -0,0 +1,18 @@
name: Add to Project
on:
pull_request_target:
issues:
types:
- opened
- reopened
jobs:
add-to-project:
name: Add to project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v1.0.2
with:
project-url: https://github.com/orgs/fastapi/projects/2
github-token: ${{ secrets.PROJECTS_TOKEN }}
+44
View File
@@ -0,0 +1,44 @@
name: Generate Client
on:
pull_request:
types:
- opened
- synchronize
jobs:
generate-client:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.FULL_STACK_FASTAPI_TEMPLATE_REPO_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "0.4.15"
enable-cache: true
- name: Install dependencies
run: npm ci
working-directory: frontend
- run: uv sync
working-directory: backend
- run: uv run bash scripts/generate-client.sh
env:
VIRTUAL_ENV: backend/.venv
- name: Commit changes
run: |
git config --local user.email "github-actions@github.com"
git config --local user.name "github-actions"
git add frontend/src/client
git diff --staged --quiet || git commit -m "✨ Autogenerate frontend client"
git push
+16 -4
View File
@@ -2,30 +2,42 @@ name: Issue Manager
on:
schedule:
- cron: "0 0 * * *"
- cron: "21 17 * * *"
issue_comment:
types:
- created
- edited
issues:
types:
- labeled
pull_request_target:
types:
- labeled
workflow_dispatch:
permissions:
issues: write
pull-requests: write
jobs:
issue-manager:
if: github.repository_owner == 'fastapi'
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: tiangolo/issue-manager@0.5.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
config: >
{
"answered": {
"users": ["tiangolo"],
"delay": 864000,
"message": "Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues."
"message": "Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs."
},
"waiting": {
"delay": 2628000,
"message": "As this PR has been waiting for the original user for a while but seems to be inactive, it's now going to be closed. But if there's anyone interested, feel free to create a new PR."
}
}
+31
View File
@@ -0,0 +1,31 @@
name: Labels
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
# For label-checker
- labeled
- unlabeled
jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
# Run this after labeler applied labels
check-labels:
needs:
- labeler
permissions:
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: docker://agilepathway/pull-request-label-checker:latest
with:
one_of: breaking,security,feature,bug,refactor,upgrade,docs,lang-all,internal
repo_token: ${{ secrets.GITHUB_TOKEN }}
+6 -7
View File
@@ -12,9 +12,9 @@ on:
description: PR number
required: true
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: 'false'
default: "false"
jobs:
latest-changes:
@@ -30,12 +30,11 @@ jobs:
with:
# To allow latest-changes to commit to the main branch
token: ${{ secrets.LATEST_CHANGES }}
- uses: docker://tiangolo/latest-changes:0.3.0
# - uses: tiangolo/latest-changes@main
- uses: tiangolo/latest-changes@0.3.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
latest_changes_file: ./release-notes.md
latest_changes_header: '## Latest Changes'
end_regex: '^## '
latest_changes_header: "## Latest Changes"
end_regex: "^## "
debug_logs: true
label_header_prefix: '### '
label_header_prefix: "### "
+28
View File
@@ -0,0 +1,28 @@
name: Lint Backend
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
jobs:
lint-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "0.4.15"
enable-cache: true
- run: uv run bash scripts/lint.sh
working-directory: backend
+3 -2
View File
@@ -41,9 +41,9 @@ jobs:
working-directory: frontend
- run: docker compose build
- run: docker compose down -v --remove-orphans
- run: docker compose up -d
- run: docker compose up -d --wait backend mailcatcher
- name: Run Playwright tests
run: npx playwright test
run: npx playwright test --fail-on-flaky-tests --trace=retain-on-failure
working-directory: frontend
- run: docker compose down -v --remove-orphans
- uses: actions/upload-artifact@v4
@@ -52,6 +52,7 @@ jobs:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30
include-hidden-files: true
# https://github.com/marketplace/actions/alls-green#why
e2e-alls-green: # This job does nothing and is only used for the branch protection
+2 -5
View File
@@ -2,7 +2,7 @@ name: Smokeshow
on:
workflow_run:
workflows: [Test]
workflows: [Test Backend]
types: [completed]
jobs:
@@ -16,17 +16,14 @@ jobs:
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: "3.10"
- run: pip install smokeshow
- uses: actions/download-artifact@v4
with:
name: coverage-html
path: backend/htmlcov
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- run: smokeshow upload backend/htmlcov
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
+41
View File
@@ -0,0 +1,41 @@
name: Test Backend
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
jobs:
test-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "0.4.15"
enable-cache: true
- run: docker compose down -v --remove-orphans
- run: docker compose up -d db mailcatcher
- name: Migrate DB
run: uv run bash scripts/prestart.sh
working-directory: backend
- name: Run tests
run: uv run bash scripts/tests-start.sh "Coverage for ${{ github.sha }}"
working-directory: backend
- run: docker compose down -v --remove-orphans
- name: Store coverage files
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: backend/htmlcov
include-hidden-files: true
+26
View File
@@ -0,0 +1,26 @@
name: Test Docker Compose
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
jobs:
test-docker-compose:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- run: docker compose build
- run: docker compose down -v --remove-orphans
- run: docker compose up -d --wait
- name: Test backend is up
run: curl http://localhost:8000/api/v1/utils/health-check
- name: Test frontend is up
run: curl http://localhost:5173
- run: docker compose down -v --remove-orphans
-49
View File
@@ -1,49 +0,0 @@
name: Test
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: docker compose build
- run: docker compose down -v --remove-orphans
- run: docker compose up -d
- name: Lint
run: docker compose exec -T backend bash /app/scripts/lint.sh
- name: Run tests
run: docker compose exec -T backend bash /app/tests-start.sh "Coverage for ${{ github.sha }}"
- run: docker compose down -v --remove-orphans
- name: Store coverage files
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: backend/htmlcov
# https://github.com/marketplace/actions/alls-green#why
alls-green: # This job does nothing and is only used for the branch protection
if: always()
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
+30 -17
View File
@@ -1,28 +1,41 @@
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10
FROM python:3.10
WORKDIR /app/
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
# Install uv
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
COPY --from=ghcr.io/astral-sh/uv:0.4.15 /uv /bin/uv
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./pyproject.toml ./poetry.lock* /app/
# Place executables in the environment at the front of the path
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
ENV PATH="/app/.venv/bin:$PATH"
# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"
# Compile bytecode
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
ENV UV_COMPILE_BYTECODE=1
# uv Cache
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching
ENV UV_LINK_MODE=copy
# Install dependencies
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project
ENV PYTHONPATH=/app
COPY ./scripts/ /app/
COPY ./scripts /app/scripts
COPY ./alembic.ini /app/
COPY ./prestart.sh /app/
COPY ./tests-start.sh /app/
COPY ./pyproject.toml ./uv.lock ./alembic.ini /app/
COPY ./app /app/app
# Sync the project
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync
CMD ["fastapi", "run", "--workers", "4", "app/main.py"]
+35 -61
View File
@@ -3,84 +3,50 @@
## Requirements
* [Docker](https://www.docker.com/).
* [Poetry](https://python-poetry.org/) for Python package and environment management.
* [uv](https://docs.astral.sh/uv/) for Python package and environment management.
## Local Development
## Docker Compose
* Start the stack with Docker Compose:
Start the local development environment with Docker Compose following the guide in [../development.md](../development.md).
```bash
docker compose up -d
```
## General Workflow
* Now you can open your browser and interact with these URLs:
Frontend, built with Docker, with routes handled based on the path: http://localhost
Backend, JSON based web API based on OpenAPI: http://localhost/api/
Automatic interactive documentation with Swagger UI (from the OpenAPI backend): http://localhost/docs
Adminer, database web administration: http://localhost:8080
Traefik UI, to see how the routes are being handled by the proxy: http://localhost:8090
**Note**: The first time you start your stack, it might take a minute for it to be ready. While the backend waits for the database to be ready and configures everything. You can check the logs to monitor it.
To check the logs, run:
```bash
docker compose logs
```
To check the logs of a specific service, add the name of the service, e.g.:
```bash
docker compose logs backend
```
If your Docker is not running in `localhost` (the URLs above wouldn't work) you would need to use the IP or domain where your Docker is running.
## Backend local development, additional details
### General workflow
By default, the dependencies are managed with [Poetry](https://python-poetry.org/), go there and install it.
By default, the dependencies are managed with [uv](https://docs.astral.sh/uv/), go there and install it.
From `./backend/` you can install all the dependencies with:
```console
$ poetry install
$ uv sync
```
Then you can start a shell session with the new environment with:
Then you can activate the virtual environment with:
```console
$ poetry shell
$ source .venv/bin/activate
```
Make sure your editor is using the correct Python virtual environment.
Make sure your editor is using the correct Python virtual environment, with the interpreter at `backend/.venv/bin/python`.
Modify or add SQLModel models for data and SQL tables in `./backend/app/models.py`, API endpoints in `./backend/app/api/`, CRUD (Create, Read, Update, Delete) utils in `./backend/app/crud.py`.
### VS Code
## VS Code
There are already configurations in place to run the backend through the VS Code debugger, so that you can use breakpoints, pause and explore variables, etc.
The setup is also already configured so you can run the tests through the VS Code Python tests tab.
### Docker Compose Override
## Docker Compose Override
During development, you can change Docker Compose settings that will only affect the local development environment in the file `docker-compose.override.yml`.
The changes to that file only affect the local development environment, not the production environment. So, you can add "temporary" changes that help the development workflow.
For example, the directory with the backend code is mounted as a Docker "host volume", mapping the code you change live to the directory inside the container. That allows you to test your changes right away, without having to build the Docker image again. It should only be done during development, for production, you should build the Docker image with a recent version of the backend code. But during development, it allows you to iterate very fast.
For example, the directory with the backend code is synchronized in the Docker container, copying the code you change live to the directory inside the container. That allows you to test your changes right away, without having to build the Docker image again. It should only be done during development, for production, you should build the Docker image with a recent version of the backend code. But during development, it allows you to iterate very fast.
There is also a command override that runs `/start-reload.sh` (included in the base image) instead of the default `/start.sh` (also included in the base image). It starts a single server process (instead of multiple, as would be for production) and reloads the process whenever the code changes. Have in mind that if you have a syntax error and save the Python file, it will break and exit, and the container will stop. After that, you can restart the container by fixing the error and running again:
There is also a command override that runs `fastapi run --reload` instead of the default `fastapi run`. It starts a single server process (instead of multiple, as would be for production) and reloads the process whenever the code changes. Have in mind that if you have a syntax error and save the Python file, it will break and exit, and the container will stop. After that, you can restart the container by fixing the error and running again:
```console
$ docker compose up -d
$ docker compose watch
```
There is also a commented out `command` override, you can uncomment it and comment the default one. It makes the backend container run a process that does "nothing", but keeps the container alive. That allows you to get inside your running container and execute commands inside, for example a Python interpreter to test installed dependencies, or start the development server that reloads when it detects changes.
@@ -88,10 +54,10 @@ There is also a commented out `command` override, you can uncomment it and comme
To get inside the container with a `bash` session you can start the stack with:
```console
$ docker compose up -d
$ docker compose watch
```
and then `exec` inside the running container:
and then in another terminal, `exec` inside the running container:
```console
$ docker compose exec backend bash
@@ -105,16 +71,16 @@ root@7f2607af31c3:/app#
that means that you are in a `bash` session inside your container, as a `root` user, under the `/app` directory, this directory has another directory called "app" inside, that's where your code lives inside the container: `/app/app`.
There you can use the script `/start-reload.sh` to run the debug live reloading server. You can run that script from inside the container with:
There you can use the `fastapi run --reload` command to run the debug live reloading server.
```console
$ bash /start-reload.sh
$ fastapi run --reload app/main.py
```
...it will look like:
```console
root@7f2607af31c3:/app# bash /start-reload.sh
root@7f2607af31c3:/app# fastapi run --reload app/main.py
```
and then hit enter. That runs the live reloading server that auto reloads when it detects code changes.
@@ -123,7 +89,7 @@ Nevertheless, if it doesn't detect a change but a syntax error, it will just sto
...this previous detail is what makes it useful to have the container alive doing nothing and then, in a Bash session, make it run the live reload server.
### Backend tests
## Backend tests
To test the backend run:
@@ -135,27 +101,27 @@ The tests run with Pytest, modify and add tests to `./backend/app/tests/`.
If you use GitHub Actions the tests will run automatically.
#### Test running stack
### Test running stack
If your stack is already up and you just want to run the tests, you can use:
```bash
docker compose exec backend bash /app/tests-start.sh
docker compose exec backend bash scripts/tests-start.sh
```
That `/app/tests-start.sh` script just calls `pytest` after making sure that the rest of the stack is running. If you need to pass extra arguments to `pytest`, you can pass them to that command and they will be forwarded.
That `/app/scripts/tests-start.sh` script just calls `pytest` after making sure that the rest of the stack is running. If you need to pass extra arguments to `pytest`, you can pass them to that command and they will be forwarded.
For example, to stop on first error:
```bash
docker compose exec backend bash /app/tests-start.sh -x
docker compose exec backend bash scripts/tests-start.sh -x
```
#### Test Coverage
### Test Coverage
When the tests are run, a file `htmlcov/index.html` is generated, you can open it in your browser to see the coverage of the tests.
### Migrations
## Migrations
As during local development your app directory is mounted as a volume inside the container, you can also run the migrations with `alembic` commands inside the container and the migration code will be in your app directory (instead of being only inside the container). So you can add it to your git repository.
@@ -189,10 +155,18 @@ If you don't want to use migrations at all, uncomment the lines in the file at `
SQLModel.metadata.create_all(engine)
```
and comment the line in the file `prestart.sh` that contains:
and comment the line in the file `scripts/prestart.sh` that contains:
```console
$ alembic upgrade head
```
If you don't want to start with the default models and want to remove them / modify them, from the beginning, without having any previous revision, you can remove the revision files (`.py` Python files) under `./backend/app/alembic/versions/`. And then create a first migration as described above.
## Email Templates
The email templates are in `./backend/app/email-templates/`. Here, there are two directories: `build` and `src`. The `src` directory contains the source files that are used to build the final email templates. The `build` directory contains the final email templates that are used by the application.
Before continuing, ensure you have the [MJML extension](https://marketplace.visualstudio.com/items?itemName=attilabuti.vscode-mjml) installed in your VS Code.
Once you have the MJML extension installed, you can create a new email template in the `src` directory. After creating the new email template and with the `.mjml` file open in your editor, open the command palette with `Ctrl+Shift+P` and search for `MJML: Export to HTML`. This will convert the `.mjml` file to a `.html` file and now you can save it in the build directory.
+5
View File
@@ -24,3 +24,8 @@ def test_email(email_to: EmailStr) -> Message:
html_content=email_data.html_content,
)
return Message(message="Test email sent")
@router.get("/health-check/")
async def health_check() -> bool:
return True
+12 -10
View File
@@ -25,27 +25,29 @@ def parse_cors(v: Any) -> list[str] | str:
class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_file=".env", env_ignore_empty=True, extra="ignore"
# Use top level .env file (one level above ./backend/)
env_file="../.env",
env_ignore_empty=True,
extra="ignore",
)
API_V1_STR: str = "/api/v1"
SECRET_KEY: str = secrets.token_urlsafe(32)
# 60 minutes * 24 hours * 8 days = 8 days
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
DOMAIN: str = "localhost"
FRONTEND_HOST: str = "http://localhost:5173"
ENVIRONMENT: Literal["local", "staging", "production"] = "local"
@computed_field # type: ignore[prop-decorator]
@property
def server_host(self) -> str:
# Use HTTPS for anything other than local development
if self.ENVIRONMENT == "local":
return f"http://{self.DOMAIN}"
return f"https://{self.DOMAIN}"
BACKEND_CORS_ORIGINS: Annotated[
list[AnyUrl] | str, BeforeValidator(parse_cors)
] = []
@computed_field # type: ignore[prop-decorator]
@property
def all_cors_origins(self) -> list[str]:
return [str(origin).rstrip("/") for origin in self.BACKEND_CORS_ORIGINS] + [
self.FRONTEND_HOST
]
PROJECT_NAME: str
SENTRY_DSN: HttpUrl | None = None
POSTGRES_SERVER: str
+2 -4
View File
@@ -21,12 +21,10 @@ app = FastAPI(
)
# Set all CORS enabled origins
if settings.BACKEND_CORS_ORIGINS:
if settings.all_cors_origins:
app.add_middleware(
CORSMiddleware,
allow_origins=[
str(origin).strip("/") for origin in settings.BACKEND_CORS_ORIGINS
],
allow_origins=settings.all_cors_origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
+1 -1
View File
@@ -64,7 +64,7 @@ class ItemBase(SQLModel):
# Properties to receive on item creation
class ItemCreate(ItemBase):
title: str = Field(min_length=1, max_length=255)
pass
# Properties to receive on item update
+2 -2
View File
@@ -64,7 +64,7 @@ def generate_test_email(email_to: str) -> EmailData:
def generate_reset_password_email(email_to: str, email: str, token: str) -> EmailData:
project_name = settings.PROJECT_NAME
subject = f"{project_name} - Password recovery for user {email}"
link = f"{settings.server_host}/reset-password?token={token}"
link = f"{settings.FRONTEND_HOST}/reset-password?token={token}"
html_content = render_email_template(
template_name="reset_password.html",
context={
@@ -90,7 +90,7 @@ def generate_new_account_email(
"username": username,
"password": password,
"email": email_to,
"link": settings.server_host,
"link": settings.FRONTEND_HOST,
},
)
return EmailData(html_content=html_content, subject=subject)
-2084
View File
File diff suppressed because it is too large Load Diff
+32 -34
View File
@@ -1,43 +1,41 @@
[tool.poetry]
[project]
name = "app"
version = "0.1.0"
description = ""
authors = ["Admin <admin@example.com>"]
requires-python = ">=3.10,<4.0"
dependencies = [
"fastapi[standard]<1.0.0,>=0.114.2",
"python-multipart<1.0.0,>=0.0.7",
"email-validator<3.0.0.0,>=2.1.0.post1",
"passlib[bcrypt]<2.0.0,>=1.7.4",
"tenacity<9.0.0,>=8.2.3",
"pydantic>2.0",
"emails<1.0,>=0.6",
"jinja2<4.0.0,>=3.1.4",
"alembic<2.0.0,>=1.12.1",
"httpx<1.0.0,>=0.25.1",
"psycopg[binary]<4.0.0,>=3.1.13",
"sqlmodel<1.0.0,>=0.0.21",
# Pin bcrypt until passlib supports the latest
"bcrypt==4.0.1",
"pydantic-settings<3.0.0,>=2.2.1",
"sentry-sdk[fastapi]<2.0.0,>=1.40.6",
"pyjwt<3.0.0,>=2.8.0",
]
[tool.poetry.dependencies]
python = "^3.10"
uvicorn = {extras = ["standard"], version = "^0.24.0.post1"}
fastapi = "^0.109.1"
python-multipart = "^0.0.7"
email-validator = "^2.1.0.post1"
passlib = {extras = ["bcrypt"], version = "^1.7.4"}
tenacity = "^8.2.3"
pydantic = ">2.0"
emails = "^0.6"
gunicorn = "^22.0.0"
jinja2 = "^3.1.4"
alembic = "^1.12.1"
httpx = "^0.25.1"
psycopg = {extras = ["binary"], version = "^3.1.13"}
sqlmodel = "^0.0.21"
# Pin bcrypt until passlib supports the latest
bcrypt = "4.0.1"
pydantic-settings = "^2.2.1"
sentry-sdk = {extras = ["fastapi"], version = "^1.40.6"}
pyjwt = "^2.8.0"
[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
mypy = "^1.8.0"
ruff = "^0.2.2"
pre-commit = "^3.6.2"
types-passlib = "^1.7.7.20240106"
coverage = "^7.4.3"
[tool.uv]
dev-dependencies = [
"pytest<8.0.0,>=7.4.3",
"mypy<2.0.0,>=1.8.0",
"ruff<1.0.0,>=0.2.2",
"pre-commit<4.0.0,>=3.6.2",
"types-passlib<2.0.0.0,>=1.7.7.20240106",
"coverage<8.0.0,>=7.4.3",
]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.mypy]
strict = true
@@ -1,10 +1,13 @@
#! /usr/bin/env bash
set -e
set -x
# Let the DB start
python /app/app/backend_pre_start.py
python app/backend_pre_start.py
# Run migrations
alembic upgrade head
# Create initial data in DB
python /app/app/initial_data.py
python app/initial_data.py
+7
View File
@@ -0,0 +1,7 @@
#! /usr/bin/env bash
set -e
set -x
python app/tests_pre_start.py
bash scripts/test.sh "$@"
-7
View File
@@ -1,7 +0,0 @@
#! /usr/bin/env bash
set -e
set -x
python /app/app/tests_pre_start.py
bash ./scripts/test.sh "$@"
+1554
View File
File diff suppressed because it is too large Load Diff
-2
View File
@@ -63,7 +63,6 @@ _exclude:
# Global
- .vscode
- .mypy_cache
- poetry.lock
# Python
- __pycache__
- app.egg-info
@@ -71,7 +70,6 @@ _exclude:
- .mypy_cache
- .coverage
- htmlcov
- poetry.lock
- .cache
- .venv
# Frontend
+7 -7
View File
@@ -12,7 +12,7 @@ But you have to configure a couple things first. 🤓
* Have a remote server ready and available.
* Configure the DNS records of your domain to point to the IP of the server you just created.
* Configure a wildcard subdomain for your domain, so that you can have multiple subdomains for different services, e.g. `*.fastapi-project.example.com`. This will be useful for accessing different components, like `traefik.fastapi-project.example.com`, `adminer.fastapi-project.example.com`, etc. And also for `staging`, like `staging.fastapi-project.example.com`, `staging.adminer.fastapi-project.example.com`, etc.
* Configure a wildcard subdomain for your domain, so that you can have multiple subdomains for different services, e.g. `*.fastapi-project.example.com`. This will be useful for accessing different components, like `dashboard.fastapi-project.example.com`, `api.fastapi-project.example.com`, `traefik.fastapi-project.example.com`, `adminer.fastapi-project.example.com`, etc. And also for `staging`, like `dashboard.staging.fastapi-project.example.com`, `adminer.staging..fastapi-project.example.com`, etc.
* Install and configure [Docker](https://docs.docker.com/engine/install/) on the remote server (Docker Engine, not Docker Desktop).
## Public Traefik
@@ -284,20 +284,20 @@ Traefik UI: `https://traefik.fastapi-project.example.com`
### Production
Frontend: `https://fastapi-project.example.com`
Frontend: `https://dashboard.fastapi-project.example.com`
Backend API docs: `https://fastapi-project.example.com/docs`
Backend API docs: `https://api.fastapi-project.example.com/docs`
Backend API base URL: `https://fastapi-project.example.com/api/`
Backend API base URL: `https://api.fastapi-project.example.com`
Adminer: `https://adminer.fastapi-project.example.com`
### Staging
Frontend: `https://staging.fastapi-project.example.com`
Frontend: `https://dashboard.staging.fastapi-project.example.com`
Backend API docs: `https://staging.fastapi-project.example.com/docs`
Backend API docs: `https://api.staging.fastapi-project.example.com/docs`
Backend API base URL: `https://staging.fastapi-project.example.com/api/`
Backend API base URL: `https://api.staging.fastapi-project.example.com`
Adminer: `https://adminer.staging.fastapi-project.example.com`
+91 -63
View File
@@ -1,78 +1,100 @@
# FastAPI Project - Development
## Development in `localhost` with a custom domain
## Docker Compose
You might want to use something different than `localhost` as the domain. For example, if you are having problems with cookies that need a subdomain, and Chrome is not allowing you to use `localhost`.
* Start the local stack with Docker Compose:
In that case, you have two options: you could use the instructions to modify your system `hosts` file with the instructions below in **Development with a custom IP** or you can just use `localhost.tiangolo.com`, it is set up to point to `localhost` (to the IP `127.0.0.1`) and all its subdomains too. And as it is an actual domain, the browsers will store the cookies you set during development, etc.
If you used the default CORS enabled domains while generating the project, `localhost.tiangolo.com` was configured to be allowed. If you didn't, you will need to add it to the list in the variable `BACKEND_CORS_ORIGINS` in the `.env` file.
To configure it in your stack, follow the section **Change the development "domain"** below, using the domain `localhost.tiangolo.com`.
After performing those steps you should be able to open: http://localhost.tiangolo.com and it will be served by your stack in `localhost`.
Check all the corresponding available URLs in the section at the end.
## Development with a custom IP
If you are running Docker in an IP address different than `127.0.0.1` (`localhost`), you will need to perform some additional steps. That will be the case if you are running a custom Virtual Machine or your Docker is located in a different machine in your network.
In that case, you will need to use a fake local domain (`dev.example.com`) and make your computer think that the domain is served by the custom IP (e.g. `192.168.99.150`).
If you have a custom domain like that, you need to add it to the list in the variable `BACKEND_CORS_ORIGINS` in the `.env` file.
* Open your `hosts` file with administrative privileges using a text editor:
* **Note for Windows**: If you are in Windows, open the main Windows menu, search for "notepad", right click on it, and select the option "open as Administrator" or similar. Then click the "File" menu, "Open file", go to the directory `c:\Windows\System32\Drivers\etc\`, select the option to show "All files" instead of only "Text (.txt) files", and open the `hosts` file.
* **Note for Mac and Linux**: Your `hosts` file is probably located at `/etc/hosts`, you can edit it in a terminal running `sudo nano /etc/hosts`.
* Additional to the contents it might have, add a new line with the custom IP (e.g. `192.168.99.150`) a space character, and your fake local domain: `dev.example.com`.
The new line might look like:
```
192.168.99.150 dev.example.com
```bash
docker compose watch
```
* Save the file.
* **Note for Windows**: Make sure you save the file as "All files", without an extension of `.txt`. By default, Windows tries to add the extension. Make sure the file is saved as is, without extension.
* Now you can open your browser and interact with these URLs:
...that will make your computer think that the fake local domain is served by that custom IP, and when you open that URL in your browser, it will talk directly to your locally running server when it is asked to go to `dev.example.com` and think that it is a remote server while it is actually running in your computer.
Frontend, built with Docker, with routes handled based on the path: http://localhost:5173
To configure it in your stack, follow the section **Change the development "domain"** below, using the domain `dev.example.com`.
Backend, JSON based web API based on OpenAPI: http://localhost:8000
After performing those steps you should be able to open: http://dev.example.com and it will be server by your stack in `192.168.99.150`.
Automatic interactive documentation with Swagger UI (from the OpenAPI backend): http://localhost:8000/docs
Check all the corresponding available URLs in the section at the end.
Adminer, database web administration: http://localhost:8080
## Change the development "domain"
Traefik UI, to see how the routes are being handled by the proxy: http://localhost:8090
If you need to use your local stack with a different domain than `localhost`, you need to make sure the domain you use points to the IP where your stack is set up.
**Note**: The first time you start your stack, it might take a minute for it to be ready. While the backend waits for the database to be ready and configures everything. You can check the logs to monitor it.
To simplify your Docker Compose setup, for example, so that the API docs (Swagger UI) knows where is your API, you should let it know you are using that domain for development.
To check the logs, run (in another terminal):
* Open the file located at `./.env`. It would have a line like:
```
DOMAIN=localhost
```bash
docker compose logs
```
* Change it to the domain you are going to use, e.g.:
To check the logs of a specific service, add the name of the service, e.g.:
```bash
docker compose logs backend
```
## Local Development
The Docker Compose files are configured so that each of the services is available in a different port in `localhost`.
For the backend and frontend, they use the same port that would be used by their local development server, so, the backend is at `http://localhost:8000` and the frontend at `http://localhost:5173`.
This way, you could turn off a Docker Compose service and start its local development service, and everything would keep working, because it all uses the same ports.
For example, you can stop that `frontend` service in the Docker Compose, in another terminal, run:
```bash
docker compose stop frontend
```
And then start the local frontend development server:
```bash
cd frontend
npm run dev
```
Or you could stop the `backend` Docker Compose service:
```bash
docker compose stop backend
```
And then you can run the local development server for the backend:
```bash
cd backend
fastapi dev app/main.py
```
## Docker Compose in `localhost.tiangolo.com`
When you start the Docker Compose stack, it uses `localhost` by default, with different ports for each service (backend, frontend, adminer, etc).
When you deploy it to production (or staging), it will deploy each service in a different subdomain, like `api.example.com` for the backend and `dashboard.example.com` for the frontend.
In the guide about [deployment](deployment.md) you can read about Traefik, the configured proxy. That's the component in charge of transmitting traffic to each service based on the subdomain.
If you want to test that it's all working locally, you can edit the local `.env` file, and change:
```dotenv
DOMAIN=localhost.tiangolo.com
```
That variable will be used by the Docker Compose files.
That will be used by the Docker Compose files to configure the base domain for the services.
After that, you can restart your stack with:
Traefik will use this to transmit traffic at `api.localhost.tiangolo.com` to the backend, and traffic at `dashboard.localhost.tiangolo.com` to the frontend.
The domain `localhost.tiangolo.com` is a special domain that is configured (with all its subdomains) to point to `127.0.0.1`. This way you can use that for your local development.
After you update it, run again:
```bash
docker compose up -d
docker compose watch
```
and check all the corresponding available URLs in the section at the end.
When deploying, for example in production, the main Traefik is configured outside of the Docker Compose files. For local development, there's an included Traefik in `docker-compose.override.yml`, just to let you test that the domains work as expected, for example with `api.localhost.tiangolo.com` and `dashboard.localhost.tiangolo.com`.
## Docker Compose files and env vars
@@ -84,6 +106,12 @@ These Docker Compose files use the `.env` file containing configurations to be i
They also use some additional configurations taken from environment variables set in the scripts before calling the `docker compose` command.
After changing variables, make sure you restart the stack:
```bash
docker compose watch
```
## The .env file
The `.env` file is the one that contains all your configurations, generated keys and passwords, etc.
@@ -92,7 +120,7 @@ Depending on your workflow, you could want to exclude it from Git, for example i
One way to do it could be to add each environment variable to your CI/CD system, and updating the `docker-compose.yml` file to read that specific env var instead of reading the `.env` file.
### Pre-commits and code linting
## Pre-commits and code linting
we are using a tool called [pre-commit](https://pre-commit.com/) for code linting and formatting.
@@ -106,10 +134,10 @@ You can find a file `.pre-commit-config.yaml` with configurations at the root of
After having the `pre-commit` tool installed and available, you need to "install" it in the local repository, so that it runs automatically before each commit.
Using Poetry, you could do it with:
Using `uv`, you could do it with:
```bash
❯ poetry run pre-commit install
❯ uv run pre-commit install
pre-commit installed at .git/hooks/pre-commit
```
@@ -125,10 +153,10 @@ Then you can `git add` the modified/fixed files again and now you can commit.
#### Running pre-commit hooks manually
you can also run `pre-commit` manually on all the files, you can do it using Poetry with:
you can also run `pre-commit` manually on all the files, you can do it using `uv` with:
```bash
❯ poetry run pre-commit run --all-files
❯ uv run pre-commit run --all-files
check for added large files..............................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
@@ -146,29 +174,29 @@ The production or staging URLs would use these same paths, but with your own dom
Development URLs, for local development.
Frontend: http://localhost
Frontend: http://localhost:5173
Backend: http://localhost/api/
Backend: http://localhost:8000
Automatic Interactive Docs (Swagger UI): http://localhost/docs
Automatic Interactive Docs (Swagger UI): http://localhost:8000/docs
Automatic Alternative Docs (ReDoc): http://localhost/redoc
Automatic Alternative Docs (ReDoc): http://localhost:8000/redoc
Adminer: http://localhost:8080
Traefik UI: http://localhost:8090
### Development in localhost with a custom domain URLs
### Development URLs with `localhost.tiangolo.com` Configured
Development URLs, for local development.
Frontend: http://localhost.tiangolo.com
Frontend: http://dashboard.localhost.tiangolo.com
Backend: http://localhost.tiangolo.com/api/
Backend: http://api.localhost.tiangolo.com
Automatic Interactive Docs (Swagger UI): http://localhost.tiangolo.com/docs
Automatic Interactive Docs (Swagger UI): http://api.localhost.tiangolo.comdocs
Automatic Alternative Docs (ReDoc): http://localhost.tiangolo.com/redoc
Automatic Alternative Docs (ReDoc): http://api.localhost.tiangolo.comredoc
Adminer: http://localhost.tiangolo.com:8080
+27 -7
View File
@@ -1,5 +1,10 @@
services:
# Local services are available on their ports, but also available on:
# http://api.localhost.tiangolo.com: backend
# http://dashboard.localhost.tiangolo.com: frontend
# etc. To enable it, update .env, set:
# DOMAIN=localhost.tiangolo.com
proxy:
image: traefik:3.0
volumes:
@@ -53,15 +58,28 @@ services:
backend:
restart: "no"
ports:
- "8888:8888"
volumes:
- ./backend/:/app
- "8000:8000"
build:
context: ./backend
args:
INSTALL_DEV: ${INSTALL_DEV-true}
# command: sleep infinity # Infinite loop to keep container alive doing nothing
command: /start-reload.sh
command:
- fastapi
- run
- --reload
- "app/main.py"
develop:
watch:
- path: ./backend
action: sync
target: /app
ignore:
- ./backend/.venv
- .venv
- path: ./backend/pyproject.toml
action: rebuild
# TODO: remove once coverage is done locally
volumes:
- ./backend/htmlcov:/app/htmlcov
environment:
SMTP_HOST: "mailcatcher"
SMTP_PORT: "1025"
@@ -76,10 +94,12 @@ services:
frontend:
restart: "no"
ports:
- "5173:80"
build:
context: ./frontend
args:
- VITE_API_URL=http://${DOMAIN?Variable not set}
- VITE_API_URL=http://localhost:8000
- NODE_ENV=development
networks:
+64 -23
View File
@@ -1,7 +1,14 @@
services:
db:
image: postgres:12
restart: always
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
retries: 5
start_period: 30s
timeout: 10s
volumes:
- app-db-data:/var/lib/postgresql/data/pgdata
env_file:
@@ -35,18 +42,23 @@ services:
- traefik.http.routers.${STACK_NAME?Variable not set}-adminer-https.tls.certresolver=le
- traefik.http.services.${STACK_NAME?Variable not set}-adminer.loadbalancer.server.port=8080
backend:
prestart:
image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
restart: always
build:
context: ./backend
networks:
- traefik-public
- default
depends_on:
- db
db:
condition: service_healthy
restart: true
command: bash scripts/prestart.sh
env_file:
- .env
environment:
- DOMAIN=${DOMAIN}
- FRONTEND_HOST=${FRONTEND_HOST?Variable not set}
- ENVIRONMENT=${ENVIRONMENT}
- BACKEND_CORS_ORIGINS=${BACKEND_CORS_ORIGINS}
- SECRET_KEY=${SECRET_KEY?Variable not set}
@@ -63,34 +75,64 @@ services:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
- SENTRY_DSN=${SENTRY_DSN}
backend:
image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
restart: always
networks:
- traefik-public
- default
depends_on:
db:
condition: service_healthy
restart: true
prestart:
condition: service_completed_successfully
env_file:
- .env
environment:
- DOMAIN=${DOMAIN}
- FRONTEND_HOST=${FRONTEND_HOST?Variable not set}
- ENVIRONMENT=${ENVIRONMENT}
- BACKEND_CORS_ORIGINS=${BACKEND_CORS_ORIGINS}
- SECRET_KEY=${SECRET_KEY?Variable not set}
- FIRST_SUPERUSER=${FIRST_SUPERUSER?Variable not set}
- FIRST_SUPERUSER_PASSWORD=${FIRST_SUPERUSER_PASSWORD?Variable not set}
- SMTP_HOST=${SMTP_HOST}
- SMTP_USER=${SMTP_USER}
- SMTP_PASSWORD=${SMTP_PASSWORD}
- EMAILS_FROM_EMAIL=${EMAILS_FROM_EMAIL}
- POSTGRES_SERVER=db
- POSTGRES_PORT=${POSTGRES_PORT}
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER?Variable not set}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
- SENTRY_DSN=${SENTRY_DSN}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/utils/health-check/"]
interval: 10s
timeout: 5s
retries: 5
build:
context: ./backend
args:
INSTALL_DEV: ${INSTALL_DEV-false}
platform: linux/amd64 # Patch for M1 Mac
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=80
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=8000
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=(Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)) && (PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`))
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=Host(`api.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.entrypoints=http
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.rule=(Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)) && (PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`))
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.rule=Host(`api.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.entrypoints=https
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.tls=true
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.tls.certresolver=le
# Define Traefik Middleware to handle domain with and without "www" to redirect to only one
- traefik.http.middlewares.${STACK_NAME?Variable not set}-www-redirect.redirectregex.regex=^http(s)?://www.(${DOMAIN?Variable not set})/(.*)
# Redirect a domain with www to non-www
- traefik.http.middlewares.${STACK_NAME?Variable not set}-www-redirect.redirectregex.replacement=http$${1}://${DOMAIN?Variable not set}/$${3}
# Enable www redirection for HTTP and HTTPS
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.middlewares=https-redirect,${STACK_NAME?Variable not set}-www-redirect
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.middlewares=${STACK_NAME?Variable not set}-www-redirect
# Enable redirection for HTTP and HTTPS
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.middlewares=https-redirect
frontend:
image: '${DOCKER_IMAGE_FRONTEND?Variable not set}:${TAG-latest}'
@@ -101,7 +143,7 @@ services:
build:
context: ./frontend
args:
- VITE_API_URL=https://${DOMAIN?Variable not set}
- VITE_API_URL=https://api.${DOMAIN?Variable not set}
- NODE_ENV=production
labels:
- traefik.enable=true
@@ -110,17 +152,16 @@ services:
- traefik.http.services.${STACK_NAME?Variable not set}-frontend.loadbalancer.server.port=80
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=Host(`dashboard.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.entrypoints=http
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.rule=Host(`dashboard.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.entrypoints=https
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.tls=true
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.tls.certresolver=le
# Enable www redirection for HTTP and HTTPS
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.middlewares=${STACK_NAME?Variable not set}-www-redirect
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.middlewares=https-redirect,${STACK_NAME?Variable not set}-www-redirect
# Enable redirection for HTTP and HTTPS
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.middlewares=https-redirect
volumes:
app-db-data:
+1 -1
View File
@@ -1 +1 @@
VITE_API_URL=http://localhost
VITE_API_URL=http://localhost:8000
+18 -5
View File
@@ -4,7 +4,7 @@ The frontend is built with [Vite](https://vitejs.dev/), [React](https://reactjs.
## Frontend development
Before you begin, ensure that you have either the Node Version Manager (nvm) or Fast Node Manager (fnm) installed on your system.
Before you begin, ensure that you have either the Node Version Manager (nvm) or Fast Node Manager (fnm) installed on your system.
* To install fnm follow the [official fnm guide](https://github.com/Schniz/fnm#installation). If you prefer nvm, you can install it using the [official nvm guide](https://github.com/nvm-sh/nvm#installing-and-updating).
@@ -27,7 +27,7 @@ nvm install
```bash
# If using fnm
fnm use
fnm use
# If using nvm
nvm use
@@ -74,6 +74,19 @@ But it would be only to clean them up, leaving them won't really have any effect
## Generate Client
### Automatically
* Activate the backend virtual environment.
* From the top level project directory, run the script:
```bash
./scripts/generate-frontend-client.sh
```
* Commit the changes.
### Manually
* Start the Docker Compose stack.
* Download the OpenAPI JSON file from `http://localhost/api/v1/openapi.json` and copy it to a new file `openapi.json` at the root of the `frontend` directory.
@@ -99,7 +112,7 @@ Notice that everytime the backend changes (changing the OpenAPI schema), you sho
If you want to use a remote API, you can set the environment variable `VITE_API_URL` to the URL of the remote API. For example, you can set it in the `frontend/.env` file:
```env
VITE_API_URL=https://my-remote-api.example.com
VITE_API_URL=https://api.my-domain.example.com
```
Then, when you run the frontend, it will use that URL as the base URL for the API.
@@ -121,7 +134,7 @@ The frontend code is structured as follows:
The frontend includes initial end-to-end tests using Playwright. To run the tests, you need to have the Docker Compose stack running. Start the stack with the following command:
```bash
docker compose up -d
docker compose up -d --wait backend
```
Then, you can run the tests with the following command:
@@ -144,4 +157,4 @@ docker compose down -v
To update the tests, navigate to the tests directory and modify the existing test files or add new ones as needed.
For more information on writing and running Playwright tests, refer to the official [Playwright documentation](https://playwright.dev/docs/intro).
For more information on writing and running Playwright tests, refer to the official [Playwright documentation](https://playwright.dev/docs/intro).
-1
View File
@@ -6,7 +6,6 @@
"files": {
"ignore": [
"node_modules",
"src/client/",
"src/routeTree.gen.ts",
"playwright.config.ts",
"playwright-report"
+9 -9
View File
@@ -15,7 +15,7 @@
"@tanstack/react-query": "^5.28.14",
"@tanstack/react-query-devtools": "^5.28.14",
"@tanstack/react-router": "1.19.1",
"axios": "1.6.2",
"axios": "1.7.4",
"form-data": "4.0.0",
"framer-motion": "10.16.16",
"react": "^18.2.0",
@@ -2781,11 +2781,11 @@
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz",
"integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==",
"version": "1.7.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz",
"integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==",
"dependencies": {
"follow-redirects": "^1.15.0",
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
@@ -5737,11 +5737,11 @@
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"axios": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz",
"integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==",
"version": "1.7.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz",
"integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==",
"requires": {
"follow-redirects": "^1.15.0",
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
+2 -2
View File
@@ -8,7 +8,7 @@
"build": "tsc && vite build",
"lint": "biome check --apply-unsafe --no-errors-on-unmatched --files-ignore-unknown=true ./",
"preview": "vite preview",
"generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios --exportSchemas true && biome format --write ./src/client"
"generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios --exportSchemas true"
},
"dependencies": {
"@chakra-ui/icons": "2.1.1",
@@ -18,7 +18,7 @@
"@tanstack/react-query": "^5.28.14",
"@tanstack/react-query-devtools": "^5.28.14",
"@tanstack/react-router": "1.19.1",
"axios": "1.6.2",
"axios": "1.7.4",
"form-data": "4.0.0",
"framer-motion": "10.16.16",
"react": "^18.2.0",
+3 -3
View File
@@ -1,9 +1,9 @@
import axios from "axios"
import type {
AxiosError,
AxiosInstance,
AxiosRequestConfig,
AxiosResponse,
AxiosInstance,
} from "axios"
import { ApiError } from "./ApiError"
@@ -151,12 +151,12 @@ export const getHeaders = async (
)
if (isStringWithValue(token)) {
headers.Authorization = `Bearer ${token}`
headers["Authorization"] = `Bearer ${token}`
}
if (isStringWithValue(username) && isStringWithValue(password)) {
const credentials = base64(`${username}:${password}`)
headers.Authorization = `Basic ${credentials}`
headers["Authorization"] = `Basic ${credentials}`
}
if (options.body !== undefined) {
+36 -24
View File
@@ -4,20 +4,20 @@ import { request as __request } from "./core/request"
import type {
Body_login_login_access_token,
ItemCreate,
ItemPublic,
ItemUpdate,
ItemsPublic,
Message,
NewPassword,
Token,
UserPublic,
UpdatePassword,
UserCreate,
UserPublic,
UserRegister,
UsersPublic,
UserUpdate,
UserUpdateMe,
UsersPublic,
ItemCreate,
ItemPublic,
ItemsPublic,
ItemUpdate,
} from "./models"
export type TDataLoginAccessToken = {
@@ -50,7 +50,7 @@ export class LoginService {
formData: formData,
mediaType: "application/x-www-form-urlencoded",
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -85,7 +85,7 @@ export class LoginService {
email,
},
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -106,7 +106,7 @@ export class LoginService {
body: requestBody,
mediaType: "application/json",
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -128,7 +128,7 @@ export class LoginService {
email,
},
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -180,7 +180,7 @@ export class UsersService {
limit,
},
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -201,7 +201,7 @@ export class UsersService {
body: requestBody,
mediaType: "application/json",
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -248,7 +248,7 @@ export class UsersService {
body: requestBody,
mediaType: "application/json",
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -269,7 +269,7 @@ export class UsersService {
body: requestBody,
mediaType: "application/json",
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -290,7 +290,7 @@ export class UsersService {
body: requestBody,
mediaType: "application/json",
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -312,7 +312,7 @@ export class UsersService {
user_id: userId,
},
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -336,7 +336,7 @@ export class UsersService {
body: requestBody,
mediaType: "application/json",
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -356,7 +356,7 @@ export class UsersService {
user_id: userId,
},
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -382,10 +382,22 @@ export class UtilsService {
email_to: emailTo,
},
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
/**
* Health Check
* @returns boolean Successful Response
* @throws ApiError
*/
public static healthCheck(): CancelablePromise<boolean> {
return __request(OpenAPI, {
method: "GET",
url: "/api/v1/utils/health-check/",
})
}
}
export type TDataReadItems = {
@@ -425,7 +437,7 @@ export class ItemsService {
limit,
},
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -446,7 +458,7 @@ export class ItemsService {
body: requestBody,
mediaType: "application/json",
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -466,7 +478,7 @@ export class ItemsService {
id,
},
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -490,7 +502,7 @@ export class ItemsService {
body: requestBody,
mediaType: "application/json",
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
@@ -510,7 +522,7 @@ export class ItemsService {
id,
},
errors: {
422: "Validation Error",
422: `Validation Error`,
},
})
}
+63
View File
@@ -2,6 +2,69 @@
## Latest Changes
## 0.7.1
### Highlights
* Migrate from Poetry to [`uv`](https://github.com/astral-sh/uv).
* Simplifications and improvements for Docker Compose files, Traefik Dockerfiles.
* Make the API use its own domain `api.example.com` and the frontend use `dashboard.example.com`. This would make it easier to deploy them separately if you needed that.
* The backend and frontend on Docker Compose now listen on the same port as the local development servers, this way you can stop the Docker Compose services and run the local development servers without changing the frontend configuration.
### Features
* 🩺 Add DB healthcheck. PR [#1342](https://github.com/fastapi/full-stack-fastapi-template/pull/1342) by [@tiangolo](https://github.com/tiangolo).
### Refactors
* ♻️ Update settings to use top level `.env` file. PR [#1359](https://github.com/fastapi/full-stack-fastapi-template/pull/1359) by [@tiangolo](https://github.com/tiangolo).
* ⬆️ Migrate from Poetry to uv. PR [#1356](https://github.com/fastapi/full-stack-fastapi-template/pull/1356) by [@tiangolo](https://github.com/tiangolo).
* 🔥 Remove logic for development dependencies and Jupyter, it was never documented, and I no longer use that trick. PR [#1355](https://github.com/fastapi/full-stack-fastapi-template/pull/1355) by [@tiangolo](https://github.com/tiangolo).
* ♻️ Use Docker Compose `watch`. PR [#1354](https://github.com/fastapi/full-stack-fastapi-template/pull/1354) by [@tiangolo](https://github.com/tiangolo).
* 🔧 Use plain base official Python Docker image. PR [#1351](https://github.com/fastapi/full-stack-fastapi-template/pull/1351) by [@tiangolo](https://github.com/tiangolo).
* 🚚 Move location of scripts to simplify file structure. PR [#1352](https://github.com/fastapi/full-stack-fastapi-template/pull/1352) by [@tiangolo](https://github.com/tiangolo).
* ♻️ Refactor prestart (migrations), move that to its own container. PR [#1350](https://github.com/fastapi/full-stack-fastapi-template/pull/1350) by [@tiangolo](https://github.com/tiangolo).
* ♻️ Include `FRONTEND_HOST` in CORS origins by default. PR [#1348](https://github.com/fastapi/full-stack-fastapi-template/pull/1348) by [@tiangolo](https://github.com/tiangolo).
* ♻️ Simplify domains with `api.example.com` for API and `dashboard.example.com` for frontend, improve local development with `localhost`. PR [#1344](https://github.com/fastapi/full-stack-fastapi-template/pull/1344) by [@tiangolo](https://github.com/tiangolo).
* 🔥 Simplify Traefik, remove www-redirects that add complexity. PR [#1343](https://github.com/fastapi/full-stack-fastapi-template/pull/1343) by [@tiangolo](https://github.com/tiangolo).
* 🔥 Enable support for Arm Docker images in Mac, remove old patch. PR [#1341](https://github.com/fastapi/full-stack-fastapi-template/pull/1341) by [@tiangolo](https://github.com/tiangolo).
* ♻️ Remove duplicate information in the ItemCreate model. PR [#1287](https://github.com/fastapi/full-stack-fastapi-template/pull/1287) by [@jjaakko](https://github.com/jjaakko).
### Upgrades
* ⬆️ Upgrade FastAPI. PR [#1349](https://github.com/fastapi/full-stack-fastapi-template/pull/1349) by [@tiangolo](https://github.com/tiangolo).
### Docs
* 💡 Add comments to Dockerfile with uv references. PR [#1357](https://github.com/fastapi/full-stack-fastapi-template/pull/1357) by [@tiangolo](https://github.com/tiangolo).
* 📝 Add Email Templates to `backend/README.md`. PR [#1311](https://github.com/fastapi/full-stack-fastapi-template/pull/1311) by [@alejsdev](https://github.com/alejsdev).
### Internal
* 👷 Do not sync labels as it overrides manually added labels. PR [#1307](https://github.com/fastapi/full-stack-fastapi-template/pull/1307) by [@tiangolo](https://github.com/tiangolo).
* 👷 Use uv cache on GitHub Actions. PR [#1366](https://github.com/fastapi/full-stack-fastapi-template/pull/1366) by [@tiangolo](https://github.com/tiangolo).
* 👷 Update GitHub Actions format. PR [#1363](https://github.com/fastapi/full-stack-fastapi-template/pull/1363) by [@tiangolo](https://github.com/tiangolo).
* 👷 Use `uv` for Python env to generate client. PR [#1362](https://github.com/fastapi/full-stack-fastapi-template/pull/1362) by [@tiangolo](https://github.com/tiangolo).
* 👷 Run tests from Python environment (with `uv`), not from Docker container. PR [#1361](https://github.com/fastapi/full-stack-fastapi-template/pull/1361) by [@tiangolo](https://github.com/tiangolo).
* 🔨 Update `generate-client.sh` script, make it fail on errors, fix generation. PR [#1360](https://github.com/fastapi/full-stack-fastapi-template/pull/1360) by [@tiangolo](https://github.com/tiangolo).
* 👷 Add GitHub Actions workflow to lint backend apart from tests. PR [#1358](https://github.com/fastapi/full-stack-fastapi-template/pull/1358) by [@tiangolo](https://github.com/tiangolo).
* 👷 Improve playwright CI job. PR [#1335](https://github.com/fastapi/full-stack-fastapi-template/pull/1335) by [@patrick91](https://github.com/patrick91).
* 👷 Update `issue-manager.yml`. PR [#1329](https://github.com/fastapi/full-stack-fastapi-template/pull/1329) by [@tiangolo](https://github.com/tiangolo).
* 💚 Set `include-hidden-files` to `True` when using the `upload-artifact` GH action. PR [#1327](https://github.com/fastapi/full-stack-fastapi-template/pull/1327) by [@svlandeg](https://github.com/svlandeg).
* 👷🏻 Auto-generate frontend client . PR [#1320](https://github.com/fastapi/full-stack-fastapi-template/pull/1320) by [@alejsdev](https://github.com/alejsdev).
* 🐛 Fix in `.github/labeler.yml`. PR [#1322](https://github.com/fastapi/full-stack-fastapi-template/pull/1322) by [@alejsdev](https://github.com/alejsdev).
* 👷 Update `.github/labeler.yml`. PR [#1321](https://github.com/fastapi/full-stack-fastapi-template/pull/1321) by [@alejsdev](https://github.com/alejsdev).
* 👷 Update `latest-changes` GitHub Action. PR [#1315](https://github.com/fastapi/full-stack-fastapi-template/pull/1315) by [@tiangolo](https://github.com/tiangolo).
* 👷 Update configs for labeler. PR [#1308](https://github.com/fastapi/full-stack-fastapi-template/pull/1308) by [@tiangolo](https://github.com/tiangolo).
* 👷 Update GitHub Action labeler to add only one label. PR [#1304](https://github.com/fastapi/full-stack-fastapi-template/pull/1304) by [@tiangolo](https://github.com/tiangolo).
* ⬆️ Bump axios from 1.6.2 to 1.7.4 in /frontend. PR [#1301](https://github.com/fastapi/full-stack-fastapi-template/pull/1301) by [@dependabot[bot]](https://github.com/apps/dependabot).
* 👷 Update GitHub Action labeler dependencies. PR [#1302](https://github.com/fastapi/full-stack-fastapi-template/pull/1302) by [@tiangolo](https://github.com/tiangolo).
* 👷 Update GitHub Action labeler permissions. PR [#1300](https://github.com/fastapi/full-stack-fastapi-template/pull/1300) by [@tiangolo](https://github.com/tiangolo).
* 👷 Add GitHub Action label-checker. PR [#1299](https://github.com/fastapi/full-stack-fastapi-template/pull/1299) by [@tiangolo](https://github.com/tiangolo).
* 👷 Add GitHub Action labeler. PR [#1298](https://github.com/fastapi/full-stack-fastapi-template/pull/1298) by [@tiangolo](https://github.com/tiangolo).
* 👷 Add GitHub Action add-to-project. PR [#1297](https://github.com/fastapi/full-stack-fastapi-template/pull/1297) by [@tiangolo](https://github.com/tiangolo).
* 👷 Update issue-manager. PR [#1288](https://github.com/fastapi/full-stack-fastapi-template/pull/1288) by [@tiangolo](https://github.com/tiangolo).
## 0.7.0
Lots of new things! 🎁
+13
View File
@@ -0,0 +1,13 @@
#! /usr/bin/env bash
set -e
set -x
cd backend
python -c "import app.main; import json; print(json.dumps(app.main.app.openapi()))" > ../openapi.json
cd ..
node frontend/modify-openapi-operationids.js
mv openapi.json frontend/
cd frontend
npm run generate-client
npx biome format --write ./src/client
+1 -1
View File
@@ -12,4 +12,4 @@ fi
docker-compose build
docker-compose up -d
docker-compose exec -T backend bash /app/tests-start.sh "$@"
docker-compose exec -T backend bash scripts/tests-start.sh "$@"
+1 -1
View File
@@ -7,5 +7,5 @@ set -x
docker compose build
docker compose down -v --remove-orphans # Remove possibly previous broken stacks left hanging after an error
docker compose up -d
docker compose exec -T backend bash /app/tests-start.sh "$@"
docker compose exec -T backend bash scripts/tests-start.sh "$@"
docker compose down -v --remove-orphans