diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5a2eb9c1..4164a23c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,4 +16,9 @@ jobs: uses: docker/build-push-action@v6 with: context: . + load: true push: false + tags: local/test-image:latest + + - name: Run image help + run: docker run --rm --entrypoint "${{ github.event.repository.name }}" local/test-image:latest --help diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 548b9015..8493a6cb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,10 +23,10 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Set image name - run: echo "IMAGE_NAME=ghcr.io/hyperleda/hyperleda" >> $GITHUB_ENV + run: echo "IMAGE_NAME=ghcr.io/hyperleda/hyperleda" >> "$GITHUB_ENV" - name: Set short SHA - run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV + run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> "$GITHUB_ENV" - name: Build and push image uses: docker/build-push-action@v6 diff --git a/.template.yaml b/.template.yaml index d501d481..b964972c 100644 --- a/.template.yaml +++ b/.template.yaml @@ -1,5 +1,6 @@ # Autogenerated - DO NOT EDIT # Parameters of the project as generated from template -_commit: 179dc2a +_commit: f510818 _src_path: gh:kraysent/python-template +package_name: app project_name: db_app diff --git a/Dockerfile b/Dockerfile index b5e7c87e..a55519bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,12 @@ -FROM python:3.13-slim-bookworm -COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ -RUN apt-get update && apt-get install -y --no-install-recommends git curl && apt-get clean -WORKDIR /usr/src/app -COPY pyproject.toml ./ -RUN uv sync -COPY app app -COPY main.py main.py +FROM python:3.12-slim AS builder +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/ +WORKDIR /app +COPY pyproject.toml uv.lock README.md ./ +COPY app ./app +RUN uv sync --frozen --no-dev + +FROM python:3.12-slim AS runtime +WORKDIR /app +COPY --from=builder /app/.venv /app/.venv +ENV PATH="/app/.venv/bin:$PATH" +COPY . . diff --git a/app/__init__.py b/app/__init__.py index e69de29b..8b137891 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -0,0 +1 @@ + diff --git a/main.py b/app/cli.py similarity index 100% rename from main.py rename to app/cli.py diff --git a/makefile b/makefile index 2185a346..43ec0782 100644 --- a/makefile +++ b/makefile @@ -21,18 +21,18 @@ check: -exec uv run python -m py_compile {} + @echo "Compilation ok." - @uvx ruff format \ + @uv run ruff format \ --quiet \ --config=pyproject.toml \ --check @echo "Formatting ok." - @uvx ruff check \ + @uv run ruff check \ --quiet \ --config=pyproject.toml @echo "Linter ok." - @output=$$(uvx basedpyright 2>&1); exit_code=$$?; \ + @output=$$(uv run basedpyright 2>&1); exit_code=$$?; \ if [ $$exit_code -ne 0 ]; then echo "$$output"; fi; \ exit $$exit_code @echo "Typechecking ok." @@ -44,11 +44,11 @@ check: @echo "Testing ok." fix: - @uvx ruff format \ + @uv run ruff format \ --quiet \ --config=pyproject.toml - @uvx ruff check \ + @uv run ruff check \ --quiet \ --config=pyproject.toml \ --fix diff --git a/pyproject.toml b/pyproject.toml index 75f649d2..049ba6f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,13 @@ [project] -name = "hyperleda-backend" +name = "app" version = "0.1.0" readme = "README.md" requires-python = "~=3.13.0" dependencies = [ + "click~=8.3.1", "astropy>=7.1.0", "astroquery>=0.4.10", "bcrypt>=4.2.1", - "click>=8.1.8", "jinja2>=3.1.5", "pandas>=2.3.2", "psycopg[binary,pool]>=3.2.4", @@ -31,6 +31,13 @@ dependencies = [ "opentelemetry-exporter-otlp>=1.40.0", ] +[project.scripts] +"app" = "app.cli:cli" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + [dependency-groups] dev = [ # fixed version so no new linter/formatter errors are introduced over time diff --git a/tests/integration/adminapi_server_test.py b/tests/integration/adminapi_server_test.py index 83a98d67..980ff23e 100644 --- a/tests/integration/adminapi_server_test.py +++ b/tests/integration/adminapi_server_test.py @@ -45,7 +45,8 @@ def setUpClass(cls) -> None: cls.process = subprocess.Popen( [ sys.executable, - "main.py", + "-m", + "app.cli", "adminapi", "-c", "configs/dev/adminapi.yaml", diff --git a/tests/integration/dataapi_server_test.py b/tests/integration/dataapi_server_test.py index 7ab34ee4..02f3e4f9 100644 --- a/tests/integration/dataapi_server_test.py +++ b/tests/integration/dataapi_server_test.py @@ -45,7 +45,8 @@ def setUpClass(cls) -> None: cls.process = subprocess.Popen( [ sys.executable, - "main.py", + "-m", + "app.cli", "dataapi", "-c", "configs/dev/dataapi.yaml",