Compare commits
2 commits
64d1147f29
...
f16f49dde7
Author | SHA1 | Date | |
---|---|---|---|
f16f49dde7 | |||
cc6683cdcc |
8 changed files with 58 additions and 18 deletions
15
Dockerfile
15
Dockerfile
|
@ -1,19 +1,24 @@
|
||||||
FROM fukamachi/qlot
|
FROM fukamachi/qlot
|
||||||
|
|
||||||
|
ARG TW_VERSION=4.1.3
|
||||||
|
ARG TW_BIN=./bin/tailwindcss
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends build-essential curl libev-dev
|
RUN apt-get update && apt-get install -y --no-install-recommends build-essential curl libev-dev
|
||||||
|
|
||||||
RUN mkdir -p ./bin \
|
RUN mkdir -p ./bin \
|
||||||
&& curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 \
|
&& curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/download/v${TW_VERSION}/tailwindcss-linux-x64 \
|
||||||
&& chmod +x tailwindcss-linux-x64 \
|
&& chmod +x tailwindcss-linux-x64 \
|
||||||
&& mv tailwindcss-linux-x64 ./bin/tailwindcss
|
&& mv tailwindcss-linux-x64 ${TW_BIN}
|
||||||
|
|
||||||
RUN ./bin/tailwindcss -i ./static/style/global.css -o ./static/style/dist.css --minify
|
RUN ${TW_BIN} -i ./static/style/global.css -o ./static/style/dist.css --minify
|
||||||
|
|
||||||
RUN qlot install --quiet
|
RUN qlot install --quiet --no-color
|
||||||
|
|
||||||
|
RUN chmod +x entrypoint.sh
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
ENTRYPOINT [".qlot/bin/clackup", "--system", "hp", "--server", "woo", "--address", "0.0.0.0", "--port", "3000", "src/app.lisp"]
|
ENTRYPOINT ["./entrypoint.sh"]
|
||||||
|
|
15
entrypoint.sh
Normal file
15
entrypoint.sh
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ -n "$CLOUDFLARE_ZONE_ID" && -n "$CLOUDFLARE_API_KEY" ]]; then
|
||||||
|
echo "Purging Cloudflare cache..."
|
||||||
|
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer ${CLOUDFLARE_API_KEY}" \
|
||||||
|
-d '{ "hosts": ["skyizwhite.dev"] }'
|
||||||
|
else
|
||||||
|
echo "Cloudflare credentials not provided. Skipping cache purge."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting server..."
|
||||||
|
exec .qlot/bin/clackup --system hp --server woo --address 0.0.0.0 --port 3000 src/app.lisp
|
|
@ -13,17 +13,28 @@
|
||||||
#:~layout))
|
#:~layout))
|
||||||
(in-package #:hp/renderer)
|
(in-package #:hp/renderer)
|
||||||
|
|
||||||
|
(defun set-cache-control (strategy)
|
||||||
|
(set-response-header :cache-control
|
||||||
|
(if (string= (hp-env) "dev")
|
||||||
|
"private, no-store"
|
||||||
|
(cond
|
||||||
|
((eq strategy :static)
|
||||||
|
"public, max-age=31536000, immutable")
|
||||||
|
((eq strategy :dynamic)
|
||||||
|
"public, max-age=60 stale-while-revalidate=86400, stale-if-error=86400")
|
||||||
|
(t
|
||||||
|
"private, no-store")))))
|
||||||
|
|
||||||
(defmethod jingle:process-response ((app jingle:app) result)
|
(defmethod jingle:process-response ((app jingle:app) result)
|
||||||
(set-response-header :content-type "text/html; charset=utf-8")
|
(set-response-header :content-type "text/html; charset=utf-8")
|
||||||
(set-response-header :cache-control (if (string= (hp-env) "dev")
|
|
||||||
"private, no-store"
|
|
||||||
"public, max-age=60 s-maxage=300, stale-while-revalidate=86400, stale-if-error=86400"))
|
|
||||||
(call-next-method app
|
(call-next-method app
|
||||||
(hsx:render-to-string
|
(hsx:render-to-string
|
||||||
(match result
|
(match result
|
||||||
((guard (or (list page metadata)
|
((plist :body body
|
||||||
page)
|
:metadata metadata
|
||||||
(typep page 'element))
|
:cache cache)
|
||||||
(~layout :metadata metadata
|
(progn
|
||||||
page))
|
(set-cache-control cache)
|
||||||
|
(~layout :metadata metadata
|
||||||
|
body)))
|
||||||
(_ (error "Invalid response form"))))))
|
(_ (error "Invalid response form"))))))
|
||||||
|
|
|
@ -15,4 +15,6 @@
|
||||||
|
|
||||||
(defun handle-get (params)
|
(defun handle-get (params)
|
||||||
(declare (ignore params))
|
(declare (ignore params))
|
||||||
(list (~page) *metadata*))
|
(list :body (~page)
|
||||||
|
:metadata *metadata*
|
||||||
|
:cache :dynamic))
|
||||||
|
|
|
@ -15,4 +15,6 @@
|
||||||
|
|
||||||
(defun handle-get (params)
|
(defun handle-get (params)
|
||||||
(declare (ignore params))
|
(declare (ignore params))
|
||||||
(list (~page) *metadata*))
|
(list :body (~page)
|
||||||
|
:metadata *metadata*
|
||||||
|
:cache :dynamic))
|
||||||
|
|
|
@ -28,4 +28,5 @@
|
||||||
|
|
||||||
(defun handle-get (params)
|
(defun handle-get (params)
|
||||||
(declare (ignore params))
|
(declare (ignore params))
|
||||||
(~page))
|
(list :body (~page)
|
||||||
|
:cache :static))
|
||||||
|
|
|
@ -18,4 +18,6 @@
|
||||||
"Back to TOP"))))
|
"Back to TOP"))))
|
||||||
|
|
||||||
(defun handle-not-found ()
|
(defun handle-not-found ()
|
||||||
(list (~page) *metadata*))
|
(list :body (~page)
|
||||||
|
:metadata *metadata*
|
||||||
|
:cache :dynamic))
|
||||||
|
|
|
@ -15,4 +15,6 @@
|
||||||
|
|
||||||
(defun handle-get (params)
|
(defun handle-get (params)
|
||||||
(declare (ignore params))
|
(declare (ignore params))
|
||||||
(list (~page) *metadata*))
|
(list :body (~page)
|
||||||
|
:metadata *metadata*
|
||||||
|
:cache :dynamic))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue