python3.8-alpine.dockerfile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. FROM python:3.8-alpine3.11
  2. LABEL maintainer="Sebastian Ramirez <[email protected]>"
  3. COPY install-nginx-alpine.sh /
  4. RUN sh /install-nginx-alpine.sh
  5. EXPOSE 80
  6. # # Expose 443, in case of LTS / HTTPS
  7. EXPOSE 443
  8. # Install uWSGI
  9. RUN apk add --no-cache uwsgi-python3
  10. # Copy the base uWSGI ini file to enable default dynamic uwsgi process number
  11. COPY uwsgi.ini /etc/uwsgi/
  12. # Install Supervisord
  13. RUN apk add --no-cache supervisor
  14. # Custom Supervisord config
  15. COPY supervisord-alpine.ini /etc/supervisor.d/supervisord.ini
  16. # uWSGI Python plugin
  17. # As an env var to re-use the config file
  18. ENV UWSGI_PLUGIN python3
  19. # Which uWSGI .ini file should be used, to make it customizable
  20. ENV UWSGI_INI /app/uwsgi.ini
  21. # By default, run 2 processes
  22. ENV UWSGI_CHEAPER 2
  23. # By default, when on demand, run up to 16 processes
  24. ENV UWSGI_PROCESSES 16
  25. # By default, allow unlimited file sizes, modify it to limit the file sizes
  26. # To have a maximum of 1 MB (Nginx's default) change the line to:
  27. # ENV NGINX_MAX_UPLOAD 1m
  28. ENV NGINX_MAX_UPLOAD 0
  29. # By default, Nginx will run a single worker process, setting it to auto
  30. # will create a worker for each CPU core
  31. ENV NGINX_WORKER_PROCESSES 1
  32. # By default, Nginx listens on port 80.
  33. # To modify this, change LISTEN_PORT environment variable.
  34. # (in a Dockerfile or with an option for `docker run`)
  35. ENV LISTEN_PORT 80
  36. # Used by the entrypoint to explicitly add installed Python packages
  37. # and uWSGI Python packages to PYTHONPATH otherwise uWSGI can't import Flask
  38. ENV ALPINEPYTHON python3.8
  39. # Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app
  40. COPY start.sh /start.sh
  41. RUN chmod +x /start.sh
  42. # Copy the entrypoint that will generate Nginx additional configs
  43. COPY entrypoint.sh /entrypoint.sh
  44. RUN chmod +x /entrypoint.sh
  45. ENTRYPOINT ["sh", "/entrypoint.sh"]
  46. # Add demo app
  47. COPY ./app /app
  48. WORKDIR /app
  49. # Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations)
  50. # And then will start Supervisor, which in turn will start Nginx and uWSGI
  51. CMD ["/start.sh"]