From 400d9e6eb0e8508efbb4c870a79c0008d15f2200 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 31 Mar 2024 15:41:57 -0600 Subject: [PATCH] update docker build with version, add changelog --- CHANGELOG.md | 18 ++++++++++++++++++ Dockerfile | 10 ++++++---- README.md | 4 ++++ app.py | 5 +++-- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..38fcb17 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,18 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [0.2.0] - 2024-03-31 +### Added +- Different times for users to receive notifications +- Ping endpoint +### Changed +- Notification loop runs every 5 minutes. + + +## [0.1.0] +- First release with subscriptions and daily notifications. + diff --git a/Dockerfile b/Dockerfile index 4449547..23f38bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,10 @@ # Use an official Python runtime as a parent image -FROM python:3.8-alpine3.18 as builder +FROM python:alpine3.19 as builder RUN apk update && apk upgrade RUN apk add --no-cache --virtual .build-deps build-base git RUN apk add --upgrade --no-cache bash sqlite libffi-dev tzdata -ENV TZ America/New_York ENV PYTHONUNBUFFERED 1 # Set the working directory in the container to /app @@ -25,7 +24,10 @@ RUN pip install --no-cache-dir -r requirements.txt RUN apk del .build-deps # ---- Production Stage ---- -FROM python:3.8-alpine3.18 as production +FROM python:alpine3.19 as production + +ARG PUSH_SERVER_VERSION +ENV PUSH_SERVER_VERSION=${PUSH_SERVER_VERSION} # Create a user to run our application RUN adduser -D myuser -u 1000 @@ -41,5 +43,5 @@ RUN chown -R myuser:myuser /app USER myuser # Start gunicorn with the appropriate options -# Without "2>&1" the gunicorn internal logging shows in 'docker logs' but doesn't go to stdout like our 'printf' commands. +# Without "2>&1" the gunicorn internal logging shows in 'docker logs' but doesn't go to stdout like our 'print' commands. CMD ["sh", "-c", "gunicorn -b 0.0.0.0:3000 --log-level=debug --workers=1 app:app 2>&1"] diff --git a/README.md b/README.md index 7eb0cc1..f03c8f0 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ ## Docker Build & Deploy +- Update CHANGELOG.md + +- Commit & tag with release version + ``` export PUSH_SERVER_VERSION=0.1 diff --git a/app.py b/app.py index 85c1a11..66f6504 100644 --- a/app.py +++ b/app.py @@ -22,8 +22,9 @@ import time CONTACT_EMAIL = "mailto:info@timesafari.app" -app = Flask(__name__) +PUSH_SERVER_VERSION = os.getenv('PUSH_SERVER_VERSION') +app = Flask(__name__) class WebPushService(): @@ -320,7 +321,7 @@ class WebPushService(): - Response: Text with some subscription-run info """ - return f"pong ... with latest subscription run at {self.latest_subscription_run}" + return f"pong ... version {PUSH_SERVER_VERSION} ... with latest subscription run at {self.latest_subscription_run}" # This is an endpoint, routed in __init__ def regenerate_vapid(self) -> Tuple[Response, int, dict[str, str]] | Tuple[Response, int]: