Fix Dockerfile

This commit is contained in:
Akira Tempaku 2025-03-29 01:07:45 +09:00
parent c8ab7e1349
commit cb50ff863b
Signed by: paku
GPG key ID: 5B4E8402BCC50607
11 changed files with 72 additions and 93 deletions

View file

@ -1,25 +1,19 @@
FROM fukamachi/qlot
# 作業ディレクトリ
WORKDIR /app
# ソース全体をコピー
COPY . /app
# Tailwind CLI をダウンロード&インストール
RUN apt-get update && apt-get install -y --no-install-recommends build-essential curl libev-dev
RUN mkdir -p ./bin \
&& curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 \
&& chmod +x tailwindcss-linux-x64 \
&& mv tailwindcss-linux-x64 ./bin/tailwindcss
# Tailwind CSS をビルドglobal.css -> dist.css
RUN ./bin/tailwindcss -i ./public/style/global.css -o ./public/style/dist.css --minify
# Qlot依存関係のインストール
RUN qlot install
RUN qlot install --quiet
# ポート開放
EXPOSE 3000
# アプリ起動
CMD [".qlot/bin/clackup", "--system", "hp", "--server", "woo", "--port", "3000", "src/app.lisp"]
ENTRYPOINT [".qlot/bin/clackup", "--system", "hp", "--server", "woo", "--address", "0.0.0.0", "--port", "3000", "src/app.lisp"]

View file

@ -1,6 +1,4 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@import "tailwindcss";
:root {
font-family: 'Noto Sans JP Variable', sans-serif;

8
qlfile
View file

@ -1,11 +1,11 @@
ql fiveam
ql cl-jingle
git hsx https://github.com/skyizwhite/hsx.git
git ningle-fbr https://github.com/skyizwhite/ningle-fbr.git
git lack-mw https://github.com/skyizwhite/lack-mw.git
ql cl-ppcre
ql trivial-backtrace
ql trivia
ql cl-str
ql quri
ql clack
git hsx https://github.com/skyizwhite/hsx.git
git ningle-fbr https://github.com/skyizwhite/ningle-fbr.git
git lack-mw https://github.com/skyizwhite/lack-mw.git
git trivial-backtrace https://github.com/hraban/trivial-backtrace.git

View file

@ -10,26 +10,10 @@
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
:version "ql-2023-10-21"))
("hsx" .
(:class qlot/source/git:source-git
:initargs (:remote-url "https://github.com/skyizwhite/hsx.git")
:version "git-4ff1c97e3ff727aa332995f5be4dcfb138a45d5f"))
("ningle-fbr" .
(:class qlot/source/git:source-git
:initargs (:remote-url "https://github.com/skyizwhite/ningle-fbr.git")
:version "git-bc87e5de01959cd99364bc14ad3eaf88e52e4478"))
("lack-mw" .
(:class qlot/source/git:source-git
:initargs (:remote-url "https://github.com/skyizwhite/lack-mw.git")
:version "git-77a0f436635e5beadaba3765492832704a015a3c"))
("cl-ppcre" .
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
:version "ql-2024-10-12"))
("trivial-backtrace" .
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
:version "ql-2023-02-14"))
("trivia" .
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
@ -46,3 +30,19 @@
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
:version "ql-2024-10-12"))
("hsx" .
(:class qlot/source/git:source-git
:initargs (:remote-url "https://github.com/skyizwhite/hsx.git")
:version "git-4ff1c97e3ff727aa332995f5be4dcfb138a45d5f"))
("ningle-fbr" .
(:class qlot/source/git:source-git
:initargs (:remote-url "https://github.com/skyizwhite/ningle-fbr.git")
:version "git-bc87e5de01959cd99364bc14ad3eaf88e52e4478"))
("lack-mw" .
(:class qlot/source/git:source-git
:initargs (:remote-url "https://github.com/skyizwhite/lack-mw.git")
:version "git-77a0f436635e5beadaba3765492832704a015a3c"))
("trivial-backtrace" .
(:class qlot/source/git:source-git
:initargs (:remote-url "https://github.com/hraban/trivial-backtrace.git")
:version "git-7f90b4a4144775cca0728791e4b92ac2557b07a1"))

View file

@ -1,8 +1,11 @@
(defpackage #:hp/app
(:use #:cl)
(:local-nicknames (#:jg #:jingle))
(:local-nicknames (#:fbr #:ningle-fbr))
(:local-nicknames (#:env #:hp/env))
(:import-from #:jingle
#:make-app
#:install-middleware
#:configure)
(:import-from #:ningle-fbr
#:set-routes)
(:import-from #:hp/middlewares/recoverer
#:*recoverer*)
(:import-from #:hp/middlewares/trailing-slash
@ -13,12 +16,12 @@
(:export #:*app*))
(in-package #:hp/app)
(defparameter *app* (jg:make-app :address env:*address*
:port env:*port*))
(defparameter *app*
(let ((app (make-app)))
(set-routes app :system :hp :target-dir-path "routes")
(install-middleware app *recoverer*)
(install-middleware app *trim-trailing-slash*)
(install-middleware app *public-server*)
(configure app)))
(fbr:set-routes *app* :system :hp :target-dir-path "routes")
(jg:install-middleware *app* *recoverer*)
(jg:install-middleware *app* *trim-trailing-slash*)
(jg:install-middleware *app* *public-server*)
(jg:configure *app*)
*app*

View file

@ -1,25 +0,0 @@
(defpackage #:hp/env
(:use #:cl)
(:export #:dev-mode-p
#:prod-mode-p
#:*port*
#:*address*))
(in-package #:hp/env)
(defmacro defenv (name env &key default parser)
(let ((env-val (gensym "env-val")))
`(defparameter ,name
(let ((,env-val (uiop:getenv ,env)))
(if ,env-val
(funcall ,(or parser '#'identity) ,env-val)
,default)))))
(defenv *env* "HP_ENV" :default "dev")
(defenv *address* "HP_ADDRESS" :default "localhost")
(defenv *port* "HP_PORT" :default 3000 :parser #'parse-integer)
(defun dev-mode-p ()
(string= *env* "dev"))
(defun prod-mode-p ()
(string= *env* "prod"))

View file

@ -1,8 +1,7 @@
(defpackage #:hp
(:nicknames #:hp/main)
(:use #:cl)
(:local-nicknames (#:jg #:jingle))
(:local-nicknames (#:env #:hp/env))
(:import-from #:clack)
(:import-from #:hp/app
#:*app*)
(:export #:start
@ -10,11 +9,22 @@
#:reload))
(in-package #:hp)
(defparameter *handler* nil)
(defun start ()
(jg:start *app*))
(if *handler*
(format t "The server is already running.~%")
(setf *handler* (clack:clackup *app*
:server :hunchentoot
:address "localhost"
:port 3000))))
(defun stop ()
(jg:stop *app*))
(if *handler*
(progn
(clack:stop *handler*)
(setf *handler* nil))
(format t "The server is not running.~%")))
(defun reload ()
(stop)

View file

@ -1,8 +1,8 @@
(defpackage #:hp/middlewares/recoverer
(:use #:cl
#:hsx)
(:local-nicknames (#:tb #:trivial-backtrace))
(:local-nicknames (#:env #:hp/env))
(:import-from #:trivial-backtrace
#:print-backtrace)
(:export #:*recoverer*))
(in-package #:hp/middlewares/recoverer)
@ -14,10 +14,10 @@
(body
(main
(h1 "500 Internal Server Error")
(when (env:dev-mode-p)
(when (string= (uiop:getenv "HP_ENV") "dev")
(hsx
(pre
(code (tb:print-backtrace condition :output nil))))))))))
(code (print-backtrace condition :output nil))))))))))
(defparameter *recoverer*
(lambda (app)

View file

@ -1,6 +1,6 @@
(defpackage #:hp/middlewares/trailing-slash
(:use #:cl)
(:local-nicknames (#:qu #:quri))
(:import-from :quri)
(:export #:*trim-trailing-slash*))
(in-package #:hp/middlewares/trailing-slash)
@ -10,8 +10,8 @@
(defparameter *trim-trailing-slash*
(lambda (app)
(lambda (env)
(let* ((req-uri (qu:uri (getf env :request-uri)))
(req-path (qu:uri-path req-uri))
(let* ((req-uri (quri:uri (getf env :request-uri)))
(req-path (quri:uri-path req-uri))
(req-method (getf env :request-method))
(response (funcall app env))
(res-status (first response)))
@ -19,7 +19,7 @@
(eq req-method :get)
(not (string= req-path "/"))
(string= (last-string req-path) "/"))
(let ((red-uri (qu:copy-uri req-uri
(let ((red-uri (quri:copy-uri req-uri
:path (string-right-trim "/" req-path))))
`(301 (:location ,(qu:render-uri red-uri))))
`(301 (:location ,(quri:render-uri red-uri))))
response)))))

View file

@ -2,10 +2,9 @@
(:use #:cl
#:hsx
#:trivia)
(:local-nicknames (#:jg #:jingle))
(:import-from :jingle)
(:import-from #:hsx/element
#:element)
(:local-nicknames (#:env #:hp/env)))
#:element))
(in-package #:hp/renderer)
(defun bust-cache (url)
@ -70,12 +69,12 @@
(main :class "flex-1 h-full"
children)))))
(defmethod jg:process-response ((app jg:app) result)
(jg:set-response-header :content-type "text/html; charset=utf-8")
(when (env:dev-mode-p)
(jg:set-response-header :cache-control "no-store, no-cache, must-revalidate")
(jg:set-response-header :pragma "no-cache")
(jg:set-response-header :expires "0"))
(defmethod jingle:process-response ((app jingle:app) result)
(jingle:set-response-header :content-type "text/html; charset=utf-8")
(when (string= (uiop:getenv "HP_ENV") "dev")
(jingle:set-response-header :cache-control "no-store, no-cache, must-revalidate")
(jingle:set-response-header :pragma "no-cache")
(jingle:set-response-header :expires "0"))
(call-next-method app
(hsx:render-to-string
(match result

View file

@ -1,7 +1,7 @@
(defpackage #:hp/routes/not-found
(:use #:cl
#:hsx)
(:local-nicknames (#:jg #:jingle))
(:import-from :jingle)
(:export #:handle-not-found))
(in-package #:hp/routes/not-found)
@ -15,5 +15,5 @@
(h1 "404 Not Found"))))
(defun handle-not-found ()
(jg:set-response-status :not-found)
(jingle:set-response-status :not-found)
(list (~page) *metadata*))