From ef0af5a2f1ed71fa78c132548c9efe88419fe717 Mon Sep 17 00:00:00 2001 From: hay-kot Date: Thu, 11 Feb 2021 18:42:20 -0900 Subject: [PATCH] test caddy web server --- Caddyfile | 21 +++++++++++++++++++++ Dockerfile | 8 +++++--- mealie/app.py | 3 ++- mealie/run.sh | 8 ++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 Caddyfile create mode 100644 mealie/run.sh diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 000000000..a24ecb85f --- /dev/null +++ b/Caddyfile @@ -0,0 +1,21 @@ +{ + auto_https off +} + +:80 { + @proxied path /api/* /docs /openapi.json + + root * /app/dist + encode gzip + uri strip_suffix / + + handle @proxied { + reverse_proxy http://127.0.0.1:9000 + } + + handle { + try_files {path}.html {path} / + file_server + } + +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ad18c37d4..cdcac7663 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN npm run build FROM python:3.9-alpine -RUN apk add --no-cache libxml2-dev libxslt-dev libxml2 +RUN apk add --no-cache libxml2-dev libxslt-dev libxml2 caddy ENV ENV prod EXPOSE 80 WORKDIR /app @@ -30,9 +30,11 @@ RUN apk add --update --no-cache --virtual .build-deps \ COPY ./mealie /app +COPY ./Caddyfile /app COPY --from=build-stage /app/dist /app/dist RUN rm -rf /app/test /app/.temp - +RUN chmod +x run.sh VOLUME [ "/app/data/" ] -CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "80"] +ENTRYPOINT ["/app/run.sh"] +# CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "80"] diff --git a/mealie/app.py b/mealie/app.py index 10efcb07b..d90fcc6c8 100644 --- a/mealie/app.py +++ b/mealie/app.py @@ -53,7 +53,8 @@ def api_routers(): if PRODUCTION: - mount_static_files() + pass + # mount_static_files() api_routers() diff --git a/mealie/run.sh b/mealie/run.sh new file mode 100644 index 000000000..86af5608d --- /dev/null +++ b/mealie/run.sh @@ -0,0 +1,8 @@ +## Migrations +# TODO + +## Web Server +./caddy run --config ./Caddyfile + +## Start API +uvicorn app:app --host 0.0.0.0 --port 80 \ No newline at end of file