From 27ab7903cf8d256605ff38ab787d066865b2e25e Mon Sep 17 00:00:00 2001 From: Sangelo Date: Thu, 16 May 2024 09:36:48 +0200 Subject: [PATCH] [c+a] fix #3 and make external caddyfile --- Caddyfile | 26 ++++++++++++++++++++++++++ Dockerfile | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Caddyfile diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..b2477bf --- /dev/null +++ b/Caddyfile @@ -0,0 +1,26 @@ +:80 { + root * /app + try_files {path}.html {path} + file_server + handle_errors { + # handle 4xx errors + @4xx expression `{err.status_code} >= 400 && {err.status_code} < 500` + handle @4xx { + rewrite * /internal/error/400.html + templates + file_server + } + + # handle 5xx errors + @5xx expression `{err.status_code} >= 500 && {err.status_code} < 600` + handle @5xx { + rewrite * /internal/error/500.html + templates + file_server + } + } +} + +:8080 { + respond /health "OK" 200 +} diff --git a/Dockerfile b/Dockerfile index 2a7d32b..92e148e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,8 @@ COPY --from=builder /git/build /app RUN addgroup -S web && adduser -S web -G web && chown -R web:web /app # Caddyfile configuration to serve files from /app -RUN echo -e ":80 {\n root * /app\n try_files {path}.html {path}\n file_server\n}\n:8080 {\n respond /health \"OK\" 200\n}" > /etc/caddy/Caddyfile +COPY --from=builder /git/Caddyfile /etc/caddy/Caddyfile +#RUN echo -e ":80 {\n root * /app\n try_files {path}.html {path}\n file_server\n}\n:8080 {\n respond /health \"OK\" 200\n}" > /etc/caddy/Caddyfile # Expose port 80 EXPOSE 80