diff --git a/Dockerfile b/Dockerfile index f66e265..5f22afe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,14 @@ -FROM java:8 +FROM clojure:openjdk-16-alpine AS builder +RUN mkdir -p /app +WORKDIR /app +COPY project.clj /app +RUN lein deps +COPY . /app +RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar -ADD buchdesmonats-1.7.jar /buchdesmonats/ -WORKDIR /buchdesmonats - -CMD ["java", "-jar", "buchdesmonats-1.7.jar"] +FROM openjdk:16 +RUN mkdir -p /app/public +WORKDIR /app +COPY --from=builder /app/app-standalone.jar /app/bdm.jar +# Make sure you mount the public folder +CMD java -jar bdm.jar $TYPE diff --git a/README.mkd b/README.mkd index 3fc6eaf..a83b319 100644 --- a/README.mkd +++ b/README.mkd @@ -11,6 +11,21 @@ list. This includes books and comics. $ target/buchdesmonats-1.7-standalone.jar [book|comic] +## Docker + +You can use the Dockerfile to generate the static content. This is useful +for a cronjob. You want to mount the target dir, so it is not lost after +the container stops. The Dockerfile is a multi stage dockerfile, which +first compiles the clojure files into a standalone jar file and then use +it to generate the book of the month content. + + $ docker build . -t bdm:1.7 + +Run this periodically: + + $ docker run -it -v "$PWD/public:/app/public" -e "TYPE=book" bdm:1.7 + $ docker run -it -v "$PWD/public:/app/public" -e "TYPE=comic" bdm:1.7 + ## Authors * Programming: [Aaron Fischer](https://aaron-fischer.net/) diff --git a/src/buchdesmonats/core.clj b/src/buchdesmonats/core.clj index 052d4c7..06cb693 100644 --- a/src/buchdesmonats/core.clj +++ b/src/buchdesmonats/core.clj @@ -81,7 +81,7 @@ (defn -main [& args] (let [type (first args) - datasource-url (str "https://git.okoyono.de/mezzomix/buch_des_monats/raw/master/" (clojure.string/upper-case type) ".mkd") + datasource-url (str "https://git.okoyono.de/mezzo/buch_des_monats/raw/master/" (clojure.string/upper-case type) ".mkd") target-dir (io/file "public" (str type "-covers"))] (fs/mkdirs target-dir) (generate-html type (scrape-book-urls datasource-url) "public")