|
|
|
|
|
|
|
|
FROM python:3.9.23-slim-bookworm |
|
|
|
|
|
|
|
|
LABEL maintainer="Kev-HL (GitHub)" |
|
|
LABEL org.opencontainers.image.source="https://github.com/Kev-HL/capsule-defect-segmentation-api" |
|
|
|
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
|
|
|
RUN addgroup --system appuser && adduser --system --ingroup appuser appuser |
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get upgrade -y && apt-get clean && rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
|
|
|
COPY app/requirements.txt . |
|
|
|
|
|
|
|
|
RUN pip install --no-cache-dir -r requirements.txt |
|
|
|
|
|
|
|
|
|
|
|
COPY --chown=appuser:appuser app/tflite_runtime-2.19.0-cp39-cp39-linux_x86_64.whl . |
|
|
RUN pip install --no-cache-dir ./tflite_runtime-2.19.0-cp39-cp39-linux_x86_64.whl |
|
|
|
|
|
|
|
|
RUN rm tflite_runtime-2.19.0-cp39-cp39-linux_x86_64.whl && \ |
|
|
find /usr/local/lib/python3.9/ -type d -name '__pycache__' -prune -exec rm -rf {} + && \ |
|
|
rm -rf /usr/share/doc /usr/share/man /usr/share/info /usr/share/locale/* |
|
|
|
|
|
|
|
|
COPY --chown=appuser:appuser app/main.py . |
|
|
|
|
|
|
|
|
COPY --chown=appuser:appuser app/aux.py . |
|
|
|
|
|
|
|
|
COPY --chown=appuser:appuser models/final_model/final_model.tflite . |
|
|
|
|
|
|
|
|
RUN mkdir -p templates && chown -R appuser:appuser templates |
|
|
COPY --chown=appuser:appuser app/templates/ templates/ |
|
|
|
|
|
|
|
|
RUN mkdir -p static/uploads static/results static/samples && chown -R appuser:appuser static |
|
|
|
|
|
|
|
|
COPY --chown=appuser:appuser app/samples/ static/samples/ |
|
|
|
|
|
|
|
|
RUN mkdir -p fonts && chown -R appuser:appuser fonts |
|
|
COPY --chown=appuser:appuser app/fonts/OpenSans-Bold.ttf fonts |
|
|
COPY --chown=appuser:appuser app/fonts/OFL.txt fonts |
|
|
|
|
|
|
|
|
RUN chmod -R 777 static |
|
|
|
|
|
|
|
|
USER appuser |
|
|
|
|
|
|
|
|
EXPOSE 8000 |
|
|
|
|
|
|
|
|
|
|
|
ENV PYTHONUNBUFFERED=1 |
|
|
|
|
|
|
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] |
|
|
|