Skip to content

Commit

Permalink
replace poetry with uv
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanschultzie committed Jan 2, 2025
1 parent b70ace5 commit 25fd60d
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 411 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
33 changes: 22 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
# Use the official Python image as base image
FROM python:3.12-slim
# Use a Python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

# Install the project into `/app`
WORKDIR /app

ENV POETRY_VERSION=1.8.3 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_HOME="/opt/poetry"
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1

RUN pip install "poetry==$POETRY_VERSION" && poetry --version
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy

COPY pyproject.toml poetry.lock /app/
RUN --mount=type=cache,target=/home/.cache/pypoetry/cache \
--mount=type=cache,target=/home/.cache/pypoetry/artifacts \
poetry install --no-root
# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-dev

# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
ADD . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"

# Copy the Flask application code to the container
COPY . .
Expand All @@ -21,4 +32,4 @@ COPY . .
EXPOSE 53336

# Command to run the Flask application
CMD ["python", "run.py"]
CMD ["python", "run.py"]
5 changes: 2 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
version: '3'
services:
ethereum_health_checker:
image: lavender5/rpc_health_checker:master
rpc_health_checker:
build: .
container_name: health
restart: unless-stopped
ports:
- "53336:53336"
network_mode: "host"
377 changes: 0 additions & 377 deletions poetry.lock

This file was deleted.

32 changes: 12 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
[tool.poetry]
name = "eth-health-checker"
[project]
name = "rpc-health-checker"
version = "0.1.0"
description = "Ethereum /health endpoint script"
authors = ["Dylan Schultz <[email protected]>"]
description = "Add your description here"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
flask = "^3.0.2"
python-dotenv = "^1.0.1"
requests = "^2.31.0"


[tool.poetry.group.dev.dependencies]
ruff = "^0.3.4"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

requires-python = ">=3.12"
dependencies = [
"flask>=3.0.2",
"logging>=0.4.9.6",
"python-dotenv>=1.0.1",
"requests>=2.32.3",
"ruff>=0.8.5",
]

[tool.ruff]
line-length = 120
line-length = 120
3 changes: 3 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import logging
from flask import Flask
from app.routes import api # Import the Blueprint

app = Flask(__name__)
app.register_blueprint(api) # Register the Blueprint

logger = logging.getLogger(__name__)


def main():
app.run(host="0.0.0.0", port=53336)
Expand Down
257 changes: 257 additions & 0 deletions uv.lock

Large diffs are not rendered by default.

0 comments on commit 25fd60d

Please sign in to comment.