Mayan in Docker with PostgreSQL

300 views
Skip to first unread message

Jbr SOLUÇÕES

unread,
May 12, 2017, 1:51:12 PM5/12/17
to Mayan EDMS
Would anyone have an example of Dockerfile installing Mayan with Postgres ?

I tried with this and it did not work

NameError: name 'TEMPLATES' is not defined

FROM ubuntu:16.04

MAINTAINER Roberto Rosario "roberto...@mayan-edms.com"


ENV DEBIAN_FRONTEND noninteractive

ENV MAYAN_USE_POSTGRES True

ENV POSTGRES_DB mayan
ENV POSTGRES_USER mayan
ENV POSTGRES_PASSWORD mayan
ENV POSTGRES_HOST localhost
ENV PORTGRES_PORT 5432

ARG APT_PROXY
# Package caching
RUN if [ "${APT_PROXY}" ]; then echo "Acquire::http { Proxy \"http://${APT_PROXY}\"; };" > /etc/apt/apt.conf.d/01proxy; fi

# Install base Ubuntu libraries
RUN apt-get update && \

apt-get install -y --no-install-recommends \
postgresql \
libpq-dev \
gcc \
ghostscript \
gpgv \
libjpeg-dev \
libmagic1 \
libpng-dev \
libpq-dev \
libreoffice \
libtiff-dev \
nginx \
netcat-openbsd \
poppler-utils \
python-dev \
python-pip \
python-setuptools \
python-wheel \
redis-server \
supervisor \
tesseract-ocr \

&& \

apt-get clean autoclean && \

apt-get autoremove -y && \

rm -rf /var/lib/apt/lists/* && \

rm -f /var/cache/apt/archives/*.deb

ENV MAYAN_INSTALL_DIR=/usr/local/lib/python2.7/dist-packages/mayan

# Update to latest version of pip
RUN pip install -U pip

USER postgres
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER mayan WITH SUPERUSER PASSWORD 'mayan';" && \
createdb -O mayan mayan;

RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.5/main/pg_hba.conf

RUN echo "listen_addresses='*'" >> /etc/postgresql/9.5/main/postgresql.conf

EXPOSE 5432

USER root

# Install Mayan EDMS, latest production release
COPY mayan-edms-2.2.tar.gz /opt/
RUN pip install /opt/mayan-edms-2.2.tar.gz
# RUN pip install mayan-edms==2.2

# Install Python clients for PostgreSQL, REDIS, librabbitmq and uWSGI
RUN pip install psycopg2 redis uwsgi

# Collect static files
RUN mayan-edms.py collectstatic --noinput

# Setup uWSGI
COPY etc/uwsgi/uwsgi.ini $MAYAN_INSTALL_DIR

# Setup NGINX
COPY /etc/nginx/mayan-edms /etc/nginx/sites-available/mayan-edms
RUN rm /etc/nginx/sites-enabled/default
RUN ln -s /etc/nginx/sites-available/mayan-edms /etc/nginx/sites-enabled/mayan-edms

# Setup supervisor
COPY /etc/supervisor/beat.conf /etc/supervisor/conf.d
COPY /etc/supervisor/nginx.conf /etc/supervisor/conf.d
COPY /etc/supervisor/uwsgi.conf /etc/supervisor/conf.d
COPY /etc/supervisor/redis.conf /etc/supervisor/conf.d
COPY /etc/supervisor/workers.conf /etc/supervisor/conf.d

# Setup Mayan EDMS settings file overrides
COPY etc/mayan/settings.py /local.py
COPY etc/mayan/postgres.py $MAYAN_INSTALL_DIR/settings/postgres.py

# Create the directory for the logs
RUN mkdir /var/log/mayan

RUN mkdir -p $MAYAN_INSTALL_DIR/media/document_storage/

# Fix ownership
RUN chown -R www-data:www-data $MAYAN_INSTALL_DIR

# Make volume symlinks
RUN ln -s $MAYAN_INSTALL_DIR/media /var/lib/mayan
RUN ln -s $MAYAN_INSTALL_DIR/settings /etc/mayan
RUN chown www-data:www-data /var/lib/mayan
RUN chown www-data:www-data /etc/mayan

#TESTES
RUN /etc/init.d/postgresql start && \
mayan-edms.py initialsetup
RUN cat /local.py >> /usr/local/lib/python2.7/dist-packages/mayan/settings/local.py
RUN chown -R www-data:www-data /usr/local/lib/python2.7/dist-packages/mayan/

VOLUME ["/etc/mayan", "/var/lib/mayan"]
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
CMD ["mayan:start"]

Prasanjit Biswas

unread,
May 15, 2017, 3:09:59 AM5/15/17
to Mayan EDMS
I think this is not yet possible. issue- https://gitlab.com/mayan-edms/mayan-edms-docker/issues/7

Roberto Rosario

unread,
May 18, 2017, 12:14:22 AM5/18/17
to Mayan EDMS
Working precisely on this and other improvements at the moment: https://gitlab.com/mayan-edms/mayan-edms-docker/commit/1e523e29c691adc2887f67481d2923b7abf8a804

From the working changelog:

- Allow changing the database backend (postgres working, MySQL untested).
- Allow changing the Celery broker
- Allow changing the Celery results backend
- Add a dedicated image converter worker
- Implement single installation step
- Implement single volume solution
- Increase NGINX max file size to 500 MB
- Increase NGINX file transfer timeout to 600 seconds
- When overrided, the database settings will add the option to keep connections
  alive with a default of 60 seconds. ('CONN_MAX_AGE': 60)

New environment variables:

- MAYAN_DATABASE_DRIVER, default: None
- MAYAN_DATABASE_NAME, default : 'mayan'
- MAYAN_DATABASE_USER, default: 'mayan'
- MAYAN_DATABASE_PASSWORD, default: ''
- MAYAN_DATABASE_HOST, default: None
- MAYAN_DATABASE_PORT, default: None
- MAYAN_BROKER_URL, default: 'redis://127.0.0.1:6379/0'
- MAYAN_CELERY_RESULT_BACKEND, default: 'redis://127.0.0.1:6379/0'

- If the MAYAN_BROKER_URL and MAYAN_CELERY_RESULT_BACKEND are specified the built in
  REDIS server is disabled.

Help with testing needed.

Also would like to add automated testing for the image. Trying out testinfra (https://github.com/philpep/testinfra), but anything like ServerSpec or RSpec is welcomed too.
Reply all
Reply to author
Forward
0 new messages