Dockerfile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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,W391 .
  19. COPY ./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 directory for the app user
  26. RUN mkdir -p /app
  27. # create the app user
  28. #RUN addgroup --system app && adduser --system --group app
  29. # create the appropriate directories
  30. ENV APP_HOME=/app
  31. RUN mkdir -p $APP_HOME
  32. WORKDIR $APP_HOME
  33. # install system dependencies
  34. RUN apt-get update && apt-get install -y sqlite3 netcat vim
  35. COPY --from=builder /app/wheels /wheels
  36. COPY --from=builder /app/requirements.txt .
  37. RUN pip install --upgrade pip
  38. RUN pip install --no-cache /wheels/*
  39. # copy entrypoint.sh
  40. COPY ./entrypoint.sh .
  41. # copy project
  42. COPY . $APP_HOME
  43. # chown all the files to the app user
  44. #RUN chown -R app:app $APP_HOME
  45. # change to the app user
  46. #USER app
  47. WORKDIR $APP_HOME/gestion_reservas
  48. # run entrypoint.sh
  49. ENTRYPOINT ["/app/entrypoint.sh"]