From 9d5115e52c4c42af8249d8eb6f0ad3b8030f7c8d Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 28 May 2018 20:53:00 +0200 Subject: Add Dockerfile. The Dockerfile uses deploy (https://shinmera.github.io/deploy/) to create a self-contained binary and packages it as a Docker image. --- .dockerignore | 5 +++++ Dockerfile | 43 +++++++++++++++++++++++++++++++++++++++++++ mulkcms-ht.asd | 9 +++++++++ mulkcms-hunchentoot.lisp | 9 ++++++++- package-hunchentoot.lisp | 2 +- 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 mulkcms-ht.asd diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..93462d9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.* +Dockerfile +ChangeLog +COPYING* +bin diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..159f748 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +############### +### STAGE 0 ### +############### + +FROM mcreations/sbcl:1.4.1 + +RUN sbcl --eval "\ + (progn \ + (ql:quickload \"deploy\")) \ + " + +COPY . /opt/quicklisp/local-projects/mulkcms + +RUN sbcl --eval "\ + (progn \ + (ql:quickload \"mulkcms-ht\")) \ + " + +USER root +RUN mkdir -p /opt/quicklisp/local-projects/mulkcms/bin +RUN chown lisp /opt/quicklisp/local-projects/mulkcms/bin + +RUN sbcl --eval "\ + (progn \ + (asdf:make \"mulkcms-ht\")) \ + " + + +############### +### STAGE 1 ### +############### + +FROM debian:9-slim + +RUN apt-get update && apt-get install -y libssl1.0 && rm -rf /var/lib/apt/lists/* && apt-get clean + + +COPY --from=0 /opt/quicklisp/local-projects/mulkcms/bin /mulkcms/bin +COPY static-files /mulkcms/static-files +COPY templates /mulkcms/templates + +WORKDIR /mulkcms +ENTRYPOINT ["/mulkcms/bin/mulkcms-ht"] diff --git a/mulkcms-ht.asd b/mulkcms-ht.asd new file mode 100644 index 0000000..b02278a --- /dev/null +++ b/mulkcms-ht.asd @@ -0,0 +1,9 @@ +(asdf:defsystem mulkcms-ht + :version "0.0.1" + :depends-on (:mulkcms-hunchentoot) + :components () + + :defsystem-depends-on (:deploy) + :build-operation "deploy-op" + :build-pathname "mulkcms-ht" + :entry-point "mulkcms-hunchentoot:run-server") diff --git a/mulkcms-hunchentoot.lisp b/mulkcms-hunchentoot.lisp index 4300871..4d7f3c1 100644 --- a/mulkcms-hunchentoot.lisp +++ b/mulkcms-hunchentoot.lisp @@ -75,5 +75,12 @@ :port *server-port* :address *server-address*)) (setq mulkcms::*authorization-page-handler* #'handle-authorization-page) - (hunchentoot:start *acceptor*)) + (hunchentoot:start *acceptor*) + *acceptor*) +(defun run-server () + (let ((acceptor (start-server))) + (unwind-protect + (loop + (sleep 86400)) + (stop acceptor :soft t)))) diff --git a/package-hunchentoot.lisp b/package-hunchentoot.lisp index 955c25a..4843e0c 100644 --- a/package-hunchentoot.lisp +++ b/package-hunchentoot.lisp @@ -3,4 +3,4 @@ #:mulkcms) (:nicknames #:mulkcms-ht) (:shadow #:copy-file #:copy-stream) - (:export #:start-server)) + (:export #:start-server #:run-server)) -- cgit v1.2.3