diff --git a/VERSION b/VERSION index b1e80bb..845639e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.3 +0.1.4 diff --git a/alembic/env.py b/alembic/env.py index 81ae248..12d8a51 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -15,6 +15,7 @@ # Import models so Base.metadata has all table definitions registered import lenny.core.models # noqa: F401 +import lenny.core.cache # noqa: F401 # Alembic Config object — access to alembic.ini values config = context.config diff --git a/alembic/versions/c6b7da6debc2_add_cache_table.py b/alembic/versions/c6b7da6debc2_add_cache_table.py new file mode 100644 index 0000000..83d56d1 --- /dev/null +++ b/alembic/versions/c6b7da6debc2_add_cache_table.py @@ -0,0 +1,43 @@ +"""add cache table + +Revision ID: c6b7da6debc2 +Revises: 001_baseline +Create Date: 2026-03-28 18:58:54.334094 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = 'c6b7da6debc2' +down_revision: Union[str, None] = '001_baseline' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('cache', + sa.Column('id', sa.BigInteger(), nullable=False), + sa.Column('scope', sa.String(length=64), nullable=False), + sa.Column('key', sa.String(length=255), nullable=False), + sa.Column('value', sa.String(length=1024), nullable=True), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False), + sa.PrimaryKeyConstraint('id'), + prefixes=['UNLOGGED'] + ) + op.create_index('idx_cache_expires', 'cache', ['expires_at'], unique=False) + op.create_index('idx_cache_scope_key_expires', 'cache', ['scope', 'key', 'expires_at'], unique=False) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index('idx_cache_scope_key_expires', table_name='cache') + op.drop_index('idx_cache_expires', table_name='cache') + op.drop_table('cache') + # ### end Alembic commands ### diff --git a/compose.yaml b/compose.yaml index e6df61a..4289c00 100644 --- a/compose.yaml +++ b/compose.yaml @@ -13,7 +13,7 @@ services: s3: condition: service_healthy healthcheck: - test: ["CMD-SHELL", "curl -sf http://localhost:1337/v1/api/opds || exit 1"] + test: ["CMD-SHELL", "curl -sf http://localhost:1337/v1/api/health || exit 1"] interval: 10s timeout: 5s retries: 3 diff --git a/docker/api/Dockerfile b/docker/api/Dockerfile index 31ab113..1b602e7 100644 --- a/docker/api/Dockerfile +++ b/docker/api/Dockerfile @@ -32,4 +32,4 @@ COPY ./docker/nginx/conf.d/lenny.conf /etc/nginx/conf.d/lenny.conf COPY ./docker/utils/migrate.sh /app/docker/utils/migrate.sh RUN chmod +x /app/docker/utils/migrate.sh -CMD ["sh", "-c", "sh /app/docker/utils/migrate.sh && python -m uvicorn lenny.app:app --host 0.0.0.0 --port 1337 --workers=${LENNY_WORKERS:-1} --log-level=${LENNY_LOG_LEVEL:-info} $([ \"${LENNY_PRODUCTION:-true}\" = \"false\" ] && echo --reload) & exec nginx"] +CMD ["sh", "-c", "sh /app/docker/utils/migrate.sh && python -m uvicorn lenny.app:app --host 0.0.0.0 --port 1337 --workers=${LENNY_WORKERS:-$([ \"${LENNY_PRODUCTION:-true}\" = \"false\" ] && echo 1 || echo 3)} --log-level=${LENNY_LOG_LEVEL:-info} $([ \"${LENNY_PRODUCTION:-true}\" = \"false\" ] && echo --reload) & exec nginx"] diff --git a/docker/configure.sh b/docker/configure.sh index 05a2e5a..89fbf73 100755 --- a/docker/configure.sh +++ b/docker/configure.sh @@ -17,7 +17,7 @@ else # Use environment variables if they are set, otherwise provide defaults or generate secure values LENNY_HOST="localhost" LENNY_PORT="${LENNY_PORT:-8080}" - LENNY_WORKERS="${LENNY_WORKERS:-1}" + LENNY_WORKERS="${LENNY_WORKERS:-3}" LENNY_LOG_LEVEL="${LENNY_LOG_LEVEL:-debug}" LENNY_PRODUCTION="${LENNY_PRODUCTION:-true}" LENNY_SSL_CRT="${LENNY_SSL_CRT:-}" @@ -96,3 +96,27 @@ NODE_ENV=$NODE_ENV EOF fi + +# Install 'lenny' CLI command if not already available +LENNY_PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)" +if ! command -v lenny &>/dev/null; then + INSTALL_DIR="$HOME/.local/bin" + mkdir -p "$INSTALL_DIR" + cat > "$INSTALL_DIR/lenny" <