2

I have an issue with a Jstree instance in my Django project. When I run the project using ./manage.py runserver the Jstree works perfectly fine, but when I run it with docker-compose up the Tree is shown for a few seconds and then disappears. No error is thrown. I know that its a very specific issue, but maybe one of you has a clue what I missed.

docker-compose.yml:

version: '3.9'

x-mayan-container:
  &mayan-container
  depends_on:
    - postgresql
    - redis
    # Enable to use RabbitMQ
    #- rabbitmq
  env_file: env_file
  environment:
    # Enable to use RabbitMQ
    # MAYAN_CELERY_BROKER_URL: amqp://${MAYAN_RABBITMQ_USER:-mayan}:${MAYAN_RABBITMQ_PASSWORD:-mayanrabbitpass}@rabbitmq:5672/${MAYAN_RABBITMQ_VHOST:-mayan}
    # To use RabbitMQ as broker, disable Redis as broker
    MAYAN_CELERY_BROKER_URL: redis://:${MAYAN_REDIS_PASSWORD:-mayanredispassword}@redis:6379/0
    MAYAN_CELERY_RESULT_BACKEND: redis://:${MAYAN_REDIS_PASSWORD:-mayanredispassword}@redis:6379/1
    MAYAN_DATABASES: "{'default':{'ENGINE':'django.db.backends.postgresql','NAME':'${MAYAN_DATABASE_NAME:-mayan}','PASSWORD':'${MAYAN_DATABASE_PASSWORD:-mayandbpass}','USER':'${MAYAN_DATABASE_USER:-mayan}','HOST':'${MAYAN_DATABASE_HOST:-postgresql}'}}"
    MAYAN_DOCKER_WAIT: "${MAYAN_DATABASE_HOST:-postgresql}:5432 redis:6379"
    MAYAN_LOCK_MANAGER_BACKEND: mayan.apps.lock_manager.backends.redis_lock.RedisLock
    MAYAN_LOCK_MANAGER_BACKEND_ARGUMENTS: "{'redis_url':'redis://:${MAYAN_REDIS_PASSWORD:-mayanredispassword}@redis:6379/2'}"
    # Replace with the line below when using RabbitMQ
    # MAYAN_DOCKER_WAIT: "${MAYAN_DATABASE_HOST:-postgresql}:5432 redis:6379 rabbitmq:5672"
  image: mayanedms/mayanedms:4.0
  networks:
    - bridge
  restart: unless-stopped
  volumes:
    - ${MAYAN_APP_VOLUME:-app}:/var/lib/mayan
    # Optional volumes to access external data like staging or watch folders
    # - /opt/staging_files:/staging_files
    # - /opt/watch_folder:/watch_folder

networks:
  bridge:
    driver: bridge

services:
  app:
    <<: *mayan-container
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.app.rule=Host(`www.example.com`)"  # Replace this with your published URL
      - "traefik.http.routers.mayan.rule=Host(`mayan.app`)"
      - "traefik.http.routers.mayan.entrypoints=web"
    ports:
      - "80:8000"

  postgresql:
    command:
      - "postgres"
      - "-c"
      - "checkpoint_completion_target=0.6"
      - "-c"
      - "default_statistics_target=200"
      - "-c"
      - "maintenance_work_mem=128MB"
      - "-c"
      - "max_connections=200"
      - "-c"
      - "shared_buffers=256MB"
      - "-c"
      - "work_mem=8MB"
    environment:
      POSTGRES_DB: ${MAYAN_DATABASE_NAME:-mayan}
      POSTGRES_PASSWORD: ${MAYAN_DATABASE_PASSWORD:-mayandbpass}
      POSTGRES_USER: ${MAYAN_DATABASE_USER:-mayan}
    image: postgres:${MAYAN_DOCKER_POSTGRES_TAG:-10.15-alpine}
    networks:
      - bridge
    restart: unless-stopped
    volumes:
      - ${MAYAN_POSTGRES_VOLUME:-postgres}:/var/lib/postgresql/data

  redis:
    command:
      - redis-server
      - --appendonly
      - "no"
      - --databases
      - "3"
      - --maxmemory
      - "100mb"
      - --maxclients
      - "500"
      - --maxmemory-policy
      - "allkeys-lru"
      - --save
      - ""
      - --tcp-backlog
      - "256"
      - --requirepass
      - "${MAYAN_REDIS_PASSWORD:-mayanredispassword}"
    image: redis:${MAYAN_DOCKER_REDIS_TAG:-6.0-alpine}
    networks:
      - bridge
    restart: unless-stopped
    volumes:
      - ${MAYAN_REDIS_VOLUME:-redis}:/data

  # Celery flower a monitor for Celery
  celery_flower:
    <<: *mayan-container
    command:
      - run_celery
      - flower
    ports:
      - "5555:5555"
    profiles:
      - celery_flower

  # Run a frontend gunicorn container
  frontend:
    <<: *mayan-container
    command:
      - run_worker
      - fast
    ports:
      - "81:8000"
    profiles:
      - extra_frontend

  # Enable to run standalone workers
  mountindex:
    <<: *mayan-container
    cap_add:
      - SYS_ADMIN
    devices:
      - "/dev/fuse:/dev/fuse"
    entrypoint:
      - /bin/bash
      - -c
      - 'mkdir --parents /mnt/index && chown mayan:mayan /mnt/index && /usr/local/bin/entrypoint.sh run_command "mountindex --allow-other creation_date /mnt/index"'  # Replace "creation_date" with the index of your choice.
    profiles:
      - mountindex
    security_opt:
      - apparmor:unconfined
    volumes:
      - type: bind
        source: /mnt/mayan_indexes/creation_date  # Host location where the index will show up.
        target: /mnt/index  # Location inside the container where the index will be mounted. Must the same is in the "entrypoint" section.
        bind:
          propagation: shared

  # Run a separate class A worker
  worker_a:
    <<: *mayan-container
    command:
      - run_worker
      - worker_a
    profiles:
      - extra_worker_a

  # Run a separate class B worker
  worker_b:
    <<: *mayan-container
    command:
      - run_worker
      - worker_b
    profiles:
      - extra_worker_b

  # Run a separate class C worker
  worker_c:
    <<: *mayan-container
    command:
      - run_worker
      - worker_c
    profiles:
      - extra_worker_c

  # Run a separate class D worker
  worker_d:
    <<: *mayan-container
    command:
      - run_worker
      - worker_d
    profiles:
      - extra_worker_d

  # Optional services

  traefik:
    container_name: "traefik"
    command:
      #- "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
    image: "traefik:v2.4"
    ports:
      - "80:80"
      - "8080:8080"
    profiles:
      - traefik
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

  # Enable to use RabbitMQ
  # rabbitmq:
  #   image: rabbitmq:${MAYAN_DOCKER_RABBITMQ_TAG:-3.8-alpine}
  #   environment:
  #     RABBITMQ_DEFAULT_USER: ${MAYAN_RABBITMQ_USER:-mayan}
  #     RABBITMQ_DEFAULT_PASS: ${MAYAN_RABBITMQ_PASSWORD:-mayanrabbitpass}
  #     RABBITMQ_DEFAULT_VHOST: ${MAYAN_RABBITMQ_VHOST:-mayan}
  #   networks:
  #     - bridge
  #   restart: unless-stopped
  #   volumes:
  #      - ${MAYAN_RABBITMQ_VOLUME:-rabbitmq}:/var/lib/rabbitmq

volumes:
  app:
  postgres:
  mountindex:
  rabbitmq:
  redis:
Dockerfile:

# vim:set ft=dockerfile:

####
# base_image - Bare bones image with the base packages needed to run
#              Mayan EDMS.
####

FROM debian:10.8-slim as base_image

LABEL maintainer="Roberto Rosario roberto.rosario@mayan-edms.com"

COPY config.env /config.env

ENV LC_ALL=C.UTF-8 \
    PYTHONUNBUFFERED=1 \
    PROJECT_INSTALL_DIR=/opt/mayan-edms/

# Debian package caching.
ARG APT_PROXY
RUN set -x \
&& if [ "${APT_PROXY}" ]; \
    then echo "Acquire::http { Proxy \"http://${APT_PROXY}\"; };" > /etc/apt/apt.conf.d/01proxy \
; fi \
# Install base OS packages to run Mayan EDMS.
&& echo "deb http://deb.debian.org/debian buster-backports main contrib non-free" >> /etc/apt/sources.list \
&& echo "deb-src http://deb.debian.org/debian buster-backports main contrib non-free" >> /etc/apt/sources.list \
&& DEBIAN_FRONTEND=noninteractive \
apt-get update \
&& apt-get install -y --no-install-recommends -t buster-backports \
    libreoffice-calc-nogui \
    libreoffice-draw-nogui \
    libreoffice-impress-nogui \
    libreoffice-math-nogui \
    libreoffice-writer-nogui \
&& apt-get install -y --no-install-recommends \
    ca-certificates \
    exiftool \
    fonts-arphic-uming \
    fonts-arphic-ukai \
    fonts-unfonts-core \
    fuse \
    ghostscript \
    git-core \
    gpgv \
    gnupg1 \
    graphviz \
    libarchive-zip-perl \
    libfuse2 \
    libmagic1 \
    libmariadb3 \
    libpq5 \
    poppler-utils \
    python3-distutils \
    sane-utils \
    sudo \
    supervisor \
    tesseract-ocr \
# Remove make and build dependencies.
&& apt-get remove -y \
    make \
    libproxy-tools \
    libreoffice-avmedia-backend-vlc \
    libvlc-bin \
    libvlc5 \
    libvlccore9 \
    adwaita-icon-theme \
    gsettings-desktop-schemas \
    libgstreamer-plugins-base1.0-0 \
&& apt-get autoremove -y --purge \
# Add mayan user.
&& adduser mayan --disabled-password --disabled-login --no-create-home --gecos "" \
# Pillow can't find zlib or libjpeg on aarch64 (ODROID C2).
&& if [ "$(uname -m)" = "aarch64" ]; then \
    ln -s /usr/lib/aarch64-linux-gnu/libz.so /usr/lib/ \
    && ln -s /usr/lib/aarch64-linux-gnu/libjpeg.so /usr/lib/ \
; fi \
# Pillow can't find zlib or libjpeg on armv7l (ODROID HC1).
&& if [ "$(uname -m)" = "armv7l" ]; then \
    ln -s /usr/lib/arm-linux-gnueabihf/libz.so /usr/lib/ \
    && ln -s /usr/lib/arm-linux-gnueabihf/libjpeg.so /usr/lib/ \
; fi \
&& sed -i 's/#user_allow_other/user_allow_other/g' /etc/fuse.conf

####
# builder_image - This image builds the Python package and is discarded afterwards
#                 only the build artifact is carried over to the next image.
####

# Reuse image.
FROM base_image as builder_image

# Python libraries caching.
ARG PIP_INDEX_URL
ARG PIP_TRUSTED_HOST

WORKDIR /src

# Copy the source files needed to build the Python package.
COPY --chown=mayan:mayan requirements /src/requirements
COPY --chown=mayan:mayan \
    HISTORY.rst \
    LICENSE \
    MANIFEST.in \
    README.md \
    README.rst \
    setup.py \
    /src/

COPY --chown=mayan:mayan mayan /src/mayan

# Install development packages needed to build the Python packages.
RUN DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
    default-libmysqlclient-dev \
    libffi-dev \
    libjpeg-dev \
    libpng-dev \
    libpq-dev \
    libtiff-dev \
    libssl-dev \
    g++ \
    gcc \
    make \
    python3-dev \
    python3-venv \
    zlib1g-dev \
&& mkdir -p "${PROJECT_INSTALL_DIR}" \
&& chown -R mayan:mayan "${PROJECT_INSTALL_DIR}" \
&& chown -R mayan:mayan /src

USER mayan

RUN set -a \
&& . /config.env \
&& set +a \
&& python3 -m venv "${PROJECT_INSTALL_DIR}" \
&& . "${PROJECT_INSTALL_DIR}bin/activate" \
&& pip install --no-cache-dir \
    pip==${PYTHON_PIP_VERSION} \
    amqp==${PYTHON_AMQP_VERSION} \
    mysqlclient==${PYTHON_MYSQL_VERSION} \
    psycopg2==${PYTHON_PSYCOPG2_VERSION} \
    redis==${PYTHON_REDIS_VERSION} \
    flower==${PYTHON_FLOWER_VERSION} \
# psutil is needed by ARM builds otherwise gevent and gunicorn fail to start.
&& UNAME=`uname -m` && if [ "${UNAME#*arm}" != ${UNAME} ]; then \
    pip install --no-cache-dir \
    psutil==${PYTHON_PSUTIL_VERSION} \
; fi \
# Install the Python packages needed to build Mayan EDMS.
&& pip install --no-cache-dir -r /src/requirements/build.txt \
# Build Mayan EDMS.
&& python3 setup.py sdist \
&& pip wheel --no-index --no-deps --wheel-dir dist dist/mayan-edms-*.tar.gz \
# Install the built Mayan EDMS package.
&& pip install --no-cache-dir dist/mayan_edms-*.whl \
# Install the static content.
&& mayan-edms.py installdependencies \
&& MAYAN_STATIC_ROOT=${PROJECT_INSTALL_DIR}static mayan-edms.py preparestatic --link --noinput

COPY --chown=mayan:mayan requirements/testing-base.txt "${PROJECT_INSTALL_DIR}"

####
# Final image - base_image + builder_image artifact (Mayan install directory).
####

FROM base_image

COPY --from=builder_image --chown=mayan:mayan "${PROJECT_INSTALL_DIR}" "${PROJECT_INSTALL_DIR}"

USER root

COPY docker/rootfs /

VOLUME ["/var/lib/mayan"]

ENTRYPOINT ["entrypoint.sh"]

EXPOSE 8000
CMD ["run_all"]

RUN set -a \
&& . /config.env \
&& set +a \
&& ${PROJECT_INSTALL_DIR}bin/mayan-edms.py platformtemplate docker_entrypoint > /usr/local/bin/entrypoint.sh \
&& chown mayan:mayan /usr/local/bin/entrypoint.sh \
&& chmod +x /usr/local/bin/entrypoint.sh \
&& ${PROJECT_INSTALL_DIR}bin/mayan-edms.py platformtemplate docker_supervisord > ${SUPERVISOR_CONFIGURATION_DIRECTORY}${SUPERVISOR_CONFIGURATION_FILENAME} \
&& apt-get clean autoclean \
&& apt-get autoremove --purge -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -f /var/cache/apt/archives/*.deb \
# Remove temporary files owned by root from the platformtemplate step.
&& rm -f /tmp/* \
# Keep displaying log messages to stdout
&& find /var/log -type f | while read f; do echo -ne '' > $f; done \
# Delete Debian package proxy used for the base image.
&& rm -f /etc/apt/apt.conf.d/01proxy
Roberto Rosario
  • 1,818
  • 1
  • 17
  • 31
Dan
  • 21
  • 2

0 Answers0