Skip to content

Commit

Permalink
🔨 Fix docker dav1d shared library linking (#408)
Browse files Browse the repository at this point in the history
* fix: link dav1d.so.7.0 for build

* chore: just tryna get local build working

* chore: switch to using the server prisma gen

* chore: revert testing change

* chore: make dockerfile work locally

* chore: copy linked libraries and map to them in entrypoint

* tweak dockerfile

---------

Co-authored-by: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com>
  • Loading branch information
wolffshots and aaronleopold authored Aug 21, 2024
1 parent afd42e9 commit a8ef2a4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
34 changes: 28 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Frontend Build Stage
# ------------------------------------------------------------------------------

FROM node:20.0.0-alpine3.16 as frontend
FROM node:20.0.0-alpine3.16 AS frontend
ARG TARGETARCH

WORKDIR /app
Expand All @@ -23,7 +23,9 @@ RUN yarn config set network-timeout 300000 && \

FROM rust:1.79.0-slim-buster AS builder

# ARG TARGETARCH
ARG GIT_REV

ENV GIT_REV=${GIT_REV}

ARG TAGS
Expand All @@ -40,7 +42,7 @@ RUN apt-get update && apt-get install -y \
nasm \
libsqlite3-dev;

#Building dav1d for AVIF Support
# Building dav1d for AVIF Support
RUN git clone https://github.com/stumpapp/dav1d.git

WORKDIR /dav1d
Expand All @@ -51,16 +53,16 @@ WORKDIR /dav1d/build

RUN meson setup ../; \
ninja; \
ninja install
ninja install

#Cargo build for stump
# Cargo build for stump
WORKDIR /app

COPY . .

RUN ./scripts/release/utils.sh -w; \
RUN cargo prisma generate --schema ./core/prisma/schema.prisma; \
./scripts/release/utils.sh -w; \
set -ex; \
./scripts/release/utils.sh -p; \
cargo build --package stump_server --bin stump_server --release; \
cp ./target/release/stump_server ./stump_server

Expand All @@ -84,6 +86,22 @@ RUN apt-get update && apt-get install -y curl tar; \
tar -xzvf pdfium.tgz -C ./pdfium; \
rm pdfium.tgz

# ------------------------------------------------------------------------------
# dav1d Copy Stage
# ------------------------------------------------------------------------------

FROM debian:buster-slim AS dav1d
ARG TARGETARCH

COPY --from=builder /usr/local/lib /usr/local/lib

RUN set -ex; \
if [ "$TARGETARCH" = "amd64" ]; then \
cp -r /usr/local/lib/x86_64-linux-gnu/* /usr/local/lib; \
elif [ "$TARGETARCH" = "arm64" ]; then \
cp -r /usr/local/lib/aarch64-linux-gnu/* /usr/local/lib; \
fi

# ------------------------------------------------------------------------------
# Final Stage
# ------------------------------------------------------------------------------
Expand All @@ -95,11 +113,15 @@ RUN apt-get update && apt-get install -y locales-all && rm -rf /var/lib/apt/list

COPY --from=builder /app/stump_server /app/stump
COPY --from=pdfium /pdfium /opt/pdfium
COPY --from=dav1d /usr/local/lib/ /usr/local/lib/
COPY --from=frontend /app/build /app/client
COPY docker/entrypoint.sh /entrypoint.sh


RUN chmod +x /entrypoint.sh; \
ln -s /opt/pdfium/lib/libpdfium.so /lib/libpdfium.so; \
echo "/usr/local/lib" >> /etc/ld.so.conf.d/mylibs.conf \
&& ldconfig; \
if [ ! -d "/app/client" ] || [ ! "$(ls -A /app/client)" ]; then exit 1; fi

# Default Stump environment variables
Expand Down
3 changes: 3 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ fi
# Change current working directory
cd /app

# Make sure shared libraries are linked
echo '/usr/local/lib' >> /etc/ld.so.conf.d/mylibs.conf && ldconfig

if [[ "$PUID" -eq 0 ]]; then
# Run as root
/app/stump
Expand Down

0 comments on commit a8ef2a4

Please sign in to comment.