Skip to content

Commit

Permalink
wip org-publish
Browse files Browse the repository at this point in the history
  • Loading branch information
fstamour committed Jan 11, 2024
1 parent d0625ca commit 78881ef
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
ARG LISP=sbcl
ARG LISP_VERSION=2.2.4

FROM clfoundation/${LISP}:${LISP_VERSION} as base

RUN mkdir /breeze
WORKDIR /breeze


FROM base as quicklisp

RUN QUICKLISP_DIST_VERSION=latest QUICKLISP_ADD_TO_INIT_FILE=true /usr/local/bin/install-quicklisp


FROM quicklisp as deps

COPY breeze.asd .
COPY scripts/load-dependencies.lisp scripts/load-dependencies.lisp

RUN sbcl --noinform --non-interactive \
--load scripts/load-dependencies.lisp


FROM scratch as dependencies.core

COPY --from=deps /breeze/dependencies.core /dependencies.core


FROM base as doc

COPY . .
RUN sbcl --core dependencies.core \
--eval "(asdf:load-system '#:breeze/doc)" \
--eval '(breeze.documentation::generate-documentation)'

FROM alpine:3.18.4 as org-publish

RUN mkdir /breeze
WORKDIR /breeze

RUN apk add bash ca-certificates emacs

COPY . .
COPY --from=doc /breeze/public /breeze/public

# RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -yq emacs
RUN emacs -Q --batch --load scripts/org-publish-project.el --kill
RUN ls
RUN ls /breeze/public


FROM scratch as public

COPY --from=org-publish /breeze/public /
35 changes: 35 additions & 0 deletions scripts/load-dependencies.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(cl:in-package #:cl-user)

(require '#:asdf)

#-quicklisp
(let ((quicklisp-init #P"/opt/quicklisp/setup.lisp"))
(when (probe-file quicklisp-init)
(load quicklisp-init)))

(asdf:load-asd
(merge-pathnames "../breeze.asd" *load-truename*))

(flet ((find-all-related-systems (system)
"Given a system, find all systems defined in the same system definition
file (including the one passed as argument)."
(let ((result ())
(asd-pathname (asdf:system-source-file system)))
(asdf:map-systems (lambda (system)
;; TODO Perhaps use asdf:primary-system-name
(when (equal asd-pathname
(asdf:system-source-file system))
(push system result))))
result)))
(let* ((systems (find-all-related-systems "breeze"))
(dependencies (remove-if (lambda (system-name)
(uiop:string-prefix-p "breeze" system-name))
(loop
:for system-name :in systems
:for system = (asdf:find-system system-name)
:for dependecy-list = (asdf:system-depends-on system)
:append (copy-list dependecy-list)))))
(ql:quickload dependencies)
(mapcar #'asdf:register-immutable-system dependencies)))

(uiop:dump-image "dependencies.core")
42 changes: 42 additions & 0 deletions scripts/org-publish-project.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

(message "Installing packages (from ELPA)")

(package-initialize)
(setf package-selected-packages
'(htmlize))
(package-install-selected-packages t)


(message "Publishing...")

(require 'org)
(require 'org-id)
(require 'htmlize)



;; See (describe-variable 'org-publish-project-alist)

(let* ((forcep t) ; "forcep" is for interactive sessions.
(org-id-link-to-org-use-id t)
(default-directory
(expand-file-name
(concat
(file-name-directory (or load-file-name buffer-file-name))
"..")))
(root "docs")
(project-alist
`("breeze"
:base-directory ,root
:publishing-function org-html-publish-to-html
:publishing-directory "./public"

:author "Francis St-Amour"
:creator "Francis St-Amour"

:auto-sitemap t
;; :makeindex t
:with-toc nil
)))
(org-id-update-id-locations (directory-files root t "\\.org$"))
(org-publish project-alist forcep))

0 comments on commit 78881ef

Please sign in to comment.