From bd0674fb0e699f4d822151187387902fff53d346 Mon Sep 17 00:00:00 2001 From: Eriks Karls Date: Sun, 1 Sep 2024 11:53:00 +0300 Subject: [PATCH] WIP various updates --- Dockerfile | 8 ++++---- Makefile | 2 +- compose.yml | 8 ++++++++ compose/nginx/default.conf | 12 ++++++------ compose/nginx/install.sh | 2 +- requirements.txt | 19 ++++++++++++------- service/app.py | 1 - 7 files changed, 32 insertions(+), 20 deletions(-) create mode 100644 compose.yml diff --git a/Dockerfile b/Dockerfile index 69dbe3c..1e4cd67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM python:3-alpine as base +FROM python:3-alpine AS base WORKDIR /app # Code from https://github.com/nginxinc/docker-nginx/blob/4bf0763f4977fff7e9648add59e0540088f3ca9f/stable/alpine-slim/Dockerfile -ENV NGINX_VERSION 1.25.3 -ENV PKG_RELEASE 1 +ENV NGINX_VERSION=1.27.1 +ENV PKG_RELEASE=1 COPY compose/nginx/install.sh / RUN /bin/sh /install.sh \ @@ -27,4 +27,4 @@ EXPOSE 80 STOPSIGNAL SIGTERM #CMD ["gunicorn", "-c", "/app/service/gunicorn.py"] -CMD ["uvicorn", "service.app:app", "--host", "0.0.0.0", "--port", "5000", "--proxy-headers", "--no-server-header"] \ No newline at end of file +CMD ["uvicorn", "service.app:app", "--host", "0.0.0.0", "--port", "5000", "--proxy-headers", "--no-server-header"] diff --git a/Makefile b/Makefile index 24cfb41..1469b1d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ docker-build: - docker build --tag=registry.72.lv/flask-namedays:latest --tag=flask-namedays:latest . + docker build --tag=registry.72.lv/flask-namedays:latest --tag=flask-namedays:latest --progress=plain . docker-push: docker-build docker push registry.72.lv/flask-namedays:latest diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..44559a0 --- /dev/null +++ b/compose.yml @@ -0,0 +1,8 @@ +services: + app: + build: + dockerfile: Dockerfile + context: . + image: registry.72.lv/flask-namedays:latest + ports: + - "18080:80" diff --git a/compose/nginx/default.conf b/compose/nginx/default.conf index 19a7880..8d2f77c 100644 --- a/compose/nginx/default.conf +++ b/compose/nginx/default.conf @@ -8,6 +8,11 @@ server { client_max_body_size 32k; + location / { + root /usr/share/nginx/html; + index index.html; + } + location /api { proxy_pass http://localhost:5000; @@ -29,12 +34,7 @@ server { proxy_request_buffering off; } - location / { - root /usr/share/nginx/html; - index index.html; - } - location = /favicon.ico { - alias /usr/share/nginx/html/static/favicon.ico; + alias /usr/share/nginx/s.72.lv/static/favicon.ico; } } diff --git a/compose/nginx/install.sh b/compose/nginx/install.sh index ab7c545..491ad1e 100755 --- a/compose/nginx/install.sh +++ b/compose/nginx/install.sh @@ -16,7 +16,7 @@ else \ echo "key verification failed!"; \ exit 1; \ fi -apk add -X "https://nginx.org/packages/mainline/alpine/v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" --no-cache $nginxPackages +apk add -X "https://nginx.org/packages/ainline/alpine/v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" --no-cache $nginxPackages # remove checksum deps apk del --no-network .checksum-deps # if we have leftovers from building, let's purge them (including extra, unnecessary build deps) diff --git a/requirements.txt b/requirements.txt index 6787c8a..c5b48a5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,12 @@ -FastAPI==0.109.0 -pydantic==2.5.3 -uvicorn==0.27.0.post1 -python-multipart==0.0.6 -icalendar==5.0.11 -Unidecode==1.3.8 -Gunicorn==21.2.0 +FastAPI==0.112.1 # https://github.com/fastapi/fastapi +pydantic==2.8.2 # https://github.com/pydantic/pydantic +uvicorn==0.30.6 # https://github.com/encode/uvicorn +python-multipart==0.0.9 # https://github.com/Kludex/python-multipart +icalendar==5.0.13 # https://github.com/collective/icalendar +Unidecode==1.3.8 # https://github.com/avian2/unidecode + +gunicorn==23.0.0 # https://github.com/benoitc/gunicorn + +# Partial uvicorn[standard] dependencies +httptools==0.6.1 +uvloop==0.20.0 diff --git a/service/app.py b/service/app.py index 3099b1c..cf30579 100644 --- a/service/app.py +++ b/service/app.py @@ -9,7 +9,6 @@ from fastapi import FastAPI, Form, HTTPException, responses from icalendar import Alarm, Calendar, Event from pydantic import BaseModel from unidecode import unidecode -from uvicorn.workers import UvicornWorker def generate_ical_for_mapping(cal: dict[datetime.date, list[str]]) -> BytesIO: