Modernized build tooling
This commit is contained in:
+36
-44
@@ -1,52 +1,44 @@
|
||||
FROM python:3.13
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM python:3.13-slim AS builder
|
||||
|
||||
LABEL maintainer="Jeffrey Phillips Freeman jeffrey.freeman@cleverthis.com"
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV PYENV_ROOT="/.pyenv" \
|
||||
PATH="/.pyenv/bin:/.pyenv/shims:$PATH"
|
||||
# Install uv
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
|
||||
|
||||
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
|
||||
# Set up working directory
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt update -y && \
|
||||
apt-get upgrade -y && \
|
||||
apt-get dist-upgrade -y && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libssl-dev \
|
||||
libreadline-dev \
|
||||
libncursesw5-dev \
|
||||
libssl-dev \
|
||||
libsqlite3-dev \
|
||||
tk-dev \
|
||||
libgdbm-dev \
|
||||
libc6-dev \
|
||||
libbz2-dev \
|
||||
nano && \
|
||||
apt-get clean && \
|
||||
rm -r /var/lib/apt/lists/*
|
||||
# Copy dependency files
|
||||
COPY pyproject.toml uv.lock ./
|
||||
|
||||
RUN pyenv install 3.13.3 && \
|
||||
pyenv install 3.12.10 && \
|
||||
pyenv install 3.11.12 && \
|
||||
pyenv install 3.10.17 && \
|
||||
pyenv install 3.9.21 && \
|
||||
pyenv install 3.8.20 && \
|
||||
pyenv install pypy-7.3.19 && \
|
||||
pyenv global 3.13.3 && \
|
||||
pyenv global 3.12.10 && \
|
||||
pyenv global 3.11.12 && \
|
||||
pyenv global 3.10.17 && \
|
||||
pyenv global 3.9.21 && \
|
||||
pyenv global 3.8.20 && \
|
||||
pyenv global pypy-7.3.19
|
||||
# Install dependencies
|
||||
RUN uv pip install --system --no-cache-dir --compile-bytecode -e .
|
||||
|
||||
RUN /.pyenv/versions/3.13.3/bin/python3.13 -m pip install --upgrade pip
|
||||
RUN pip install tox
|
||||
# Copy source code
|
||||
COPY src/ ./src/
|
||||
|
||||
RUN mkdir -p /usr/src/boilerplate && \
|
||||
chmod a+rwx -R /usr/src/boilerplate && \
|
||||
mkdir /.cache && \
|
||||
chmod a+rwx /.cache && \
|
||||
mkdir /.tox && \
|
||||
chmod a+rwx /.tox
|
||||
# Build wheel
|
||||
RUN uv pip install --system build && \
|
||||
python -m build --wheel --outdir /dist
|
||||
|
||||
VOLUME /usr/src/boilerplate
|
||||
# Runtime stage
|
||||
FROM python:3.13-slim
|
||||
|
||||
# Create non-root user
|
||||
RUN useradd -m -u 1000 appuser
|
||||
|
||||
# Install runtime dependencies
|
||||
COPY --from=builder /dist/*.whl /tmp/
|
||||
RUN pip install --no-cache-dir /tmp/*.whl && \
|
||||
rm -rf /tmp/*
|
||||
|
||||
# Switch to non-root user
|
||||
USER appuser
|
||||
|
||||
# Set entrypoint
|
||||
ENTRYPOINT ["python", "-m", "boilerplate"]
|
||||
CMD ["--help"]
|
||||
Reference in New Issue
Block a user