Instead of sending the whole image file for every receipt shown on the list page, we now generate thumbnails for them on the fly. This dramatically reduces the amount of bytes sent for each image, especially very large, high-quality photographs. It also improves support for non-image attachments like PDFs, by rendering image previews in the grid view instead of a broken image placeholder. We use GraphicsMagic to do the conversion. Its `MagickWand` API is pretty straightforward and convenient, and it supports a plethora of image and image-like formats.
63 lines
1.3 KiB
Docker
63 lines
1.3 KiB
Docker
FROM git.pyrocufflink.net/containerimages/dch-base AS build
|
|
|
|
RUN --mount=type=cache,target=/var/cache \
|
|
microdnf install -y \
|
|
--setopt persistdir=/var/cache/dnf \
|
|
--setopt install_weak_deps=0 \
|
|
GraphicsMagick-devel \
|
|
cargo \
|
|
clang-devel \
|
|
openssl-devel \
|
|
&& :
|
|
|
|
WORKDIR /build
|
|
|
|
COPY Cargo.* .
|
|
COPY src src
|
|
COPY .sqlx .sqlx
|
|
COPY migrations migrations
|
|
COPY sql sql
|
|
|
|
RUN --mount=type=cache,target=/root/.cargo \
|
|
cargo build --release --locked
|
|
|
|
FROM git.pyrocufflink.net/containerimages/dch-base AS esbuild
|
|
|
|
RUN --mount=type=cache,target=/var/cache \
|
|
microdnf install -y \
|
|
--setopt persistdir=/var/cache/dnf \
|
|
--setopt install_weak_deps=0 \
|
|
npm \
|
|
&& :
|
|
|
|
WORKDIR /build
|
|
|
|
COPY js .
|
|
|
|
RUN --mount=type=cache,target=/root/.cargo \
|
|
npm ci && npm run build
|
|
|
|
|
|
FROM git.pyrocufflink.net/containerimages/dch-base
|
|
|
|
RUN --mount=type=cache,target=/var/cache \
|
|
microdnf install -y \
|
|
--setopt persistdir=/var/cache/dnf \
|
|
--setopt install_weak_deps=0 \
|
|
GraphicsMagick \
|
|
clang-libs \
|
|
ghostscript \
|
|
&& :
|
|
|
|
COPY --from=build /build/target/release/receipts /usr/local/bin
|
|
|
|
COPY --from=esbuild /build/dist /usr/local/share/receipts/static
|
|
|
|
COPY templates /usr/local/share/receipts/templates
|
|
|
|
WORKDIR /usr/local/share/receipts
|
|
|
|
ENTRYPOINT ["/usr/local/bin/receipts"]
|
|
|
|
ENV ROCKET_CONFIG=/etc/receipts/config.toml
|