Dockerfile update with ofuscation
This commit is contained in:
34
Dockerfile
34
Dockerfile
@@ -1,24 +1,36 @@
|
||||
# Usar una imagen base de Python
|
||||
FROM python:3.9-slim
|
||||
FROM python:3.9-slim as builder
|
||||
|
||||
# Instalar dependencias del sistema necesarias para OpenCV y zbar
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libzbar0 \
|
||||
libgl1-mesa-glx \
|
||||
libglib2.0-0 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Directorio de trabajo
|
||||
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
|
||||
WORKDIR /app
|
||||
|
||||
# Copiar requirements.txt primero para aprovechar la caché de Docker
|
||||
COPY requirements.txt .
|
||||
RUN pip install --user --no-cache-dir -r requirements.txt
|
||||
|
||||
# Instalar dependencias de Python
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY --from=builder /build/dist ./dist
|
||||
|
||||
# Copiar el código fuente
|
||||
COPY . .
|
||||
ENV PATH=/home/appuser/.local/bin:$PATH
|
||||
ENV PYTHONPATH=/app
|
||||
|
||||
# Comando para ejecutar la aplicación
|
||||
CMD ["python", "qr_detector.py"]
|
||||
CMD ["python", "dist/qr_detector.py"]
|
||||
Reference in New Issue
Block a user