Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Latest docker image is missing library, uploading books fails #302

Closed
1 task done
bartschneider opened this issue Jul 7, 2024 · 8 comments · Fixed by #304
Closed
1 task done

[BUG] Latest docker image is missing library, uploading books fails #302

bartschneider opened this issue Jul 7, 2024 · 8 comments · Fixed by #304
Assignees

Comments

@bartschneider
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

[2024-07-07 08:04:23,556] ERROR {cps:1414} Exception on /upload [POST]
Traceback (most recent call last):
File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/app/calibre-web/cps/usermanagement.py", line 35, in decorated_view
return login_required(func)(*args, **kwargs)
File "/lsiopy/lib/python3.10/site-packages/flask_login/utils.py", line 290, in decorated_view
return current_app.ensure_sync(func)(*args, **kwargs)
File "/app/calibre-web/cps/editbooks.py", line 59, in inner
return f(*args, **kwargs)
File "/app/calibre-web/cps/editbooks.py", line 249, in upload
meta, error = file_handling_on_upload(requested_file)
File "/app/calibre-web/cps/editbooks.py", line 755, in file_handling_on_upload
if not validate_mime_type(requested_file, allowed_extensions):
File "/app/calibre-web/cps/file_helper.py", line 49, in validate_mime_type
mime = magic.Magic(mime=True)
NameError: name 'magic' is not defined

Book upload fails

Expected Behavior

Book uploads succeed

Steps To Reproduce

pull latest docker image

--- services: calibre-web: image: lscr.io/linuxserver/calibre-web:0.6.22-ls275 container_name: calibre-web environment: - PUID=1001 - PGID=1002 - TZ=Etc/UTC volumes: - /calibreconfig:/config - /mnt/nfs/calibre-lib:/books ports: - 8083:8083 restart: unless-stopped

try to upload a book to server through UI

Environment

- OS:
- How docker service was installed:

CPU architecture

arm64

Docker creation

---
services:
  calibre-web:
    image: lscr.io/linuxserver/calibre-web:0.6.22-ls275
    container_name: calibre-web
    environment:
      - PUID=1001
      - PGID=1002
      - TZ=Etc/UTC
    volumes:
      - /calibreconfig:/config
      - /mnt/nfs/calibre-lib:/books
    ports:
      - 8083:8083
    restart: unless-stopped

Container logs

docker logs calibre-web
[migrations] started
[migrations] no migrations found
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    1001
User GID:    1002
───────────────────────────────────────

[custom-init] No custom files found, skipping...
[ls.io-init] done.
Copy link

github-actions bot commented Jul 7, 2024

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

@Dinth
Copy link

Dinth commented Jul 7, 2024

janeczku/calibre-web#3096

As per the changelog:
"!Attention! For this update regex, bleach and python-magic has to be installed !Attention!"

@aptalca
Copy link
Member

aptalca commented Jul 7, 2024

@bartschneider
Copy link
Author

bartschneider commented Jul 7, 2024

python-magic has a secondary dependency on libmagic1 which needs to be added to the dockerfiles. Here's mine for arm64 that works now for me with the three missing python libraries which I added to optional-requirements.txt

# syntax=docker/dockerfile:1

FROM ghcr.io/linuxserver/unrar:arm64v8-latest as unrar

FROM ghcr.io/linuxserver/baseimage-ubuntu:arm64v8-jammy

# set version label
ARG BUILD_DATE
ARG VERSION
ARG CALIBREWEB_RELEASE
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="chbmb"

RUN \
  echo "**** install build packages ****" && \
  apt-get update && \
  apt-get install -y --no-install-recommends \
    build-essential \
    cmake \
    libffi-dev \
    libjpeg-dev \
    libldap2-dev \
    libsasl2-dev \
    libxml2-dev \
    libxslt1-dev \
    python3-dev \
    zlib1g-dev && \
  echo "**** install runtime packages ****" && \
  apt-get install -y --no-install-recommends \
    imagemagick \
    ghostscript \
    libldap-2.5-0 \
    libsasl2-2 \
    libxi6 \
    libxslt1.1 \
    libmagic1 \
    python3-venv && \
  echo "**** install calibre-web ****" && \
  if [ -z ${CALIBREWEB_RELEASE+x} ]; then \
    CALIBREWEB_RELEASE=$(curl -sX GET "https://api.github.com/repos/janeczku/calibre-web/releases/latest" \
      | awk '/tag_name/{print $4;exit}' FS='[""]'); \
  fi && \
  curl -o \
    /tmp/calibre-web.tar.gz -L \
    https://github.com/janeczku/calibre-web/archive/${CALIBREWEB_RELEASE}.tar.gz && \
  mkdir -p \
    /app/calibre-web && \
  tar xf \
    /tmp/calibre-web.tar.gz -C \
    /app/calibre-web --strip-components=1 && \
  cd /app/calibre-web && \
  python3 -m venv /lsiopy && \
  pip install -U --no-cache-dir \
    pip \
    wheel && \
  pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/ubuntu/ -r \
    requirements.txt -r \
    optional-requirements.txt && \
  echo "***install kepubify" && \
  if [ -z ${KEPUBIFY_RELEASE+x} ]; then \
    KEPUBIFY_RELEASE=$(curl -sX GET "https://api.github.com/repos/pgaskin/kepubify/releases/latest" \
      | awk '/tag_name/{print $4;exit}' FS='[""]'); \
  fi && \
  curl -o \
    /usr/bin/kepubify -L \
    https://github.com/pgaskin/kepubify/releases/download/${KEPUBIFY_RELEASE}/kepubify-linux-arm64 && \
  echo "**** cleanup ****" && \
  apt-get -y purge \
    build-essential \
    cmake \
    libffi-dev \
    libjpeg-dev \
    libldap2-dev \
    libsasl2-dev \
    libxml2-dev \
    libxslt1-dev \
    python3-dev \
    zlib1g-dev && \
  apt-get -y autoremove && \
  rm -rf \
    /tmp/* \
    /var/lib/apt/lists/* \
    /var/tmp/* \
    /root/.cache

# add local files
COPY root/ /

# add unrar
COPY --from=unrar /usr/bin/unrar-ubuntu /usr/bin/unrar

# ports and volumes
EXPOSE 8083
VOLUME /config

@aptalca
Copy link
Member

aptalca commented Jul 7, 2024

Thanks for the heads up. We'll add the new dep. Btw, you don't need to add the new packages to optional requirements because they are already in the requirements.txt in the latest version.

Alternatively, you can use our universal package install mod to install libmagic1 in the latest image container until we PR the fix so you don't need to build your own image.

@Dinth
Copy link

Dinth commented Jul 7, 2024

Alternatively, you can use our universal package install mod to install libmagic1 in the latest image container until we PR the fix so you don't need to build your own image.

Amazing tip, thank you very much!

@aptalca aptalca self-assigned this Jul 7, 2024
@dziban303
Copy link

Alternatively, you can use our universal package install mod to install libmagic1 in the latest image container until we PR the fix so you don't need to build your own image.

Thank you for reminding me this is a thing. Will this method cause any problems down the line once the package is built into the image? I.e., should I try to remember to remove it later, or will it not cause any problems?

@aptalca
Copy link
Member

aptalca commented Jul 7, 2024

No, it will just say the package is already installed.

@LinuxServer-CI LinuxServer-CI moved this from Issues to Done in Issue & PR Tracker Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants