diff --git a/Dockerfile b/Dockerfile index 55506fd07..c4ab7d82b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,66 +1,66 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2015, 2016 CERN. # # Invenio is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # Invenio is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Invenio; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307, USA. # # In applying this license, CERN does not # waive the privileges and immunities granted to it by virtue of its status # as an Intergovernmental Organization or submit itself to any jurisdiction. # Use Python-2.7: FROM python:2.7-slim # Add Invenio sources to `code` and work there: WORKDIR /code ADD . /code # Install Invenio web node pre-requisites: RUN /code/scripts/provision-web.sh # Run container as user `invenio` with UID `1000`, which should match # current host user in most situations: RUN adduser --uid 1000 --disabled-password --gecos '' invenio && \ chown -R invenio:invenio /code USER invenio # Configure Invenio instance: ENV INVENIO_WEB_HOST=127.0.0.1 ENV INVENIO_WEB_INSTANCE=invenio3 ENV INVENIO_WEB_VENV=invenio3 ENV INVENIO_USER_EMAIL=info@inveniosoftware.org ENV INVENIO_USER_PASS=uspass123 ENV INVENIO_POSTGRESQL_HOST=postgresql ENV INVENIO_POSTGRESQL_DBNAME=invenio3 ENV INVENIO_POSTGRESQL_DBUSER=invenio3 ENV INVENIO_POSTGRESQL_DBPASS=dbpass123 ENV INVENIO_REDIS_HOST=redis ENV INVENIO_ELASTICSEARCH_HOST=elasticsearch ENV INVENIO_RABBITMQ_HOST=rabbitmq ENV INVENIO_WORKER_HOST=127.0.0.1 # Create Invenio instance: RUN /code/scripts/create-instance.sh --devel # Make given VENV default: ENV PATH=/home/invenio/.virtualenvs/invenio3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ENV VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python RUN echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc RUN echo "workon invenio3" >> ~/.bashrc # Start the Invenio application: -CMD ["/bin/bash", "-c", "invenio3 --debug run -h 0.0.0.0"] +CMD ["/bin/bash", "-c", "invenio3 run -h 0.0.0.0"] diff --git a/MANIFEST.in b/MANIFEST.in index 6d329e176..3dc9f0c59 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,64 +1,66 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2015, 2016 CERN. # # Invenio is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # Invenio is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Invenio; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307, USA. # # In applying this license, CERN does not # waive the privileges and immunities granted to it by virtue of its status # as an Intergovernmental Organization or submit itself to any jurisdiction. # TODO: Generate this manifest file by running the following commands: # # git init # git add -A # pip install -e .[all] # check-manifest -u # Check manifest will not automatically add these two files: include .dockerignore include .editorconfig include .inveniorc include Vagrantfile include docker-compose.yml include Dockerfile +include nginx/Dockerfile include *.rst include *.sh include *.txt include ABOUT-NLS include babel.ini include COPYING include LICENSE include pytest.ini include THANKS recursive-include docs *.bat recursive-include docs *.css recursive-include docs *.gif recursive-include docs *.jpeg recursive-include docs *.jpg recursive-include docs *.plantuml recursive-include docs *.png recursive-include docs *.py recursive-include docs *.rst recursive-include docs *.svg recursive-include docs Makefile recursive-include misc *.py recursive-include misc *.rst recursive-include scripts *.sh -recursive-include tests *.py \ No newline at end of file +recursive-include tests *.py +recursive-include nginx *.conf \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6f6a7e77b..8156b9c9e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,78 +1,101 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2015, 2016 CERN. # # Invenio is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # Invenio is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Invenio; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307, USA. # # In applying this license, CERN does not # waive the privileges and immunities granted to it by virtue of its status # as an Intergovernmental Organization or submit itself to any jurisdiction. web: + restart: "always" build: . - command: /bin/bash -c "invenio3 --debug run -h 0.0.0.0" + command: /bin/bash -c "invenio3 run -h 0.0.0.0" environment: - PATH=/home/invenio/.virtualenvs/invenio3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python - INVENIO_WEB_HOST=127.0.0.1 - INVENIO_WEB_INSTANCE=invenio3 - INVENIO_WEB_VENV=invenio3 - INVENIO_USER_EMAIL=info@inveniosoftware.org - INVENIO_USER_PASS=uspass123 - INVENIO_POSTGRESQL_HOST=postgresql - INVENIO_POSTGRESQL_DBNAME=invenio3 - INVENIO_POSTGRESQL_DBUSER=invenio3 - INVENIO_POSTGRESQL_DBPASS=dbpass123 - INVENIO_REDIS_HOST=redis - INVENIO_ELASTICSEARCH_HOST=elasticsearch - INVENIO_RABBITMQ_HOST=rabbitmq - INVENIO_WORKER_HOST=127.0.0.1 - volumes: - - .:/code + volumes_from: + - static links: - postgresql - redis - elasticsearch - rabbitmq ports: - "5000:5000" postgresql: + restart: "always" image: postgres environment: - POSTGRES_USER=invenio3 - POSTGRES_DB=invenio3 - POSTGRES_PASSWORD=dbpass123 ports: - "25432:5432" redis: + restart: "always" image: redis ports: - "26379:6379" elasticsearch: + restart: "always" image: elasticsearch ports: - "29200:9200" - "29300:9300" rabbitmq: + restart: "always" image: rabbitmq ports: - "24369:4369" - "45672:25672" + +nginx: + restart: "always" + build: ./nginx + ports: + - "80:80" + volumes_from: + - static + links: + - web + +static: + restart: "no" + build: . + volumes: + - /home/invenio/.virtualenvs/invenio3/var/invenio3-instance/static + - /home/invenio/.virtualenvs/invenio3/src/invenio-theme/invenio_theme/static + user: invenio diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 000000000..dc4fd7536 --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# +# This file is part of Invenio. +# Copyright (C) 2016 CERN. +# +# Invenio is free software; you can redistribute it +# and/or modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# Invenio is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Invenio; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307, USA. +# +# In applying this license, CERN does not +# waive the privileges and immunities granted to it by virtue of its status +# as an Intergovernmental Organization or submit itself to any jurisdiction. + +FROM nginx +RUN rm /etc/nginx/conf.d/default.conf +ADD invenio3.conf /etc/nginx/conf.d/ diff --git a/nginx/invenio3.conf b/nginx/invenio3.conf new file mode 100644 index 000000000..735503b15 --- /dev/null +++ b/nginx/invenio3.conf @@ -0,0 +1,23 @@ +server { + + listen 80; + server_name localhost; + charset utf-8; + + location /static { + root /home/invenio/.virtualenvs/invenio3/var/invenio3-instance; + } + + location / { + proxy_pass http://web:5000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + +} \ No newline at end of file diff --git a/scripts/start-instance.sh b/scripts/start-instance.sh index 96f4e97d1..278a2faa7 100755 --- a/scripts/start-instance.sh +++ b/scripts/start-instance.sh @@ -1,104 +1,104 @@ #!/usr/bin/env bash # # This file is part of Invenio. # Copyright (C) 2015, 2016 CERN. # # Invenio is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # Invenio is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Invenio; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307, USA. # # In applying this license, CERN does not # waive the privileges and immunities granted to it by virtue of its status # as an Intergovernmental Organization or submit itself to any jurisdiction. # check environment variables: if [ -v ${INVENIO_WEB_HOST} ]; then echo "[ERROR] Please set environment variable INVENIO_WEB_HOST before runnning this script." echo "[ERROR] Example: export INVENIO_WEB_HOST=192.168.50.10" exit 1 fi if [ -v ${INVENIO_WEB_INSTANCE} ]; then echo "[ERROR] Please set environment variable INVENIO_WEB_INSTANCE before runnning this script." echo "[ERROR] Example: export INVENIO_WEB_INSTANCE=invenio3" exit 1 fi if [ -v ${INVENIO_WEB_VENV} ]; then echo "[ERROR] Please set environment variable INVENIO_WEB_VENV before runnning this script." echo "[ERROR] Example: export INVENIO_WEB_VENV=invenio3" exit 1 fi if [ -v ${INVENIO_USER_EMAIL} ]; then echo "[ERROR] Please set environment variable INVENIO_USER_EMAIL before runnning this script." echo "[ERROR] Example: export INVENIO_USER_EMAIL=info@inveniosoftware.org" exit 1 fi if [ -v ${INVENIO_USER_PASS} ]; then echo "[ERROR] Please set environment variable INVENIO_USER_PASS before runnning this script." echo "[ERROR] Example: export INVENIO_USER_PASS=uspass123" exit 1 fi if [ -v ${INVENIO_POSTGRESQL_HOST} ]; then echo "[ERROR] Please set environment variable INVENIO_POSTGRESQL_HOST before runnning this script." echo "[ERROR] Example: export INVENIO_POSTGRESQL_HOST=192.168.50.11" exit 1 fi if [ -v ${INVENIO_POSTGRESQL_DBNAME} ]; then echo "[ERROR] Please set environment variable INVENIO_POSTGRESQL_DBNAME before runnning this script." echo "[ERROR] Example: INVENIO_POSTGRESQL_DBNAME=invenio3" exit 1 fi if [ -v ${INVENIO_POSTGRESQL_DBUSER} ]; then echo "[ERROR] Please set environment variable INVENIO_POSTGRESQL_DBUSER before runnning this script." echo "[ERROR] Example: INVENIO_POSTGRESQL_DBUSER=invenio3" exit 1 fi if [ -v ${INVENIO_POSTGRESQL_DBPASS} ]; then echo "[ERROR] Please set environment variable INVENIO_POSTGRESQL_DBPASS before runnning this script." echo "[ERROR] Example: INVENIO_POSTGRESQL_DBPASS=dbpass123" exit 1 fi if [ -v ${INVENIO_REDIS_HOST} ]; then echo "[ERROR] Please set environment variable INVENIO_REDIS_HOST before runnning this script." echo "[ERROR] Example: export INVENIO_REDIS_HOST=192.168.50.12" exit 1 fi if [ -v ${INVENIO_ELASTICSEARCH_HOST} ]; then echo "[ERROR] Please set environment variable INVENIO_ELASTICSEARCH_HOST before runnning this script." echo "[ERROR] Example: export INVENIO_ELASTICSEARCH_HOST=192.168.50.13" exit 1 fi if [ -v ${INVENIO_RABBITMQ_HOST} ]; then echo "[ERROR] Please set environment variable INVENIO_RABBITMQ_HOST before runnning this script." echo "[ERROR] Example: export INVENIO_RABBITMQ_HOST=192.168.50.14" exit 1 fi if [ -v ${INVENIO_WORKER_HOST} ]; then echo "[ERROR] Please set environment variable INVENIO_WORKER_HOST before runnning this script." echo "[ERROR] Example: export INVENIO_WORKER_HOST=192.168.50.15" exit 1 fi # load virtualenvrapper: source $(which virtualenvwrapper.sh) # switch virtual environment: workon ${INVENIO_WEB_VENV} # quit on errors and unbound symbols: set -o errexit set -o nounset # sphinxdoc-start-application-begin -${INVENIO_WEB_INSTANCE} --debug run -h 0.0.0.0 & +${INVENIO_WEB_INSTANCE} run -h 0.0.0.0 & # sphinxdoc-start-application-end