FROM debian:bullseye-20221024-slim@sha256:76cdda8fe5eb597ef5e712e4c9a9f5f1fb119e69f353daaa7bd6d0f6e66e541d EXPOSE 8000 COPY ./requirements.txt /app/requirements.txt RUN apt-get update \ && apt-get install -y python3 python3-pip \ && pip3 install -r /app/requirements.txt \ && apt-get remove -y \ gcc \ curl \ wget \ python3-pip \ python3-dev \ && apt-get autoremove -y \ && apt-get clean # Remove setuid and setgid RUN find / -xdev -perm /6000 -type f -exec chmod a-s {} \; || true # Add user RUN useradd collector -u 1500 -s /usr/sbin/nologin COPY ./src /app/src WORKDIR /app/ USER collector # Add healthcheck HEALTHCHECK --interval=2m --timeout=15s --retries=1 --start-period=30s \ CMD sh ./src/collector/healthcheck.sh COLLECTOR || bash -c 'kill -s 15 1 && (sleep 7; kill -s 9 1)' ENTRYPOINT ["uvicorn", "src.collector.main:app", "--host", "0.0.0.0", "--workers", "1", "--header", "server:collector"]