Merge Docker files back into main repo.
Signed-off-by: Eric Riggs <ericriggs42@gmail.com>
This commit is contained in:
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@@ -0,0 +1,10 @@
|
||||
.git
|
||||
.gitignore
|
||||
HISTORY.md
|
||||
mayan/media
|
||||
db.sqlite*
|
||||
docker
|
||||
!docker/etc
|
||||
!docker/entrypoint.sh
|
||||
./.*
|
||||
docs
|
||||
8
Makefile
8
Makefile
@@ -1,5 +1,7 @@
|
||||
.PHONY: clean-pyc clean-build
|
||||
|
||||
APT_PROXY ?= `/sbin/ip route|awk '/docker0/ { print $$9 }'`:3142
|
||||
DOCKER_VERSION ?= `cat docker/version`
|
||||
|
||||
help:
|
||||
@echo
|
||||
@@ -361,3 +363,9 @@ check_readme:
|
||||
check_missing_migrations:
|
||||
./manage.py makemigrations --dry-run --noinput --check
|
||||
|
||||
|
||||
docker-build:
|
||||
docker build -t mayanedms/mayanedms:$(DOCKER_VERSION) -f docker/Dockerfile .
|
||||
|
||||
docker-build-with-proxy:
|
||||
docker build -t mayanedms/mayanedms:$(DOCKER_VERSION) -f docker/Dockerfile --build-arg APT_PROXY=$(APT_PROXY) .
|
||||
|
||||
129
docker/Dockerfile
Executable file
129
docker/Dockerfile
Executable file
@@ -0,0 +1,129 @@
|
||||
# vim:set ft=dockerfile:
|
||||
|
||||
####################
|
||||
# Base image start #
|
||||
####################
|
||||
|
||||
FROM ubuntu:16.04 as BASE_IMAGE
|
||||
|
||||
MAINTAINER Roberto Rosario "roberto.rosario@mayan-edms.com"
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV PROJECT_INSTALL_DIR=/usr/local/lib/python2.7/dist-packages/mayan
|
||||
|
||||
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 \
|
||||
curl \
|
||||
gcc \
|
||||
gettext-base \
|
||||
ghostscript \
|
||||
gpgv \
|
||||
graphviz \
|
||||
libffi6 \
|
||||
libjpeg-dev \
|
||||
libmagic1 \
|
||||
libmysqlclient-dev \
|
||||
libpng-dev \
|
||||
libpq-dev \
|
||||
libreoffice \
|
||||
libtiff-dev \
|
||||
locales \
|
||||
netcat-openbsd \
|
||||
poppler-utils \
|
||||
python-dev \
|
||||
python-pip \
|
||||
python-setuptools \
|
||||
python-wheel \
|
||||
redis-server \
|
||||
supervisor \
|
||||
tesseract-ocr \
|
||||
&& \
|
||||
apt-get clean autoclean && \
|
||||
apt-get autoremove --purge -y && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
rm -f /var/cache/apt/archives/*.deb
|
||||
|
||||
# Switch to UTF locale
|
||||
RUN echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale && \
|
||||
locale-gen en_US.UTF-8 && \
|
||||
update-locale LANG=en_US.UTF-8 && \
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
# Install apt-get-install
|
||||
ADD https://raw.githubusercontent.com/guilhem/apt-get-install/master/apt-get-install /usr/bin/
|
||||
RUN chmod +x /usr/bin/apt-get-install
|
||||
|
||||
# Install Python clients for PostgreSQL, REDIS, librabbitmq
|
||||
RUN pip install psycopg2==2.7.3.2 redis==2.10.6 mysql-python==1.2.5 librabbitmq==1.6.1
|
||||
|
||||
RUN adduser mayan --disabled-password --disabled-login --no-create-home --gecos ""
|
||||
|
||||
#####################
|
||||
# Build image start #
|
||||
#####################
|
||||
|
||||
FROM python:2-alpine3.7 as BUILDER_IMAGE
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
COPY . /code
|
||||
|
||||
RUN apk update && \
|
||||
apk add make
|
||||
|
||||
RUN pip install -r requirements/build.txt
|
||||
|
||||
RUN make wheel
|
||||
|
||||
RUN chmod 777 dist -R
|
||||
|
||||
#####################
|
||||
# Final image start #
|
||||
#####################
|
||||
|
||||
FROM BASE_IMAGE
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
COPY --from=BUILDER_IMAGE /code/dist/*.whl .
|
||||
|
||||
# Install build Mayan EDMS
|
||||
RUN pip install *.whl && \
|
||||
rm *.whl
|
||||
|
||||
# Setup supervisor
|
||||
#RUN mkdir /etc/supervisor.d/
|
||||
COPY docker/etc/supervisor/beat.conf /etc/supervisor/conf.d
|
||||
COPY docker/etc/supervisor/gunicorn.conf /etc/supervisor/conf.d
|
||||
COPY docker/etc/supervisor/redis.conf /etc/supervisor/conf.d
|
||||
COPY docker/etc/supervisor/workers.conf /etc/supervisor/conf.d
|
||||
|
||||
# Create the directory for the logs
|
||||
RUN mkdir /var/log/mayan
|
||||
|
||||
# Fix ownership
|
||||
RUN chown -R mayan:mayan $PROJECT_INSTALL_DIR
|
||||
|
||||
# Allow flanker to autogenerate its PLY files
|
||||
RUN chown -R mayan:mayan /usr/local/lib/python2.7/dist-packages/flanker/
|
||||
|
||||
RUN mkdir /var/lib/mayan
|
||||
VOLUME ["/var/lib/mayan"]
|
||||
|
||||
COPY docker/entrypoint.sh /usr/local/bin/
|
||||
RUN ln -s usr/local/bin/entrypoint.sh / # backwards compat
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
|
||||
# Healthcheck setup
|
||||
HEALTHCHECK --interval=15s --timeout=1s --retries=20 \
|
||||
CMD curl -s -f http://localhost/authentication/login/ | grep 'form' > /dev/null || exit 1
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["mayan"]
|
||||
42
docker/Makefile
Executable file
42
docker/Makefile
Executable file
@@ -0,0 +1,42 @@
|
||||
|
||||
APT_PROXY ?= `/sbin/ip route|awk '/docker0/ { print $$9 }'`:3142
|
||||
VERSION ?= `cat version`
|
||||
|
||||
help:
|
||||
@echo
|
||||
@echo "readme-render - Generate a new README.md from README.md.tmpl."
|
||||
@echo "release - Push code to trigger and publish a new version build."
|
||||
@echo "build - Build a new image locally."
|
||||
@echo "build-with-proxy - Build a new image locally using an APT proxy."
|
||||
@echo "test-container - Build and run a test container."
|
||||
@echo "test-cleanup - Delete the test container and the test volume."
|
||||
@echo "test-all - Build, run a test container, and executed the test suite."
|
||||
|
||||
readme-render:
|
||||
@export VERSION=$(VERSION); \
|
||||
envsubst < README.md.tmpl > README.md
|
||||
|
||||
release:
|
||||
git push origin
|
||||
git push --tags origin || true
|
||||
git push --tags bitbucket || true
|
||||
git push bitbucket
|
||||
|
||||
build:
|
||||
@export DIRECTORY=`pwd`; \
|
||||
export PARENT_DIRECTORY=`dirname "$$DIRECTORY"`; \
|
||||
docker build -t mayanedms/mayanedms:$(VERSION) -f $$PARENT_DIRECTORY
|
||||
|
||||
build-with-proxy:
|
||||
docker build -t mayanedms/mayanedms:$(VERSION) --build-arg APT_PROXY=$(APT_PROXY) .
|
||||
|
||||
test-launch-container: build-with-proxy test-cleanup
|
||||
docker run -d --name test-mayan-edms -p 80:80 -v test-mayan_data:/var/lib/mayan mayanedms/mayanedms:$(VERSION)
|
||||
|
||||
test-cleanup:
|
||||
@docker rm -f test-mayan-edms || true
|
||||
@docker volume rm test-mayan_data || true
|
||||
|
||||
test-all: test-launch-container
|
||||
docker exec -ti test-mayan-edms sh -c "apt-get update && apt-get install -y tesseract-ocr-deu"
|
||||
docker exec -ti test-mayan-edms sh -c "mayan-edms.py test --mayan-apps"
|
||||
1
docker/README-short.txt
Executable file
1
docker/README-short.txt
Executable file
@@ -0,0 +1 @@
|
||||
Mayan EDMS is a free open source electronic document management system.
|
||||
549
docker/README.md
Executable file
549
docker/README.md
Executable file
File diff suppressed because it is too large
Load Diff
549
docker/README.md.tmpl
Executable file
549
docker/README.md.tmpl
Executable file
File diff suppressed because it is too large
Load Diff
72
docker/docker-compose-development.yml
Executable file
72
docker/docker-compose-development.yml
Executable file
@@ -0,0 +1,72 @@
|
||||
version: '2.1'
|
||||
|
||||
volumes:
|
||||
broker:
|
||||
driver: local
|
||||
app:
|
||||
driver: local
|
||||
db:
|
||||
driver: local
|
||||
results:
|
||||
driver: local
|
||||
|
||||
services:
|
||||
broker:
|
||||
container_name: mayan-edms-broker
|
||||
image: healthcheck/rabbitmq
|
||||
environment:
|
||||
RABBITMQ_DEFAULT_USER: mayan
|
||||
RABBITMQ_DEFAULT_PASS: mayan
|
||||
RABBITMQ_DEFAULT_VHOST: mayan
|
||||
volumes:
|
||||
- broker:/var/lib/rabbitmq
|
||||
results:
|
||||
container_name: mayan-edms-results
|
||||
image: healthcheck/redis
|
||||
volumes:
|
||||
- results:/data
|
||||
#db:
|
||||
# container_name: mayan-edms-db
|
||||
# image: healthcheck/mysql
|
||||
# environment:
|
||||
# MYSQL_DATABASE: mayan
|
||||
# MYSQL_PASSWORD: mayan-password
|
||||
# MYSQL_ROOT_PASSWORD: root-password
|
||||
# MYSQL_USER: mayan
|
||||
# volumes:
|
||||
# - db:/var/lib/mysql
|
||||
db:
|
||||
container_name: mayan-edms-db
|
||||
image: healthcheck/postgres
|
||||
environment:
|
||||
POSTGRES_DB: mayan
|
||||
POSTGRES_PASSWORD: mayan-password
|
||||
POSTGRES_USER: mayan
|
||||
volumes:
|
||||
- db:/var/lib/postgresql/data
|
||||
mayan-edms:
|
||||
container_name: mayan-edms-app
|
||||
image: mayan-edms/next
|
||||
build:
|
||||
context: ./
|
||||
args:
|
||||
- APT_PROXY=172.18.0.1:3142
|
||||
depends_on:
|
||||
broker:
|
||||
condition: service_healthy
|
||||
db:
|
||||
condition: service_healthy
|
||||
results:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
MAYAN_BROKER_URL: amqp://mayan:mayan@broker:5672/mayan
|
||||
MAYAN_CELERY_RESULT_BACKEND: redis://results:6379/0
|
||||
MAYAN_DATABASE_DRIVER: django.db.backends.postgres
|
||||
MAYAN_DATABASE_HOST: db
|
||||
MAYAN_DATABASE_NAME: mayan
|
||||
MAYAN_DATABASE_PASSWORD: mayan-password
|
||||
MAYAN_DATABASE_USER: mayan
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- app:/var/lib/mayan
|
||||
58
docker/docker-compose.yml
Executable file
58
docker/docker-compose.yml
Executable file
@@ -0,0 +1,58 @@
|
||||
version: '2.1'
|
||||
|
||||
volumes:
|
||||
broker:
|
||||
driver: local
|
||||
app:
|
||||
driver: local
|
||||
db:
|
||||
driver: local
|
||||
results:
|
||||
driver: local
|
||||
|
||||
services:
|
||||
broker:
|
||||
container_name: mayan-edms-broker
|
||||
image: healthcheck/rabbitmq
|
||||
environment:
|
||||
RABBITMQ_DEFAULT_USER: mayan
|
||||
RABBITMQ_DEFAULT_PASS: mayan
|
||||
RABBITMQ_DEFAULT_VHOST: mayan
|
||||
volumes:
|
||||
- broker:/var/lib/rabbitmq
|
||||
results:
|
||||
container_name: mayan-edms-results
|
||||
image: healthcheck/redis
|
||||
volumes:
|
||||
- results:/data
|
||||
db:
|
||||
container_name: mayan-edms-db
|
||||
image: healthcheck/postgres
|
||||
environment:
|
||||
POSTGRES_DB: mayan
|
||||
POSTGRES_PASSWORD: mayan-password
|
||||
POSTGRES_USER: mayan
|
||||
volumes:
|
||||
- db:/var/lib/postgresql/data
|
||||
mayan-edms:
|
||||
container_name: mayan-edms-app
|
||||
image: mayanedms/mayanedms:2.6
|
||||
depends_on:
|
||||
broker:
|
||||
condition: service_healthy
|
||||
db:
|
||||
condition: service_healthy
|
||||
results:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
MAYAN_BROKER_URL: amqp://mayan:mayan@broker:5672/mayan
|
||||
MAYAN_CELERY_RESULT_BACKEND: redis://results:6379/0
|
||||
MAYAN_DATABASE_DRIVER: django.db.backends.postgres
|
||||
MAYAN_DATABASE_HOST: db
|
||||
MAYAN_DATABASE_NAME: mayan
|
||||
MAYAN_DATABASE_PASSWORD: mayan-password
|
||||
MAYAN_DATABASE_USER: mayan
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- app:/var/lib/mayan
|
||||
57
docker/entrypoint.sh
Executable file
57
docker/entrypoint.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
echo "* start"
|
||||
INSTALL_FLAG=/var/lib/mayan/media/system/SECRET_KEY
|
||||
|
||||
export MAYAN_MEDIA_ROOT=/var/lib/mayan
|
||||
export MAYAN_GUNICORN_WORKERS=${MAYAN_GUNICORN_WORKERS:-3}
|
||||
|
||||
chown mayan:mayan /var/lib/mayan -R
|
||||
|
||||
initialize() {
|
||||
echo "* initialize"
|
||||
su mayan -c "mayan-edms.py initialsetup --force"
|
||||
su mayan -c "mayan-edms.py collectstatic --noinput --clear"
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
echo "* upgrade"
|
||||
su mayan -c "mayan-edms.py performupgrade"
|
||||
su mayan -c "mayan-edms.py collectstatic --noinput --clear"
|
||||
}
|
||||
|
||||
start() {
|
||||
rm -rf /var/run/supervisor.sock
|
||||
exec /usr/bin/supervisord -nc /etc/supervisor/supervisord.conf
|
||||
}
|
||||
|
||||
os_package_installs() {
|
||||
echo "* os_package_installs"
|
||||
if [ "${MAYAN_APT_INSTALLS}" ]; then
|
||||
apt-get-install $MAYAN_APT_INSTALLS
|
||||
fi
|
||||
}
|
||||
|
||||
pip_installs() {
|
||||
echo "* pip_installs"
|
||||
if [ "${MAYAN_PIP_INSTALLS}" ]; then
|
||||
pip install $MAYAN_PIP_INSTALLS
|
||||
fi
|
||||
}
|
||||
|
||||
os_package_installs || true
|
||||
pip_installs || true
|
||||
|
||||
if [ "$1" = 'mayan' ]; then
|
||||
# Check if this is a new install, otherwise try to upgrade the existing
|
||||
# installation on subsequent starts
|
||||
if [ ! -f $INSTALL_FLAG ]; then
|
||||
initialize
|
||||
else
|
||||
upgrade
|
||||
fi
|
||||
start
|
||||
else
|
||||
su mayan -c "mayan-edms.py $@";
|
||||
fi
|
||||
15
docker/etc/supervisor/beat.conf
Executable file
15
docker/etc/supervisor/beat.conf
Executable file
@@ -0,0 +1,15 @@
|
||||
[program:celery-beat]
|
||||
autorestart = false
|
||||
autostart = true
|
||||
command = python /usr/local/lib/python2.7/dist-packages/mayan/bin/mayan-edms.py celery --settings=mayan.settings.production beat -l ERROR
|
||||
directory = /usr/local/lib/python2.7/dist-packages/mayan/
|
||||
killasgroup = true
|
||||
numprocs = 1
|
||||
priority = 998
|
||||
stderr_logfile = /dev/fd/2
|
||||
stderr_logfile_maxbytes = 0
|
||||
stdout_logfile = /dev/fd/1
|
||||
stdout_logfile_maxbytes = 0
|
||||
startsecs = 10
|
||||
stopwaitsecs = 1
|
||||
user = mayan
|
||||
9
docker/etc/supervisor/gunicorn.conf
Normal file
9
docker/etc/supervisor/gunicorn.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
[program:gunicorn]
|
||||
autorestart = false
|
||||
autostart = true
|
||||
command = /bin/bash -c "gunicorn -w ${MAYAN_GUNICORN_WORKERS:-3} mayan.wsgi --max-requests 1000 --max-requests-jitter 50 --worker-class gevent --bind 0.0.0.0:8000"
|
||||
#command = gunicorn -w ${MAYAN_GUNICORN_WORKERS:-3} mayan.wsgi --max-requests 1000 --max-requests-jitter 50 --worker-class gevent --bind 0.0.0.0:8000
|
||||
#command = /bin/bash -c "if [ -z ${MAYAN_BROKER_URL} ] || [ -z ${MAYAN_CELERY_RESULT_BACKEND} ];then /usr/bin/redis-server /etc/redis/;fi"
|
||||
directory = /tmp
|
||||
redirect_stderr = true
|
||||
user = mayan
|
||||
5
docker/etc/supervisor/redis.conf
Executable file
5
docker/etc/supervisor/redis.conf
Executable file
@@ -0,0 +1,5 @@
|
||||
[program:redis]
|
||||
autorestart = false
|
||||
autostart = true
|
||||
command = /bin/bash -c "if [ -z ${MAYAN_BROKER_URL} ] || [ -z ${MAYAN_CELERY_RESULT_BACKEND} ];then /usr/bin/redis-server /etc/redis/;fi"
|
||||
user = root
|
||||
63
docker/etc/supervisor/workers.conf
Executable file
63
docker/etc/supervisor/workers.conf
Executable file
@@ -0,0 +1,63 @@
|
||||
[program:mayan-worker-fast]
|
||||
autorestart = false
|
||||
autostart = true
|
||||
command = python /usr/local/lib/python2.7/dist-packages/mayan/bin/mayan-edms.py celery --settings=mayan.settings.production worker -Ofair -l ERROR -Q converter -n mayan-worker-fast.%%h
|
||||
directory = /usr/local/lib/python2.7/dist-packages/mayan/
|
||||
killasgroup = true
|
||||
numprocs = 1
|
||||
priority = 998
|
||||
startsecs = 10
|
||||
stderr_logfile = /dev/fd/2
|
||||
stderr_logfile_maxbytes = 0
|
||||
stdout_logfile = /dev/fd/1
|
||||
stdout_logfile_maxbytes = 0
|
||||
stopwaitsecs = 1
|
||||
user = mayan
|
||||
|
||||
[program:mayan-worker-medium]
|
||||
autorestart = false
|
||||
autostart = true
|
||||
command = python /usr/local/lib/python2.7/dist-packages/mayan/bin/mayan-edms.py celery --settings=mayan.settings.production worker -Ofair -l ERROR -Q checkouts_periodic,documents_periodic,indexing,metadata,sources,sources_periodic,uploads,documents -n mayan-worker-medium.%%h
|
||||
directory = /usr/local/lib/python2.7/dist-packages/mayan/
|
||||
killasgroup = true
|
||||
numprocs = 1
|
||||
priority = 998
|
||||
startsecs = 10
|
||||
stderr_logfile = /dev/fd/2
|
||||
stderr_logfile_maxbytes = 0
|
||||
stdout_logfile = /dev/fd/1
|
||||
stdout_logfile_maxbytes = 0
|
||||
stopwaitsecs = 1
|
||||
user = mayan
|
||||
|
||||
[program:mayan-worker-slow]
|
||||
autorestart = false
|
||||
autostart = true
|
||||
command = python /usr/local/lib/python2.7/dist-packages/mayan/bin/mayan-edms.py celery --settings=mayan.settings.production worker -Ofair -l ERROR -Q mailing,tools,statistics -n mayan-worker-slow.%%h --concurrency=1
|
||||
directory = /usr/local/lib/python2.7/dist-packages/mayan/
|
||||
killasgroup = true
|
||||
numprocs = 1
|
||||
priority = 998
|
||||
startsecs = 10
|
||||
stderr_logfile = /dev/fd/2
|
||||
stderr_logfile_maxbytes = 0
|
||||
stdout_logfile = /dev/fd/1
|
||||
stdout_logfile_maxbytes = 0
|
||||
stopwaitsecs = 1
|
||||
user = mayan
|
||||
|
||||
[program:mayan-worker-ocr]
|
||||
autorestart = false
|
||||
autostart = true
|
||||
command = nice -n 19 python /usr/local/lib/python2.7/dist-packages/mayan/bin/mayan-edms.py celery --settings=mayan.settings.production worker -Ofair -l ERROR -Q parsing,ocr -n mayan-worker-slow.%%h --concurrency=1
|
||||
directory = /usr/local/lib/python2.7/dist-packages/mayan/
|
||||
killasgroup = true
|
||||
numprocs = 1
|
||||
priority = 998
|
||||
startsecs = 10
|
||||
stderr_logfile = /dev/fd/2
|
||||
stderr_logfile_maxbytes = 0
|
||||
stdout_logfile = /dev/fd/1
|
||||
stdout_logfile_maxbytes = 0
|
||||
stopwaitsecs = 1
|
||||
user = mayan
|
||||
1
docker/version
Executable file
1
docker/version
Executable file
@@ -0,0 +1 @@
|
||||
3.0b1
|
||||
@@ -1,2 +0,0 @@
|
||||
User files such as: document_storage, image_cache, db.sqlite3 and gpg_home go here
|
||||
|
||||
Reference in New Issue
Block a user