Skip to content

Commit a34825d

Browse files
committed
chore: add template
1 parent 2134f2d commit a34825d

File tree

84 files changed

+2404
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2404
-2
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.git
2+
.venv
3+
.mypy_cache
4+
.pytest_cache
5+
.ruff_cache

.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
POSTGRES_URL= # str
2+
JWT_SECRET= # str

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
ruff:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: ruff
11+
run: docker compose -f deployments/dev/docker-compose.yaml run backend ruff check src tests
12+
13+
mypy:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: mypy
18+
run: docker compose -f deployments/dev/docker-compose.yaml run backend mypy src tests
19+
20+
pytest:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: pytest
26+
run: docker compose -f deployments/dev/docker-compose.yaml run backend pytest tests --cov --cov-report=xml
27+
28+
- name: upload coverage reports to codecov
29+
uses: codecov/codecov-action@v5
30+
with:
31+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,7 @@ cython_debug/
169169

170170
# PyPI configuration file
171171
.pypirc
172+
173+
# Custom
174+
.ruff_cache
175+
.uv_cache

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# temp
2-
temp
1+
# APPNANE_SNAKE_CASE
2+
kebab-case > snake_case

alembic.ini

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# path to migration scripts
5+
# Use forward slashes (/) also on windows to provide an os agnostic path
6+
script_location = src/appname_snake_case/infrastructure/alembic
7+
8+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
9+
# Uncomment the line below if you want the files to be prepended with date and time
10+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
11+
# for all available tokens
12+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
13+
14+
# sys.path path, will be prepended to sys.path if present.
15+
# defaults to the current working directory.
16+
prepend_sys_path = sys
17+
18+
# timezone to use when rendering the date within the migration file
19+
# as well as the filename.
20+
# If specified, requires the python>=3.9 or backports.zoneinfo library and tzdata library.
21+
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
22+
# string value is passed to ZoneInfo()
23+
# leave blank for localtime
24+
# timezone =
25+
26+
# max length of characters to apply to the "slug" field
27+
# truncate_slug_length = 40
28+
29+
# set to 'true' to run the environment during
30+
# the 'revision' command, regardless of autogenerate
31+
# revision_environment = false
32+
33+
# set to 'true' to allow .pyc and .pyo files without
34+
# a source .py file to be detected as revisions in the
35+
# versions/ directory
36+
# sourceless = false
37+
38+
# version location specification; This defaults
39+
# to src/app/infrastructure/alembic/versions. When using multiple version
40+
# directories, initial revisions must be specified with --version-path.
41+
# The path separator used here should be the separator specified by "version_path_separator" below.
42+
# version_locations = %(here)s/bar:%(here)s/bat:src/app/infrastructure/alembic/versions
43+
44+
# version path separator; As mentioned above, this is the character used to split
45+
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
46+
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
47+
# Valid values for version_path_separator are:
48+
#
49+
# version_path_separator = :
50+
# version_path_separator = ;
51+
# version_path_separator = space
52+
# version_path_separator = newline
53+
#
54+
# Use os.pathsep. Default configuration used for new projects.
55+
version_path_separator = os
56+
57+
# set to 'true' to search source files recursively
58+
# in each "version_locations" directory
59+
# new in Alembic version 1.10
60+
# recursive_version_locations = false
61+
62+
# the output encoding used when revision files
63+
# are written from script.py.mako
64+
# output_encoding = utf-8
65+
66+
sqlalchemy.url = none
67+
68+
69+
[post_write_hooks]
70+
# post_write_hooks defines scripts or Python functions that are run
71+
# on newly generated revision scripts. See the documentation for further
72+
# detail and examples
73+
74+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
75+
# hooks = black
76+
# black.type = console_scripts
77+
# black.entrypoint = black
78+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
79+
80+
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
81+
# hooks = ruff
82+
# ruff.type = exec
83+
# ruff.executable = %(here)s/.venv/bin/ruff
84+
# ruff.options = --fix REVISION_SCRIPT_FILENAME
85+
86+
# Logging configuration
87+
[loggers]
88+
keys = root,sqlalchemy,alembic
89+
90+
[handlers]
91+
keys = console
92+
93+
[formatters]
94+
keys = generic
95+
96+
[logger_root]
97+
level = WARNING
98+
handlers = console
99+
qualname =
100+
101+
[logger_sqlalchemy]
102+
level = WARNING
103+
handlers =
104+
qualname = sqlalchemy.engine
105+
106+
[logger_alembic]
107+
level = INFO
108+
handlers =
109+
qualname = alembic
110+
111+
[handler_console]
112+
class = StreamHandler
113+
args = (sys.stderr,)
114+
level = NOTSET
115+
formatter = generic
116+
117+
[formatter_generic]
118+
format = %(levelname)-5.5s [%(name)s] %(message)s
119+
datefmt = %H:%M:%S

deployments/dev/.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# External environment variables are not required.

deployments/dev/backend/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ghcr.io/astral-sh/uv:python3.13-alpine AS app
2+
3+
WORKDIR /app
4+
COPY . .
5+
6+
ENV UV_LINK_MODE copy
7+
ENV UV_PROJECT_ENVIRONMENT /run/app/.venv
8+
RUN uv sync --extra dev
9+
10+
ENV PYTHONPATH /app/src:/app/tests
11+
ENV MYPYPATH /app/src:/app/tests
12+
13+
ENV WATCHFILES_FORCE_POLLING true
14+
15+
ENTRYPOINT ["ash", "deployments/dev/backend/entrypoint.sh"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/ash
2+
3+
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
4+
alembic upgrade head
5+
$@
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: appname_kebab_case
2+
3+
services:
4+
backend:
5+
build:
6+
context: ../../
7+
dockerfile: deployments/dev/backend/Dockerfile
8+
tags:
9+
- "appname_kebab_case-backend:dev"
10+
container_name: appname_kebab_case-backend
11+
volumes:
12+
- ../..:/app
13+
- backend-data:/run/app
14+
ports:
15+
- 8000:8000
16+
depends_on:
17+
postgres:
18+
condition: service_healthy
19+
environment:
20+
JWT_SECRET: super-secret-jwt-secret
21+
POSTGRES_URL: postgresql+psycopg://root:root@postgres/root
22+
command: appname_kebab_case-web-service
23+
healthcheck:
24+
test: wget backend:8000/healthcheck -q -O /dev/null
25+
start_period: 1m
26+
start_interval: 1s
27+
interval: 5s
28+
29+
postgres:
30+
image: postgres:16.3-alpine3.19
31+
container_name: appname_kebab_case-postgres
32+
labels:
33+
deployment: dev
34+
volumes:
35+
- postgres-data:/var/lib/postgresql/data
36+
environment:
37+
POSTGRES_DB: root
38+
POSTGRES_USER: root
39+
POSTGRES_PASSWORD: root
40+
healthcheck:
41+
test: pg_isready -d root -U root
42+
start_period: 1m
43+
start_interval: 1s
44+
interval: 5s
45+
46+
volumes:
47+
backend-data: null
48+
49+
postgres-data:
50+
labels:
51+
db: true

0 commit comments

Comments
 (0)