From f0d935291715742b2e9f71c1b5e1ecbf23d02eff Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Mon, 18 May 2020 18:43:06 +0000
Subject: [PATCH] Replace uwsgi with waitress due to 400 Bad Request issues
---
config.json | 6 +++++-
Dockerfile | 4 ++--
/dev/null | 16 ----------------
requirements.txt | 1 +
run.py | 7 ++++++-
5 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index d31ab7a..98b66ff 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,6 @@
FROM alpine
-RUN apk add uwsgi-python3 python3 py3-pip
+RUN apk add python3 py3-pip
RUN mkdir -p /run/docker/plugins /usr/src/app \
&& chown -R nobody:nobody /run/docker/plugins /usr/src/app
USER nobody
@@ -12,4 +12,4 @@
COPY --chown=nobody:nobody . .
-CMD [ "uwsgi", "--ini", "uwsgi.ini" ]
+CMD [ "./run.py" ]
diff --git a/config.json b/config.json
index f2751c2..683359c 100644
--- a/config.json
+++ b/config.json
@@ -2,9 +2,13 @@
"description": "pyIPAM - IPAM driver in Python",
"documentation": "https://github.com/jacekkow/docker-plugin-pyipam",
"workdir": "/usr/src/app",
- "entrypoint": ["uwsgi", "--ini", "uwsgi.ini"],
+ "entrypoint": ["./run.py"],
"env": [
{
+ "name": "ENVIRONMENT",
+ "value": "production"
+ },
+ {
"name": "HOME",
"value": "/usr/src/app"
}
diff --git a/requirements.txt b/requirements.txt
index ba512e1..7ecff0d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,3 @@
docker-plugin-api
Flask
+waitress
diff --git a/run.py b/run.py
index 7645305..7502587 100755
--- a/run.py
+++ b/run.py
@@ -1,9 +1,11 @@
#!/usr/bin/env python3
import logging
+import os
import docker_plugin_api.Plugin
import flask
+import waitress
app = flask.Flask('pyIPAM')
app.logger.setLevel(logging.DEBUG)
@@ -15,4 +17,7 @@
app.register_blueprint(lib.IpamDriver.app)
if __name__ == '__main__':
- app.run(debug=True)
+ if os.environ.get('ENVIRONMENT', 'dev') == 'dev':
+ app.run(debug=True)
+ else:
+ waitress.serve(app, unix_socket='/run/docker/plugins/pyipam.sock', threads=1)
diff --git a/uwsgi.ini b/uwsgi.ini
deleted file mode 100644
index 54d12ba..0000000
--- a/uwsgi.ini
+++ /dev/null
@@ -1,16 +0,0 @@
-[uwsgi]
-shared-socket = /run/docker/plugins/pyipam.sock
-http-socket = =0
-;uid = 65534
-;gid = 65534
-
-die-on-term = true
-honour-stdin = true
-
-master = true
-processes = 1
-single-interpreter = true
-
-plugins = python3
-module = run
-callable = app
--
Gitblit v1.9.1