Dockerfile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. FROM amd64/ubuntu:22.04
  2. ENV DEBIAN_FRONTEND noninteractive
  3. ENV LC_ALL C.UTF-8
  4. ENV LANG C.UTF-8
  5. # pre-requisites
  6. RUN apt-get update && apt-get install --no-install-recommends -y --upgrade python3 python3-pip git curl gunicorn coinor-cbc postgresql-client && apt-get clean
  7. WORKDIR /app
  8. # requirements - doing this earlier, so we don't install them each time. Use --no-cache to refresh them.
  9. COPY requirements /app/requirements
  10. # py dev tooling
  11. RUN python3 -m pip install --no-cache-dir --upgrade pip && python3 --version && \
  12. pip3 install --no-cache-dir --upgrade setuptools && pip3 install highspy && \
  13. PYV=$(python3 -c "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)") && \
  14. pip3 install --no-cache-dir -r requirements/$PYV/app.txt -r requirements/$PYV/dev.txt -r requirements/$PYV/test.txt
  15. # Copy code and meta/config data
  16. COPY setup.* pyproject.toml .flaskenv wsgi.py /app/
  17. COPY flexmeasures/ /app/flexmeasures
  18. RUN find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
  19. COPY .git/ /app/.git
  20. RUN pip3 install --no-cache-dir .
  21. EXPOSE 5000
  22. CMD [ \
  23. "gunicorn", \
  24. "--bind", "0.0.0.0:5000", \
  25. # This is set to /tmp by default, but this is part of the Docker overlay filesystem, and can cause stalls.
  26. # http://docs.gunicorn.org/en/latest/faq.html#how-do-i-avoid-gunicorn-excessively-blocking-in-os-fchmod
  27. "--worker-tmp-dir", "/dev/shm", \
  28. # Ideally you'd want one worker per container, but we don't want to risk the health check timing out because
  29. # another request is taking a long time to complete.
  30. "--workers", "2", "--threads", "4", \
  31. "wsgi:application" \
  32. ]