Skip to content

Commit ea3ed34

Browse files
committed
Make *core* an addon image
The *pandoc-crossref* binaries are downloaded from GitHub instead of compiled.
1 parent 53c04b8 commit ea3ed34

File tree

9 files changed

+132
-56
lines changed

9 files changed

+132
-56
lines changed

alpine/Dockerfile.tmpl

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,24 @@ FROM builder-base AS builder
3636
RUN git clone --branch=${pandoc_commit} --depth=1 --quiet \
3737
https://github.com/jgm/pandoc /app
3838

39-
# Add pandoc-crossref to project
40-
RUN printf "extra-packages: pandoc-crossref\n" > cabal.project.local;
41-
42-
# Build pandoc and pandoc-crossref. The `allow-newer` is required for
43-
# when pandoc-crossref has not been updated yet, but we want to build
44-
# anyway.
39+
# Build the pandoc CLI binary.
4540
RUN cabal build \
4641
--jobs \
4742
--disable-tests \
4843
--disable-bench \
4944
--enable-split-sections \
5045
--enable-executable-stripping \
5146
--upgrade-dependencies \
52-
--allow-newer='pandoc-crossref:pandoc' \
5347
--ghc-options='-O1 -optc-Os -optl=-pthread -fPIC -j' \
5448
--ghc-options='+RTS -M4G -A128m -n2m -RTS' \
5549
$for(cabal.constraints)$
5650
--constraint='${it}' \
5751
$endfor$
58-
. pandoc-cli pandoc-crossref
52+
. pandoc-cli
5953

6054
# Cabal's exec stripping doesn't seem to work reliably, let's do it here.
6155
RUN find dist-newstyle \
62-
-name 'pandoc*' -type f -perm -u+x \
56+
-name 'pandoc' -type f -perm -u+x \
6357
-exec strip '{}' ';' \
6458
-exec cp '{}' /usr/local/bin/ ';'
6559

@@ -93,16 +87,3 @@ RUN ln -s /usr/local/bin/pandoc /usr/local/bin/pandoc-lua && \
9387
lua5.4 && \
9488
# Create user data directory
9589
mkdir -p "$$XDG_DATA_HOME"/pandoc
96-
97-
# Core ##################################################################
98-
FROM minimal AS core
99-
COPY --from=builder \
100-
/usr/local/bin/pandoc-crossref \
101-
/usr/local/bin/
102-
103-
# Additional packages frequently used during conversions
104-
# NOTE: `libsrvg`, pandoc uses `rsvg-convert` for working with svg images.
105-
# FIXME: Alpine 3.17 and later ships the binary in the rsvg-convert package.
106-
# hadolint ignore=DL3018
107-
RUN apk --no-cache add librsvg; \
108-
apk --no-cache add rsvg-convert || true

alpine/core/Dockerfile.tmpl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# ____
2+
# / ___|___ _ __ ___
3+
# | | / _ \| '__/ _ \
4+
# | |__| (_) | | | __/
5+
# \____\___/|_| \___|
6+
#
7+
FROM pandoc/minimal:${pandoc_version}-alpine
8+
9+
# Additional packages frequently used during conversions
10+
# hadolint ignore=DL3018
11+
RUN apk --no-cache add rsvg-convert
12+
13+
# Install pandoc-crossref
14+
RUN <<EOF
15+
set -eux
16+
apk --no-cache add curl
17+
url_base='https://github.com/lierdakil/pandoc-crossref/releases/download';
18+
case "$$(uname -m)" in
19+
('x86_64')
20+
arch="X64"
21+
crossref_hash=${core.pandoc-crossref.hashes.amd64}
22+
;;
23+
('arm64')
24+
arch="ARM64"
25+
crossref_hash=${core.pandoc-crossref.hashes.arm64}
26+
;;
27+
(*)
28+
echo >&2 "error: unsupported architecture '$$(uname -m)'"
29+
exit 1
30+
;;
31+
esac
32+
version="${core.pandoc-crossref.version}"
33+
filename="pandoc-crossref-Linux-$${arch}.tar.xz"
34+
curl --proto '=https' --tlsv1.3 -sSfL -o /tmp/pandoc-crossref.tar.xz \
35+
"$${url_base}/$${version}/pandoc-crossref-linux-$${arch}.tar.xz"
36+
echo "$$crossref_hash /tmp/pandoc-crossref.tar.xz" | sha256sum -c
37+
tar -xf /tmp/pandoc-crossref.tar.xz -C /usr/local/bin pandoc-crossref
38+
# Remove archive
39+
rm /tmp/pandoc-crossref.tar.xz
40+
# Curl is no longer needed
41+
apk del curl
42+
EOF
43+

common/pandoc-freeze.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,6 @@ sourcedir=$PWD/pandoc-cli-${pandoc_cli_version}
121121
printf "Switching directory to %s\n" "${sourcedir}"
122122
cd "${sourcedir}"
123123

124-
# Add pandoc-crossref to the project
125-
if [ -z "${WITHOUT_CROSSREF}" ]; then
126-
printf "Writing cabal.project.local\n"
127-
printf "\nextra-packages: pandoc-crossref\n" > cabal.project.local
128-
fi
129-
130124
# create freeze file with all desired constraints
131125
printf "Creating freeze file...\n"
132126
cabal v2-freeze \

config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ release:
1212
ubuntu: 'noble'
1313
debian: 'bookworm'
1414
addon:
15+
core:
16+
pandoc-crossref: 'v0.3.22b'
1517
latex:
1618
texlive: '2025'
1719
typst:
@@ -35,6 +37,8 @@ release:
3537
ubuntu: 'noble'
3638
debian: 'bookworm'
3739
addon:
40+
core:
41+
pandoc-crossref: 'v0.3.22b'
3842
latex:
3943
texlive: '2025'
4044
typst:
@@ -150,6 +154,12 @@ release:
150154
- 'pandoc-include==1.4.*'
151155

152156
addon:
157+
core:
158+
hashes:
159+
pandoc-crossref:
160+
v0.3.22b:
161+
amd64: a521900745f7c1621b4104119f92dd4a9b4cc527f50157ef544ae1cb8435f9c1
162+
arm64: aaaeae858b73a4150cc91581b07e08fb6e383f476a04fd024bb03ef323b32c3e
153163
latex:
154164
texlive:
155165
current: 2025

debian/Dockerfile.tmpl

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,24 @@ RUN git clone --branch=${pandoc_commit} --depth=1 --quiet \
2323
https://github.com/jgm/pandoc /app
2424
2525
# Install Haskell dependencies
26-
# Add pandoc-crossref to project
27-
RUN printf "extra-packages: pandoc-crossref\n" > cabal.project.local;
28-
29-
# Build pandoc and pandoc-crossref. The `allow-newer` is required for
30-
# when pandoc-crossref has not been updated yet, but we want to build
31-
# anyway.
26+
# Build pandoc CLI binary.
3227
RUN cabal build \
3328
--jobs \
3429
--disable-tests \
3530
--disable-bench \
3631
--enable-split-sections \
3732
--enable-executable-stripping \
3833
--upgrade-dependencies \
39-
--allow-newer='pandoc-crossref:pandoc' \
4034
--ghc-options='-O1 -optc-Os -optl=-pthread -fPIC -j' \
4135
--ghc-options='+RTS -M4G -A128m -n2m -RTS' \
4236
$for(cabal.constraints)$
4337
--constraint='${it}' \
4438
$endfor$
45-
. pandoc-cli pandoc-crossref
39+
. pandoc-cli
4640
4741
# Cabal's exec stripping doesn't seem to work reliably, let's do it here.
4842
RUN find dist-newstyle \
49-
-name 'pandoc*' -type f -perm -u+x \
43+
-name 'pandoc' -type f -perm -u+x \
5044
-exec strip '{}' ';' \
5145
-exec cp '{}' /usr/local/bin/ ';'
5246
@@ -85,17 +79,3 @@ RUN ln -s /usr/local/bin/pandoc /usr/local/bin/pandoc-lua \
8579
&& rm -rf /var/lib/apt/lists/* \
8680
# Create user data directory
8781
&& mkdir -p "$$XDG_DATA_HOME"/pandoc
88-
89-
# Core ##################################################################
90-
FROM minimal AS core
91-
COPY --from=builder \
92-
/usr/local/bin/pandoc-crossref \
93-
/usr/local/bin/
94-
95-
# Additional packages frequently used during conversions
96-
# NOTE: `libsrvg`, pandoc uses `rsvg-convert` for working with svg images.
97-
RUN apt-get -q --no-allow-insecure-repositories update \
98-
&& DEBIAN_FRONTEND=noninteractive \
99-
apt-get install --assume-yes --no-install-recommends \
100-
librsvg2-bin=2.* \
101-
&& rm -rf /var/lib/apt/lists/*

debian/core/Dockerfile.tmpl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# ____
2+
# / ___|___ _ __ ___
3+
# | | / _ \| '__/ _ \
4+
# | |__| (_) | | | __/
5+
# \____\___/|_| \___|
6+
#
7+
FROM pandoc/minimal:${pandoc_version}-debian
8+
9+
# Additional packages frequently used during conversions
10+
# NOTE: `libsrvg`, pandoc uses `rsvg-convert` for working with svg images.
11+
RUN apt-get -q --no-allow-insecure-repositories update \
12+
&& DEBIAN_FRONTEND=noninteractive \
13+
apt-get install --assume-yes --no-install-recommends \
14+
librsvg2-bin=2.* \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Install pandoc-crossref
18+
RUN <<EOF
19+
set -eux
20+
21+
# Install curl
22+
apt-get -q --no-allow-insecure-repositories update
23+
apt-get install --assume-yes --no-install-recommends --mark-auto curl
24+
25+
url_base='https://github.com/lierdakil/pandoc-crossref/releases/download';
26+
case "$$(uname -m)" in
27+
('x86_64')
28+
arch="X64"
29+
crossref_hash=${core.pandoc-crossref.hashes.amd64}
30+
;;
31+
('arm64')
32+
arch="ARM64"
33+
crossref_hash=${core.pandoc-crossref.hashes.arm64}
34+
;;
35+
(*)
36+
echo >&2 "error: unsupported architecture '$$(uname -m)'"
37+
exit 1
38+
;;
39+
esac
40+
version="${core.pandoc-crossref.version}"
41+
filename="pandoc-crossref-Linux-$${arch}.tar.xz"
42+
curl --proto '=https' --tlsv1.3 -sSfL -o /tmp/pandoc-crossref.tar.xz \
43+
"$${url_base}/$${version}/pandoc-crossref-linux-$${arch}.tar.xz"
44+
echo "$$crossref_hash /tmp/pandoc-crossref.tar.xz" | sha256sum -c
45+
tar -xf /tmp/pandoc-crossref.tar.xz -C /usr/local/bin pandoc-crossref
46+
# Remove archive
47+
rm /tmp/pandoc-crossref.tar.xz
48+
# Curl is no longer needed
49+
apt-get autoremove --purge --assume-yes; \
50+
rm -rf /var/lib/apt/lists/*;
51+
EOF
52+

pandock/addon/core.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--- Handle options and parameters for Core images
2+
--
3+
-- Copyright : © 2025 Albert Krewinkel <albert+pandoc@tarleb.com>
4+
-- License : MIT
5+
6+
local function addon_context (core, release)
7+
local crossref_version = release.addon.core['pandoc-crossref']
8+
return {
9+
['pandoc-crossref'] = {
10+
version = crossref_version,
11+
hashes = core.hashes['pandoc-crossref'][crossref_version],
12+
}
13+
}
14+
end
15+
16+
return {
17+
addon_context = addon_context,
18+
}

pandock/generator.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ end
5656

5757
--- Writes a Dockerfile for a release.
5858
--
59-
-- The default (minimal&core) Dockerfile is built unless `addon` is
60-
-- specified.
59+
-- The default (minimal) Dockerfile is built unless `addon` is specified.
6160
generator.write_dockerfile = function(opts, addon)
6261
generator.log:warn(
6362
'Generating Dockerfile for pandoc/%s:%s-%s',
64-
addon or 'core',
63+
addon or 'minimal',
6564
opts.pandoc_version,
6665
opts.stack
6766
)

pandock/type/Variant.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
-- Copyright : © 2025 Albert Krewinkel <albert+pandoc@tarleb.com>
44
-- License : MIT
55

6-
local path = require 'pandoc.path'
76
local configutils = require 'pandock.configutils'
87

98
local Variant = configutils.make_config_class{
109
name = 'Variant',
1110
valid_keys = {'name', 'title', 'description', 'default-stack'},
1211
methods = {
1312
is_addon = function (self)
14-
return self.name ~= 'minimal' and self.name ~= 'core'
13+
return self.name ~= 'minimal'
1514
end
1615
}
1716
}

0 commit comments

Comments
 (0)