Dockerfile.k8s 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. # copia fichero de configuración de nginx
  36. COPY ./nginx/nginx.conf /etc/nginx/
  37. # enlace los logs de nginx a stdout
  38. RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
  39. # copy entrypoint.sh
  40. COPY ./entrypoint.sh .
  41. # copy project
  42. COPY . $APP_HOME
  43. # change to the app user
  44. WORKDIR $APP_HOME/src
  45. # run entrypoint.sh
  46. ENTRYPOINT ["/app/entrypoint.sh"]