attempt to make the image smaller

This commit is contained in:
McCloudS
2025-02-03 22:03:28 -07:00
committed by GitHub
parent 34a09e012f
commit e0214ba858

View File

@@ -1,23 +1,34 @@
FROM python:3.11-slim-bullseye
# Stage 1: Build dependencies in a full-featured Python image
FROM python:3.11-alpine AS builder
WORKDIR /subgen
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/requirements.txt /subgen/requirements.txt
# Install dependencies required for building wheels
RUN apk add --no-cache \
ffmpeg \
git \
build-base \
python3-dev \
libffi-dev
RUN apt-get update \
&& apt-get install -y \
python3 \
python3-pip \
ffmpeg \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip install -r requirements.txt
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# Stage 2: Create a minimal final image
FROM python:3.11-alpine
WORKDIR /subgen
# Install runtime dependencies (minimal set)
RUN apk add --no-cache ffmpeg git
# Copy only the required files from the builder stage
COPY --from=builder /install /usr/local
COPY launcher.py subgen.py language_code.py /subgen/
# Set environment variable for cleaner output
ENV PYTHONUNBUFFERED=1
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/launcher.py /subgen/launcher.py
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/subgen.py /subgen/subgen.py
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/language_code.py /subgen/language_code.py
CMD [ "bash", "-c", "python3 -u launcher.py" ]
# Run the application
CMD ["python3", "-u", "launcher.py"]