nekmo-dirhunt
SUCCESS
34m 58s
History Source
SummaryIterations2Transcript34Dockerfile
Dockerfile42 lines · 991 chars
FROM python:3.11-alpine

# Prevent Python from writing pyc files to disk
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app

# Install build dependencies and CA certificates
RUN apk add --no-cache --virtual .build-deps \
        build-base \
        linux-headers \
        openssl-dev \
        zlib-dev \
        libffi-dev \
    && apk add --no-cache ca-certificates

# Upgrade pip
RUN python -m pip install --upgrade pip

# Install runtime dependencies first to leverage Docker layer caching
COPY requirements.txt .
RUN pip install -r requirements.txt

# Install pytest for smoke tests in the final image
RUN pip install pytest

# Copy the source and install the package from source
COPY . .
RUN python -m pip install .

# Strip build dependencies to reduce image size
RUN apk del .build-deps

# Create a non-root user and switch to it for security
RUN adduser -D dirhunt
USER dirhunt

# Set a simple default command to display help
ENTRYPOINT ["dirhunt"]
CMD ["--help"]