From 5311229f422e374a923a33f7a25ffe1d6cf45610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Placzy=C5=84ski?= Date: Mon, 22 Apr 2024 07:09:25 +0200 Subject: [PATCH] Move application to Docker image This commit moves the application to a Docker image to streamline the deployment process. By utilizing a Docker image, the application can be easily packaged and distributed across different environments, ensuring consistency and ease of deployment. The changes include: - Added .dockerignore file to specify files to be excluded from the Docker build - Modified .github/workflows/release.yml to build the application using Docker - Updated the Dockerfile to include necessary dependencies and instructions for building the application within the Docker image - Adjusted the Makefile to reference files within the Docker image for building the application --- .dockerignore | 11 +++++++++++ .github/workflows/release.yml | 5 +---- Dockerfile | 10 ++++++++-- Makefile | 14 +++++++++----- 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..174fe15 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +*.html +*.pdf +*.zip +*.SQLite3 +*.db +.git/ +.github/ +README.md +shell.nix +LICENSE +Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 22d1bc7..ef63ca3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,13 +9,10 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Install GhostScript - run: sudo apt-get update && sudo apt-get install -y ghostscript - name: Build - run: make + run: docker run -v $(pwd):/data $(docker build -q .) - name: Create release uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') with: draft: true files: '*.pdf' diff --git a/Dockerfile b/Dockerfile index 31244d6..1715af0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,10 @@ FROM alpine:3.19.1 ADD https://www.princexml.com/download/prince-15.3-r0-alpine3.19-x86_64.apk /tmp/prince.apk -RUN apk add --allow-untrusted /tmp/prince.apk && rm /tmp/prince.apk -ENTRYPOINT ["prince"] +RUN apk update && \ + apk add --allow-untrusted /tmp/prince.apk && \ + apk add --no-cache curl ghostscript unzip make sed sqlite && \ + rm /tmp/prince.apk && \ + mkdir /app +COPY . /app +WORKDIR /data +ENTRYPOINT ["make", "-f", "/app/Makefile"] diff --git a/Makefile b/Makefile index 75740ee..638e2df 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ size ?= A6 left ?= BT'03 right ?= NA28 +style ?= /app/style.css +print ?= /app/print.css +chapters := /app/chapters.sql +render := /app/render.sed all: screen print @@ -10,12 +14,12 @@ screen: $(left)-$(right)_screen.pdf .PHONY: print print: $(left)-$(right)_print.pdf -$(left)-$(right).html: info-$(left).html info-$(right).html chapters.sql render.sed +$(left)-$(right).html: info-$(left).html info-$(right).html mv "$(left).SQLite3" left.db; mv "$(right).SQLite3" right.db; \ - { echo "

pocket-nt

"; \ + { echo "

pocket-nt

"; \ cat "info-$(left).html" "info-$(right).html"; \ echo ""; \ - sqlite3 < chapters.sql | sed -rf render.sed; \ + sqlite3 < $(chapters) | sed -rf $(render); \ echo ""; \ } > "$@" @@ -26,10 +30,10 @@ $(left)-$(right).html: info-$(left).html info-$(right).html chapters.sql render. unzip -j "$<" %_screen.pdf: %.html - docker run --rm -v "`pwd`":/data silquenarmo/princexml:15.3 --verbose --pdf-title="pocket-nt" --no-network --page-size=$(size) --media=screen --output="/data/$@" "/data/$<" + prince --verbose --pdf-title="pocket-nt" --no-network --page-size=$(size) --media=screen --output="/data/$@" "/data/$<" %_print_raw.pdf: %.html - docker run --rm -v "`pwd`":/data silquenarmo/princexml:15.3 --verbose --pdf-title="pocket-nt" --no-network --page-size=$(size) --media=print --style=/data/print.css --output="/data/$@" "/data/$<" + prince --verbose --pdf-title="pocket-nt" --no-network --page-size=$(size) --media=print --style=$(print) --output="/data/$@" "/data/$<" %_print.pdf: %_print_raw.pdf gs -dPDFX -dBATCH -dNOPAUSE -dNOOUTERSAVE -dNoOutputFonts -sDEVICE=pdfwrite -sColorConversionStrategy=CMYK -dProcessColorModel=/DeviceCMYK -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dHaveTransparency=false -sOutputFile="$@" "$<"