From 01d3868b80882e7513e2ebbbe7f6904b1702f95b Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 3 Dec 2023 20:10:49 -0700 Subject: [PATCH 1/2] fix endpoint for regenerating VAPID key --- app.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 873bb97..e73a4f1 100644 --- a/app.py +++ b/app.py @@ -35,6 +35,7 @@ class WebPushService(): # Setting the application instance self.app = app + self.app.add_url_rule('/web-push/regenerate_vapid', view_func=self.regenerate_vapid, methods=['POST']) # Setting the database URI for the application db_uri = os.getenv('SQLALCHEMY_DATABASE_URI', 'sqlite:////app/instance/data/webpush.db') @@ -194,9 +195,7 @@ class WebPushService(): time.sleep(24 * 60 * 60) - @staticmethod - @app.route('/web-push/regenerate_vapid', methods=['POST']) - def regenerate_vapid() -> Tuple[str, int]: + def regenerate_vapid(self) -> Tuple[str, int]: """ Endpoint to regenerate VAPID keys. From 8ccefc8b2294fd40954889bad50185bb33ca5677 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 3 Dec 2023 20:11:01 -0700 Subject: [PATCH 2/2] update docker build & instructions for the necessary matching user --- Dockerfile | 2 +- README.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 860be32..4a6e26c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ RUN apk del .build-deps FROM python:3.8-alpine3.18 as production # Create a user to run our application -RUN adduser -D myuser +RUN adduser -D myuser -u 1000 # Copy the dependencies and installed packages from the builder image WORKDIR /app diff --git a/README.md b/README.md index cf8685d..07f0185 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ export PUSH_SERVER_VERSION=0.1 # This command is also in build.sh +# Note that there is a user with the uid 1000 inside the Dockerfile: make sure that such a user exists on the server and has write access to the database. docker build --tag py-push-server:amd-$PUSH_SERVER_VERSION --platform linux/amd64 . docker save -o ~/dl/py-push-server-amd-$PUSH_SERVER_VERSION.tar py-push-server:amd-$PUSH_SERVER_VERSION @@ -22,7 +23,7 @@ bzip2 -d py-push-server-amd-$PUSH_SERVER_VERSION.tar.bz2 sudo docker load -i py-push-server-amd-$PUSH_SERVER_VERSION.tar -sudo docker run -d -p 8900:3000 -v ~/py-push-server-db:/srv/py-push-server/data --name py-push-server-$PUSH_SERVER_VERSION py-push-server:amd-$PUSH_SERVER_VERSION +sudo docker run -d -p 8900:3000 -v ~/py-push-server-db:/app/instance/data --name py-push-server-$PUSH_SERVER_VERSION py-push-server:amd-$PUSH_SERVER_VERSION ```