Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc8b67d585 | ||
|
|
16174fe4cb | ||
|
|
b5529e0dc5 | ||
|
|
b6dc6dd6b8 |
No files matched your search
@@ -9,7 +9,9 @@
|
|||||||
"Bash(PYTHONPATH=. uv run *)",
|
"Bash(PYTHONPATH=. uv run *)",
|
||||||
"Bash(python *)",
|
"Bash(python *)",
|
||||||
"Bash(DATABASE_URL=\"sqlite+aiosqlite:////tmp/claude-1000/-home-iroddis-dev-armament-fitguide/41e5e14d-88fe-45e7-ba3a-be5a2cbde2cd/scratchpad/mig_test.db\" uv run alembic upgrade head)",
|
"Bash(DATABASE_URL=\"sqlite+aiosqlite:////tmp/claude-1000/-home-iroddis-dev-armament-fitguide/41e5e14d-88fe-45e7-ba3a-be5a2cbde2cd/scratchpad/mig_test.db\" uv run alembic upgrade head)",
|
||||||
"Bash(sqlite3 /tmp/claude-1000/-home-iroddis-dev-armament-fitguide/41e5e14d-88fe-45e7-ba3a-be5a2cbde2cd/scratchpad/mig_test.db '.schema users')"
|
"Bash(sqlite3 /tmp/claude-1000/-home-iroddis-dev-armament-fitguide/41e5e14d-88fe-45e7-ba3a-be5a2cbde2cd/scratchpad/mig_test.db '.schema users')",
|
||||||
|
"Bash(docker build *)",
|
||||||
|
"Bash(git status *)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,8 @@ venv/
|
|||||||
|
|
||||||
# Databases
|
# Databases
|
||||||
*.db
|
*.db
|
||||||
|
*.db-shm
|
||||||
|
*.db-wal
|
||||||
*.sqlite3
|
*.sqlite3
|
||||||
|
|
||||||
# Test / tooling
|
# Test / tooling
|
||||||
|
|||||||
+5
-2
@@ -18,8 +18,11 @@ RUN uv sync --no-dev
|
|||||||
|
|
||||||
# Copy the application.
|
# Copy the application.
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN chmod +x entrypoint.sh
|
||||||
|
|
||||||
|
# If sqlite3 is used
|
||||||
|
VOLUME /data
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Default: run the API server. docker-compose overrides this to also seed.
|
# Seeds perms/roles/superuser (idempotent, no-op if already present), then runs the API server.
|
||||||
CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
ENTRYPOINT ["./entrypoint.sh"]
|
||||||
@@ -30,6 +30,8 @@ clean:
|
|||||||
docker:
|
docker:
|
||||||
mkdir -p artifacts
|
mkdir -p artifacts
|
||||||
docker build -t $(IMAGE_NAME):$(VERSION) .
|
docker build -t $(IMAGE_NAME):$(VERSION) .
|
||||||
|
|
||||||
|
docker-push: docker
|
||||||
docker tag $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):latest
|
docker tag $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):latest
|
||||||
docker tag $(IMAGE_NAME):$(VERSION) git.kinesin.ca/kinesin/$(IMAGE_NAME):$(VERSION)
|
docker tag $(IMAGE_NAME):$(VERSION) git.kinesin.ca/kinesin/$(IMAGE_NAME):$(VERSION)
|
||||||
docker tag $(IMAGE_NAME):$(VERSION) git.kinesin.ca/kinesin/$(IMAGE_NAME):latest
|
docker tag $(IMAGE_NAME):$(VERSION) git.kinesin.ca/kinesin/$(IMAGE_NAME):latest
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ Works with SQLite (aiosqlite) or Postgres (asyncpg) depending on DATABASE_URL.
|
|||||||
|
|
||||||
from collections.abc import AsyncGenerator
|
from collections.abc import AsyncGenerator
|
||||||
|
|
||||||
|
from sqlalchemy import event
|
||||||
from sqlalchemy.ext.asyncio import (
|
from sqlalchemy.ext.asyncio import (
|
||||||
AsyncSession,
|
AsyncSession,
|
||||||
async_sessionmaker,
|
async_sessionmaker,
|
||||||
@@ -21,6 +22,19 @@ class Base(DeclarativeBase):
|
|||||||
|
|
||||||
engine = create_async_engine(settings.database_url, echo=settings.debug, future=True)
|
engine = create_async_engine(settings.database_url, echo=settings.debug, future=True)
|
||||||
|
|
||||||
|
if engine.sync_engine.dialect.name == "sqlite":
|
||||||
|
|
||||||
|
@event.listens_for(engine.sync_engine, "connect")
|
||||||
|
def _set_sqlite_pragma(dbapi_connection, connection_record) -> None:
|
||||||
|
"""WAL mode lets readers/writers avoid blocking each other; busy_timeout
|
||||||
|
makes a connection wait for a lock instead of immediately raising
|
||||||
|
"database is locked" (the pysqlite/aiosqlite default is 0ms).
|
||||||
|
"""
|
||||||
|
cursor = dbapi_connection.cursor()
|
||||||
|
cursor.execute("PRAGMA journal_mode=WAL")
|
||||||
|
cursor.execute("PRAGMA busy_timeout=5000")
|
||||||
|
cursor.close()
|
||||||
|
|
||||||
AsyncSessionLocal = async_sessionmaker(
|
AsyncSessionLocal = async_sessionmaker(
|
||||||
engine,
|
engine,
|
||||||
class_=AsyncSession,
|
class_=AsyncSession,
|
||||||
|
|||||||
@@ -52,8 +52,10 @@ MM_PER_INCH = 25.4
|
|||||||
# e.g.
|
# e.g.
|
||||||
# M8-1.25 - 8mm OD, 1.25 mm pitch
|
# M8-1.25 - 8mm OD, 1.25 mm pitch
|
||||||
# M8 x 1.25
|
# M8 x 1.25
|
||||||
|
# M50x.75 - No leading digit on floats
|
||||||
|
# Float pattern: \d*\.?\d+
|
||||||
_ISO_THREAD_RE = re.compile(
|
_ISO_THREAD_RE = re.compile(
|
||||||
r"^M\s*(?P<diameter>\d+(?:\.\d+)?)\s*[xX-]\s*(?P<pitch>\d+(?:\.\d+)?)(?P<extra>.*)$"
|
r"^M\s*(?P<diameter>\d*\.?\d+)\s*[xX-]\s*P?(?P<pitch>\d*\.?\d+)(?P<extra>.*)$"
|
||||||
)
|
)
|
||||||
|
|
||||||
# e.g.
|
# e.g.
|
||||||
@@ -63,7 +65,7 @@ _ISO_THREAD_RE = re.compile(
|
|||||||
#
|
#
|
||||||
# Leading digit / period, one or more digits, a dash, then
|
# Leading digit / period, one or more digits, a dash, then
|
||||||
_UNC_THREAD_RE = re.compile(
|
_UNC_THREAD_RE = re.compile(
|
||||||
r"^(?P<diameter>\d+(?:\.\d+)?(?:/\d+)?)\s*-\s*(?P<tpi>\d+)"
|
r"^(?P<diameter>\d*\.?\d+)\s*-\s*(?P<tpi>\d*\.?\d+)"
|
||||||
r"\s*(?P<series>UNEF|UNC|UNF|UNS|UN)?$",
|
r"\s*(?P<series>UNEF|UNC|UNF|UNS|UN)?$",
|
||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
# Seed default roles/permissions/superuser, then start the server.
|
|
||||||
command: >
|
|
||||||
sh -c "uv run python -m scripts.seed &&
|
|
||||||
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000"
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
pgdata:
|
pgdata:
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Idempotent: creates perms/roles/superuser only if missing.
|
||||||
|
uv run python -m scripts.seed
|
||||||
|
|
||||||
|
exec uv run uvicorn app.main:app --host 0.0.0.0 --port 8000
|
||||||
Reference in new issue
Block a user