mirror of
https://github.com/nikdoof/ohayodash.git
synced 2025-12-13 10:02:17 +00:00
Switch to uv
This commit is contained in:
48
Dockerfile
48
Dockerfile
@@ -1,34 +1,18 @@
|
||||
FROM python:3.12.3-alpine3.18 AS base
|
||||
|
||||
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.12/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"
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
# 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
|
||||
|
||||
FROM base AS runtime
|
||||
COPY --from=builder /runtime /usr/local
|
||||
COPY . /app
|
||||
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
|
||||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
|
||||
ENV UV_PYTHON_DOWNLOADS=0
|
||||
WORKDIR /app
|
||||
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 --locked --no-install-project --no-dev
|
||||
COPY . /app
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
uv sync --locked --no-dev
|
||||
|
||||
|
||||
FROM python:3.13-slim-bookworm
|
||||
COPY --from=builder --chown=app:app /app /app
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
EXPOSE 8000/tcp
|
||||
CMD ["/usr/local/bin/gunicorn", "ohayodash.app:app", "-b", "0.0.0.0:80", "--access-logfile", "-"]
|
||||
CMD ["gunicorn", "ohayodash.app:app", "-b", "0.0.0.0:8000", "--access-logfile", "-"]
|
||||
|
||||
Reference in New Issue
Block a user