Dockerfile.k8s 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # syntax=docker/dockerfile:1
  2. ##################
  3. # BUILDER #
  4. ##################
  5. FROM python:3.11-slim 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,E722 .
  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-slim
  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 nginx netcat-openbsd curl vim jq rsync libpango-1.0-0 libpangocairo-1.0-0 libcairo2 -y
  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"]