diff --git a/Dockerfile b/Dockerfile index db4150f..3b6b9b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,21 @@ FROM python:3.9-alpine AS base +# Builder FROM base AS builder -ENV PYTHONFAULTHANDLER=1 \ - PYTHONUNBUFFERED=1 \ - PYTHONHASHSEED=random \ - PIP_NO_CACHE_DIR=off \ - PIP_DISABLE_PIP_VERSION_CHECK=on \ - PIP_DEFAULT_TIMEOUT=100 \ - POETRY_NO_INTERACTION=1 \ - POETRY_VIRTUALENVS_CREATE=false \ - PATH="$PATH:/runtime/bin" \ - PYTHONPATH="$PYTHONPATH:/runtime/lib/python3.9/site-packages" \ - # Versions: - POETRY_VERSION=2.1.1 - -# System deps: -RUN apk add build-base unzip wget python3-dev libffi-dev rust cargo openssl-dev -RUN pip install "poetry==$POETRY_VERSION" "poetry-plugin-export" +ENV POETRY_VERSION=2.1.1 +RUN apk add build-base unzip wget python3-dev libffi-dev rust cargo openssl-dev && pip install "poetry==$POETRY_VERSION" && poetry self add poetry-plugin-bundle WORKDIR /src +COPY poetry.lock pyproject.toml README.md /src/ +COPY smsbot /src/smsbot +RUN poetry bundle venv /runtime -# Generate requirements and install *all* dependencies. -COPY pyproject.toml poetry.lock /src/ -RUN poetry export --without-hashes --no-interaction --no-ansi -f requirements.txt -o requirements.txt -RUN pip install --prefix=/runtime --force-reinstall -r requirements.txt +# Final container FROM base AS runtime -COPY --from=builder /runtime /usr/local -COPY . /app -WORKDIR /app + +COPY --from=builder /runtime /runtime +ENV PATH=/runtime/bin:$PATH EXPOSE 8000/tcp -CMD ["/usr/local/bin/smsbot"] \ No newline at end of file +CMD ["smsbot"] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 73b4f63..fc4cace 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,10 +2,8 @@ name = "smsbot" version = "0.0.5" description = "A simple Telegram bot to receive SMS messages." -authors = [ - {name = "Andrew Williams",email = "andy@tensixtyone.com"} -] -license = {text = "MIT"} +authors = [{ name = "Andrew Williams", email = "andy@tensixtyone.com" }] +license = { text = "MIT" } readme = "README.md" requires-python = ">=3.9,<3.10" dependencies = [ @@ -13,12 +11,16 @@ dependencies = [ "waitress (>=3.0.2,<4.0.0)", "twilio (>=9.4.6,<10.0.0)", "python-telegram-bot (<20)", - "prometheus-client (>=0.21.1,<0.22.0)" + "prometheus-client (>=0.21.1,<0.22.0)", ] +[tool.poetry] +packages = [{ include = "smsbot" }] + [tool.poetry.scripts] smsbot = "smsbot.cli:main" + [build-system] requires = ["poetry-core>=2.0.0,<3.0.0"] build-backend = "poetry.core.masonry.api" @@ -33,4 +35,4 @@ pytest-flask = "^1.3.0" optional = true [tool.poetry.group.github.dependencies] -pytest-github-actions-annotate-failures = "^0.3.0" \ No newline at end of file +pytest-github-actions-annotate-failures = "^0.3.0"