mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Two test-image gaps surfaced by a full pnpm test:ci run: - s3-storage.test.ts imports @aws-sdk/client-s3 (an enterprise dependency) at module load, but Dockerfile.test never copied packages/enterprise/package.json before pnpm install, so the suite failed to collect. Copy it so the dep installs; the suite then skips cleanly when MinIO is absent. - EPS batch decode returned 422: ImageMagick reads EPS through the Ghostscript PS coder, but policy.xml left PS/PS2/PS3 at rights=none (only EPS was opened), so convert refused with a policy error before Ghostscript ran. Open the PostScript coders too.
106 lines
4.2 KiB
Docker
106 lines
4.2 KiB
Docker
# ============================================
|
|
# SnapOtter - Test Dockerfile
|
|
# Runs the full test suite (unit + integration)
|
|
# ============================================
|
|
|
|
# ============================================
|
|
# Stage 1: Build libheif from source
|
|
# ============================================
|
|
FROM node:22-bookworm@sha256:2d178f2785b96dfbf62a416ca2e40f50e30150b4ff3320d706f0d96e90600eb3 AS libheif-builder
|
|
|
|
ARG LIBHEIF_VERSION=1.21.2
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
cmake pkg-config gcc g++ make curl ca-certificates \
|
|
libde265-dev libx265-dev libjpeg-dev libpng-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN curl -fsSL "https://github.com/strukturag/libheif/releases/download/v${LIBHEIF_VERSION}/libheif-${LIBHEIF_VERSION}.tar.gz" \
|
|
| tar xz \
|
|
&& cmake -B build -S "libheif-${LIBHEIF_VERSION}" \
|
|
-DCMAKE_INSTALL_PREFIX=/opt/libheif \
|
|
-DWITH_EXAMPLES=ON \
|
|
-DWITH_GDK_PIXBUF=OFF \
|
|
-DWITH_AOM_DECODER=OFF \
|
|
-DWITH_AOM_ENCODER=OFF \
|
|
-DWITH_DAV1D=OFF \
|
|
&& cmake --build build -j$(nproc) \
|
|
&& cmake --install build
|
|
|
|
# ============================================
|
|
# Stage 2: Test runner
|
|
# ============================================
|
|
FROM node:22-bookworm@sha256:2d178f2785b96dfbf62a416ca2e40f50e30150b4ff3320d706f0d96e90600eb3
|
|
|
|
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libde265-0 \
|
|
libimage-exiftool-perl \
|
|
imagemagick \
|
|
libraw-dev \
|
|
libjxl-tools \
|
|
ghostscript \
|
|
&& if apt-cache show libx265-199 >/dev/null 2>&1; then \
|
|
apt-get install -y --no-install-recommends libx265-199; \
|
|
elif apt-cache show libx265-209 >/dev/null 2>&1; then \
|
|
apt-get install -y --no-install-recommends libx265-209; \
|
|
fi \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY --from=libheif-builder /opt/libheif/bin/ /usr/local/bin/
|
|
COPY --from=libheif-builder /opt/libheif/lib/ /usr/local/lib/
|
|
# The base image ships an older system libheif (~1.15) that shadows our built
|
|
# 1.21 without this, so heif-dec fails with an undefined-symbol error.
|
|
ENV LD_LIBRARY_PATH=/usr/local/lib
|
|
RUN ldconfig
|
|
|
|
# Allow ImageMagick's Ghostscript delegate to read EPS. Decoding an EPS goes
|
|
# through the PostScript (PS) coder, so the default Debian policy.xml blocking
|
|
# PS/PS2/PS3 must be opened too, not just EPS -- otherwise `convert` refuses with
|
|
# a policy error before Ghostscript ever runs.
|
|
RUN POLICY_FILE=$(find /etc/ImageMagick* -name policy.xml 2>/dev/null | head -1) && \
|
|
if [ -n "$POLICY_FILE" ]; then \
|
|
for CODER in EPS PS PS2 PS3; do \
|
|
sed -i "s/<policy domain=\"coder\" rights=\"none\" pattern=\"${CODER}\"/<policy domain=\"coder\" rights=\"read|write\" pattern=\"${CODER}\"/" "$POLICY_FILE"; \
|
|
done; \
|
|
fi
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy workspace config first (for layer caching)
|
|
COPY pnpm-workspace.yaml pnpm-lock.yaml package.json turbo.json tsconfig.base.json vitest.config.ts ./
|
|
|
|
# Copy all package.json files
|
|
COPY apps/web/package.json apps/web/tsconfig.json apps/web/vite.config.ts ./apps/web/
|
|
COPY apps/api/package.json apps/api/tsconfig.json ./apps/api/
|
|
COPY packages/shared/package.json packages/shared/tsconfig.json ./packages/shared/
|
|
COPY packages/image-engine/package.json packages/image-engine/tsconfig.json ./packages/image-engine/
|
|
COPY packages/ai/package.json packages/ai/tsconfig.json ./packages/ai/
|
|
# enterprise ships @aws-sdk/client-s3, which tests/integration/s3-storage.test.ts
|
|
# imports at module load; without it that suite fails to collect.
|
|
COPY packages/enterprise/package.json packages/enterprise/tsconfig.json ./packages/enterprise/
|
|
|
|
# Install ALL dependencies (including devDependencies for testing)
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Environment for tests
|
|
ENV NODE_ENV=test \
|
|
AUTH_ENABLED=true \
|
|
DEFAULT_USERNAME=admin \
|
|
DEFAULT_PASSWORD=admin \
|
|
WORKSPACE_PATH=/tmp/test-workspace \
|
|
MAX_MEGAPIXELS=100 \
|
|
MAX_UPLOAD_SIZE_MB=100 \
|
|
MAX_BATCH_SIZE=200 \
|
|
CONCURRENT_JOBS=3 \
|
|
RATE_LIMIT_PER_MIN=1000 \
|
|
FILE_MAX_AGE_HOURS=1 \
|
|
CLEANUP_INTERVAL_MINUTES=60
|
|
|
|
# Run unit + integration tests with coverage
|
|
CMD ["pnpm", "test:all"]
|