diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 16a2d89..0000000 --- a/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -FROM python:3.12-slim AS base - -RUN apt-get update && \ - apt-get install -y --no-install-recommends curl ca-certificates && \ - rm -rf /var/lib/apt/lists/* && \ - useradd --uid 1001 --user-group --home-dir=/home/bored-charts --create-home --shell=/bin/false bored-charts -ADD https://astral.sh/uv/install.sh /uv-installer.sh -RUN sh /uv-installer.sh && rm /uv-installer.sh -ENV PATH="/root/.cargo/bin/:$PATH" - -# ------------------------------------------------------------------------------ -FROM base AS app - -WORKDIR /app -RUN chown bored-charts:bored-charts /app - -COPY --chown=bored-charts uv.lock pyproject.toml ./ -COPY --chown=bored-charts bored-charts/pyproject.toml ./bored-charts/pyproject.toml -COPY --chown=bored-charts bored-charts/boredcharts/__init__.py ./bored-charts/boredcharts/__init__.py -COPY --chown=bored-charts example/pyproject.toml ./example/pyproject.toml -COPY --chown=bored-charts example/bcexample/__init__.py ./example/bcexample/__init__.py -RUN touch README.md bored-charts/README.md example/README.md && \ - uv sync --locked --no-dev - -COPY --chown=bored-charts ./ /app/ - -ENV PATH="/app/.venv/bin:$PATH" -ENV PYTHONUNBUFFERED=1 -USER bored-charts -EXPOSE 4000 -CMD ["bc-example"] -HEALTHCHECK CMD ["curl", "--fail", "http://localhost:4000/healthz"] diff --git a/Makefile b/Makefile index 4611c8f..dbdc0e9 100644 --- a/Makefile +++ b/Makefile @@ -44,21 +44,6 @@ fmt: uv run mdformat README.md npx prettier . --write -.PHONY: dev -## Run locally -dev: - UVICORN_RELOAD=true uv run bc-example - -.PHONY: d.up -## Start docker compose -d.up: - docker compose up --build - -.PHONY: d.down -## Stop docker compose -d.down: - docker compose down --remove-orphans - .PHONY: clean ## Remove all hidden generated/cache files clean: diff --git a/.dockerignore b/examples/full/.dockerignore similarity index 100% rename from .dockerignore rename to examples/full/.dockerignore diff --git a/examples/full/Dockerfile b/examples/full/Dockerfile new file mode 100644 index 0000000..befba54 --- /dev/null +++ b/examples/full/Dockerfile @@ -0,0 +1,22 @@ +FROM python:3.12-slim +COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv + +RUN useradd --uid 1001 --user-group --home-dir=/home/bored-charts --create-home --shell=/bin/false bored-charts +USER bored-charts + +COPY --chown=bored-charts pyproject.toml /app/pyproject.toml +RUN chown bored-charts:bored-charts /app + +WORKDIR /app +RUN uv sync --no-install-project --no-install-workspace --no-dev --compile-bytecode + +COPY --chown=bored-charts . /app +WORKDIR /app + +RUN uv sync + +ENV PATH="/app/.venv/bin:$PATH" +ENV PYTHONUNBUFFERED=1 +EXPOSE 4000 +CMD ["bc-example"] +HEALTHCHECK CMD ["curl", "--fail", "http://localhost:4000/healthz"] diff --git a/examples/full/Makefile b/examples/full/Makefile new file mode 100644 index 0000000..ecd826b --- /dev/null +++ b/examples/full/Makefile @@ -0,0 +1,14 @@ +.PHONY: dev +## Run locally +dev: + UVICORN_RELOAD=true uv run bc-example + +.PHONY: up +## Start docker compose +up: + docker compose up --build + +.PHONY: down +## Stop docker compose +down: + docker compose down --remove-orphans diff --git a/examples/full/README.md b/examples/full/README.md index 2c8d70b..86b9ae5 100644 --- a/examples/full/README.md +++ b/examples/full/README.md @@ -20,3 +20,9 @@ Project structure: ├── README.md └── pyproject.toml ``` + +It's also dockerized: + +```bash +docker compose up --build +``` diff --git a/compose.yaml b/examples/full/compose.yaml similarity index 100% rename from compose.yaml rename to examples/full/compose.yaml diff --git a/uv.lock b/uv.lock index d3baf20..4635bf1 100644 --- a/uv.lock +++ b/uv.lock @@ -11,6 +11,18 @@ members = [ "bored-charts-example-full", "minimal", ] +requirements = [ + { name = "djlint", specifier = ">=1.34.1" }, + { name = "httpx", specifier = ">=0.27.0" }, + { name = "mdformat", specifier = ">=0.7.17" }, + { name = "mdformat-footnote", specifier = ">=0.1.1" }, + { name = "mdformat-frontmatter", specifier = ">=2.0.8" }, + { name = "mdformat-gfm", specifier = ">=0.3.6" }, + { name = "mypy", specifier = ">=1.11.1" }, + { name = "pytest", specifier = ">=8.3.2" }, + { name = "ruff", specifier = ">=0.5.7" }, + { name = "types-markdown", specifier = ">=3.6.0.20240316" }, +] [[package]] name = "altair" @@ -36,7 +48,6 @@ all = [ { name = "pandas" }, { name = "pyarrow" }, { name = "vega-datasets" }, - { name = "vegafusion" }, { name = "vegafusion", extra = ["embed"] }, { name = "vl-convert-python" }, ]