diff --git a/docker/Dockerfile b/docker/Dockerfile index 79a5a4d..b29219f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -68,12 +68,14 @@ LABEL distro="tests" LABEL org.opencontainers.image.created="$BUILD_DATE" LABEL org.opencontainers.image.version="$VERSION" -ENV PATH=/app/.venv/bin:/usr/local/bin/:/usr/bin:/bin \ +ENV PATH=/venv/bin:/usr/local/bin/:/usr/bin:/bin \ DJANGO_SETTINGS_MODULE=country_workspace.config.settings \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ - PYTHONPATH=""\ + UV_PROJECT_ENVIRONMENT=/venv \ + VIRTUAL_ENV=/venv \ UWSGI_PROCESSES=4 + WORKDIR /app COPY uv.lock README.md MANIFEST.in pyproject.toml /app/ COPY src /app/src/ @@ -94,8 +96,10 @@ ENV PATH=/app/.venv/bin:/usr/local/bin/:/usr/bin:/bin \ DJANGO_SETTINGS_MODULE=country_workspace.config.settings \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ - PYTHONPATH=""\ + UV_PROJECT_ENVIRONMENT=/venv \ + VIRTUAL_ENV=/venv \ UWSGI_PROCESSES=4 + WORKDIR /app COPY uv.lock README.md MANIFEST.in pyproject.toml /app/ COPY src /app/src/ @@ -114,7 +118,7 @@ ARG BUILD_DATE ARG GIT_SHA ARG BRANCH -ENV PATH=/app/.venv/bin:/usr/local/bin/:/usr/bin:/bin \ +ENV PATH=/venv/bin:/usr/local/bin/:/usr/bin:/bin \ BUILD_DATE=$BUILD_DATE \ GIT_SHA=$GIT_SHA \ VERSION=$VERSION \ @@ -124,6 +128,8 @@ ENV PATH=/app/.venv/bin:/usr/local/bin/:/usr/bin:/bin \ STATIC_URL="/static/" \ PYTHONPATH=""\ PGSSLCERT="/tmp/postgresql.crt" \ + UV_PROJECT_ENVIRONMENT=/venv \ + VIRTUAL_ENV=/venv \ UWSGI_PROCESSES=4 RUN < /RELEASE @@ -135,20 +141,14 @@ EOF WORKDIR /app COPY docker/conf /conf/ COPY docker/bin/* /usr/local/bin/ -COPY LICENSE.md README.md / -COPY src /app/src/ -RUN rm -fr /app/src/ +COPY . /app/ -COPY --chown=hope:unicef --from=production /app/.venv /app/.venv +COPY --chown=hope:unicef --from=production /venv /venv COPY --from=builder /usr/local/bin/uwsgi /usr/local/bin/uv /usr/local/bin/ RUN --mount=type=cache,target=/root/.uv-cache \ - --mount=type=bind,source=uv.lock,target=/app/uv.lock \ - --mount=type=bind,source=pyproject.toml,target=/app/pyproject.toml \ - --mount=type=bind,source=MANIFEST.in,target=/app/MANIFEST.in \ - --mount=type=bind,source=README.md,target=/app/README.md \ - --mount=type=bind,source=./src/country_workspace,target=/app/src/country_workspace \ - uv --cache-dir=/root/.uv-cache pip install --link-mode=copy --no-deps . + uv --cache-dir=/root/.uv-cache pip install --link-mode=copy --no-deps . \ + && rm -fr /app EXPOSE 8000 diff --git a/docker/bin/docker-entrypoint.sh b/docker/bin/docker-entrypoint.sh index dcad279..ef2e66c 100755 --- a/docker/bin/docker-entrypoint.sh +++ b/docker/bin/docker-entrypoint.sh @@ -16,6 +16,7 @@ case "$1" in fi set -- tini -- "$@" set -- uwsgi --http :8000 \ + -H /venv \ --module country_workspace.config.wsgi \ --mimefile=/conf/mime.types \ --uid hope \ @@ -29,16 +30,16 @@ case "$1" in ;; worker) set -- tini -- "$@" - set -- gosu user:app celery -A country_workspace.config.celery worker -E --loglevel=ERROR --concurrency=4 + set -- gosu hope:unicef celery -A country_workspace.config.celery worker --statedb worker-E --loglevel=ERROR --concurrency=4 ;; beat) set -- tini -- "$@" - set -- gosu user:app celery -A country_workspace.config.celery beat --loglevel=ERROR --scheduler django_celery_beat.schedulers:DatabaseScheduler + set -- gosu hope:unicef celery -A country_workspace.config.celery beat --loglevel=ERROR --scheduler django_celery_beat.schedulers:DatabaseScheduler ;; flower) export DATABASE_URL="sqlite://:memory:" set -- tini -- "$@" - set -- gosu user:app celery -A country_workspace.config.celery flower + set -- gosu hope:unicef celery -A country_workspace.config.celery flower ;; esac diff --git a/docker/conf/uwsgi.ini b/docker/conf/uwsgi.ini deleted file mode 100644 index ac6d9c9..0000000 --- a/docker/conf/uwsgi.ini +++ /dev/null @@ -1,28 +0,0 @@ -[uwsgi] -http-socket = 0.0.0.0:8000 -;enable-threads=0 -;honour-range=1 -;master=1 -module = country_workspace.config.wsgi -processes = 4 -master = 1 -buffer-size = 8192 -http-buffer-size = 8192 - -processes=$(UWSGI_PROCESSES) -;virtualenv=/app/.venv/ -;pythonpath=/app/.venv/lib/python3.12/site-packages -;virtualenv=%(_) -;venv=%(_) -chdir=app/ -uid = hope -gid = unicef -;username = user -;gropuname = app -;offload-threads=%k -;static-gzip-all=true -;route = /static/(.*) static:$(STATIC_ROOT)/$1 -;http-keepalive = 1 -;collect-header=Content-Type RESPONSE_CONTENT_TYPE -mimefile=/conf/mime.types -;honour-stdin = true diff --git a/pyproject.toml b/pyproject.toml index 316bf4b..12cb31d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,10 +65,6 @@ docs = [ "mkdocs-gen-files>=0.5.0", ] -distribution = [ - "uwsgi>=2.0.27", -] - [tool.uv] package = true dev-dependencies = [ diff --git a/uv.lock b/uv.lock index 9139a25..bbd0c30 100644 --- a/uv.lock +++ b/uv.lock @@ -392,7 +392,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/98/65/13d9e76ca19b0ba5603d71ac8424b5694415b348e719db277b5edc985ff5/cryptography-44.0.0-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:761817a3377ef15ac23cd7834715081791d4ec77f9297ee694ca1ee9c2c7e5eb", size = 3915420 }, { url = "https://files.pythonhosted.org/packages/b1/07/40fe09ce96b91fc9276a9ad272832ead0fddedcba87f1190372af8e3039c/cryptography-44.0.0-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:3c672a53c0fb4725a29c303be906d3c1fa99c32f58abe008a82705f9ee96f40b", size = 4154498 }, { url = "https://files.pythonhosted.org/packages/75/ea/af65619c800ec0a7e4034207aec543acdf248d9bffba0533342d1bd435e1/cryptography-44.0.0-cp37-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:4ac4c9f37eba52cb6fbeaf5b59c152ea976726b865bd4cf87883a7e7006cc543", size = 3932569 }, - { url = "https://files.pythonhosted.org/packages/4e/d5/9cc182bf24c86f542129565976c21301d4ac397e74bf5a16e48241aab8a6/cryptography-44.0.0-cp37-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:60eb32934076fa07e4316b7b2742fa52cbb190b42c2df2863dbc4230a0a9b385", size = 4164756 }, { url = "https://files.pythonhosted.org/packages/c7/af/d1deb0c04d59612e3d5e54203159e284d3e7a6921e565bb0eeb6269bdd8a/cryptography-44.0.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:ed3534eb1090483c96178fcb0f8893719d96d5274dfde98aa6add34614e97c8e", size = 4016721 }, { url = "https://files.pythonhosted.org/packages/bd/69/7ca326c55698d0688db867795134bdfac87136b80ef373aaa42b225d6dd5/cryptography-44.0.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:f3f6fdfa89ee2d9d496e2c087cebef9d4fcbb0ad63c40e821b39f74bf48d9c5e", size = 4240915 }, { url = "https://files.pythonhosted.org/packages/ef/d4/cae11bf68c0f981e0413906c6dd03ae7fa864347ed5fac40021df1ef467c/cryptography-44.0.0-cp37-abi3-win32.whl", hash = "sha256:eb33480f1bad5b78233b0ad3e1b0be21e8ef1da745d8d2aecbb20671658b9053", size = 2757925 }, @@ -403,7 +402,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d0/c7/c656eb08fd22255d21bc3129625ed9cd5ee305f33752ef2278711b3fa98b/cryptography-44.0.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:c5eb858beed7835e5ad1faba59e865109f3e52b3783b9ac21e7e47dc5554e289", size = 3915417 }, { url = "https://files.pythonhosted.org/packages/ef/82/72403624f197af0db6bac4e58153bc9ac0e6020e57234115db9596eee85d/cryptography-44.0.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f53c2c87e0fb4b0c00fa9571082a057e37690a8f12233306161c8f4b819960b7", size = 4155160 }, { url = "https://files.pythonhosted.org/packages/a2/cd/2f3c440913d4329ade49b146d74f2e9766422e1732613f57097fea61f344/cryptography-44.0.0-cp39-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:9e6fc8a08e116fb7c7dd1f040074c9d7b51d74a8ea40d4df2fc7aa08b76b9e6c", size = 3932331 }, - { url = "https://files.pythonhosted.org/packages/31/d9/90409720277f88eb3ab72f9a32bfa54acdd97e94225df699e7713e850bd4/cryptography-44.0.0-cp39-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:9abcc2e083cbe8dde89124a47e5e53ec38751f0d7dfd36801008f316a127d7ba", size = 4165207 }, { url = "https://files.pythonhosted.org/packages/7f/df/8be88797f0a1cca6e255189a57bb49237402b1880d6e8721690c5603ac23/cryptography-44.0.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:d2436114e46b36d00f8b72ff57e598978b37399d2786fd39793c36c6d5cb1c64", size = 4017372 }, { url = "https://files.pythonhosted.org/packages/af/36/5ccc376f025a834e72b8e52e18746b927f34e4520487098e283a719c205e/cryptography-44.0.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:a01956ddfa0a6790d594f5b34fc1bfa6098aca434696a03cfdbe469b8ed79285", size = 4239657 }, { url = "https://files.pythonhosted.org/packages/46/b0/f4f7d0d0bcfbc8dd6296c1449be326d04217c57afb8b2594f017eed95533/cryptography-44.0.0-cp39-abi3-win32.whl", hash = "sha256:eca27345e1214d1b9f9490d200f9db5a874479be914199194e746c893788d417", size = 2758672 }, @@ -1168,9 +1166,6 @@ dependencies = [ ] [package.optional-dependencies] -distribution = [ - { name = "uwsgi" }, -] docs = [ { name = "mkdocs" }, { name = "mkdocs-awesome-pages-plugin" }, @@ -1261,7 +1256,6 @@ requires-dist = [ { name = "sentry-sdk", specifier = ">=2.7.1" }, { name = "social-auth-app-django" }, { name = "unicef-security", specifier = ">=1.5.1" }, - { name = "uwsgi", marker = "extra == 'distribution'", specifier = ">=2.0.27" }, ] [package.metadata.requires-dev] @@ -3035,12 +3029,6 @@ socks = [ { name = "pysocks", marker = "platform_python_implementation != 'PyPy'" }, ] -[[package]] -name = "uwsgi" -version = "2.0.28" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/24/c2/d58480aadc9a1f420dd96fc43cf0dcd8cb5ededb95cab53743529c23b6cd/uwsgi-2.0.28.tar.gz", hash = "sha256:79ca1891ef2df14508ab0471ee8c0eb94bd2d51d03f32f90c4bbe557ab1e99d0", size = 816212 } - [[package]] name = "vcrpy" version = "6.0.2"