Skip to content

Commit

Permalink
Move application to Docker image
Browse files Browse the repository at this point in the history
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
  • Loading branch information
placek committed Apr 22, 2024
1 parent afd2000 commit 5311229
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.html
*.pdf
*.zip
*.SQLite3
*.db
.git/
.github/
README.md
shell.nix
LICENSE
Dockerfile
5 changes: 1 addition & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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 "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><link rel=\"stylesheet\" href=\"style.css\"></head><body><h1>pocket-nt</h1><info>"; \
{ echo "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><link rel=\"stylesheet\" href=\"$(style)\"></head><body><h1>pocket-nt</h1><info>"; \
cat "info-$(left).html" "info-$(right).html"; \
echo "</info>"; \
sqlite3 < chapters.sql | sed -rf render.sed; \
sqlite3 < $(chapters) | sed -rf $(render); \
echo "</body></html>"; \
} > "$@"

Expand All @@ -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="$@" "$<"
Expand Down

0 comments on commit 5311229

Please sign in to comment.