Dockerfile.k8s 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # syntax=docker/dockerfile:1
  2. ##################
  3. # BUILDER #
  4. ##################
  5. FROM python:3.11.4-slim-buster AS builder
  6. # set work directory
  7. WORKDIR /app
  8. # set environment variables
  9. ENV PYTHONDONTWRITEBYTECODE=1
  10. ENV PYTHONUNBUFFERED=1
  11. # install system dependencies
  12. RUN apt-get update && \
  13. apt-get install -y --no-install-recommends gcc
  14. # lint
  15. RUN pip install --upgrade pip
  16. RUN pip install flake8==6.0.0
  17. COPY . /app/
  18. RUN flake8 --ignore=E501,F401,E126 .
  19. COPY ./src/requirements.txt .
  20. RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
  21. ##################
  22. # FINAL #
  23. ##################
  24. FROM python:3.11.4-slim-buster
  25. # create the appropriate directories
  26. ENV APP_HOME=/app
  27. RUN mkdir -p $APP_HOME
  28. WORKDIR $APP_HOME
  29. # install system dependencies
  30. RUN apt-get update && apt-get install -y sqlite3 netcat vim procps curl jq
  31. COPY --from=builder /app/wheels /wheels
  32. COPY --from=builder /app/requirements.txt .
  33. RUN pip install --upgrade pip
  34. RUN pip install --no-cache /wheels/*
  35. # copy entrypoint.sh
  36. COPY ./entrypoint.sh .
  37. # copy project
  38. COPY . $APP_HOME
  39. # change to the app user
  40. WORKDIR $APP_HOME/src
  41. # run entrypoint.sh
  42. ENTRYPOINT ["/app/entrypoint.sh"]