Update Dockerfile

This commit is contained in:
2025-03-12 22:12:02 +00:00
parent 77fbf16828
commit 6871fad313

View File

@@ -1,36 +1,18 @@
FROM python:3.9-slim as builder
FROM python:3.9-slim
RUN apt-get update && apt-get install -y \
libzbar0 \
libgl1-mesa-glx \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt pyarmor
COPY qr_detector.py .
RUN pyarmor obfuscate --recursive qr_detector.py
FROM python:3.9-slim as runtime
RUN apt-get update && apt-get install -y \
libzbar0 \
libgl1-mesa-glx \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -m -u 1000 appuser
USER appuser
# Set working directory
WORKDIR /app
# Copy requirements file and install dependencies
COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
COPY --from=builder /build/dist ./dist
# Copy the entire project directory
COPY . .
ENV PATH=/home/appuser/.local/bin:$PATH
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
CMD ["python", "dist/qr_detector.py"]
# Command to run the application
CMD ["python", "src/qr_detector.py"]