# Runtime-only image: copy prebuilt musl binaries (with OCR)
FROM --platform=$TARGETPLATFORM alpine:3.19 AS runtime
ARG TARGETARCH
ARG OCR_LANGS=""
# Install runtime dependencies (PDF extraction + OCR)
RUN apk add --no-cache openssl ca-certificates poppler-utils tesseract-ocr && \
if [ -n "$OCR_LANGS" ]; then \
for lang in $OCR_LANGS; do \
apk add --no-cache "tesseract-ocr-data-$lang"; \
done; \
fi
# Create non-root user
RUN addgroup -g 1000 appgroup && \
adduser -u 1000 -G appgroup -s /bin/sh -D appuser
# Copy binary for the current target architecture
COPY docker-bin/research-master-${TARGETARCH} /usr/local/bin/research-master
# Create downloads directory
RUN mkdir /downloads && chown appuser:appgroup /downloads
# Switch to non-root user
USER appuser
# Default command
ENTRYPOINT ["research-master"]
CMD ["serve"]