diff --git a/.dockerignore b/.dockerignore index d7e2fffa48..cbfb4765f0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -33,7 +33,7 @@ !plugin-server/.prettierrc !share/GeoLite2-City.mmdb !hogvm/python -!unit.json +!unit.json.tpl !plugin-transpiler/src !plugin-transpiler/*.* !test-runner-jest.config.js diff --git a/bin/docker-server-unit b/bin/docker-server-unit index 55d5961bb6..52d8057271 100755 --- a/bin/docker-server-unit +++ b/bin/docker-server-unit @@ -11,6 +11,9 @@ trap 'rm -rf "$PROMETHEUS_MULTIPROC_DIR"' EXIT export PROMETHEUS_METRICS_EXPORT_PORT=8001 export STATSD_PORT=${STATSD_PORT:-8125} +export NGINX_UNIT_PYTHON_PROTOCOL=${NGINX_UNIT_PYTHON_PROTOCOL:-wsgi} +envsubst < /docker-entrypoint.d/unit.json.tpl > /docker-entrypoint.d/unit.json + # We need to run as --user root so that nginx unit can proxy the control socket for stats # However each application is run as "nobody" diff --git a/production.Dockerfile b/production.Dockerfile index 6d43498a53..0d4c8880a4 100644 --- a/production.Dockerfile +++ b/production.Dockerfile @@ -249,7 +249,8 @@ RUN apt-get update && \ "libpq-dev" \ "libxmlsec1" \ "libxmlsec1-dev" \ - "libxml2" + "libxml2" \ + "gettext-base" # Install NodeJS 18. RUN apt-get install -y --no-install-recommends \ @@ -311,6 +312,6 @@ EXPOSE 8000 # Expose the port from which we serve OpenMetrics data. EXPOSE 8001 -COPY unit.json /docker-entrypoint.d/unit.json +COPY unit.json.tpl /docker-entrypoint.d/unit.json.tpl USER root CMD ["./bin/docker"] diff --git a/unit.json b/unit.json.tpl similarity index 92% rename from unit.json rename to unit.json.tpl index 64f70e34a3..81cf4b145a 100644 --- a/unit.json +++ b/unit.json.tpl @@ -43,8 +43,8 @@ "processes": 4, "working_directory": "/code", "path": ".", - "module": "posthog.wsgi", - "protocol": "wsgi", + "module": "posthog.$NGINX_UNIT_PYTHON_PROTOCOL", + "protocol": "$NGINX_UNIT_PYTHON_PROTOCOL", "user": "nobody", "limits": { "requests": 50000