From c008c037facaf632dc9923bb2ecd4c9542c14c9d Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Wed, 10 Jan 2018 20:45:07 +0800 Subject: + add Dockerfile --- .dockerignore | 3 +++ Dockerfile | 20 ++++++++++++++++++-- bootstrap.py | 24 ++++++++---------------- conf.py | 15 --------------- requirements.txt | 2 +- 5 files changed, 30 insertions(+), 34 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f794bc2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.venv +.idea +_build diff --git a/Dockerfile b/Dockerfile index 49de25f..985f527 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,22 @@ -FROM python:3.6.0 +FROM python:3.6.0 as builder +LABEL maintainer=clarkzjw +RUN pip install virtualenv -FROM nginx +COPY requirements.txt /app/requirements.txt +COPY bootstrap.py /app/bootstrap.py + +RUN /app/bootstrap.py + +ADD . /app + +WORKDIR /app + +RUN /bin/bash -c "source /app/.venv/bin/activate && make html" + + +FROM nginx:alpine + +COPY --from=builder /app/_build/html /usr/share/nginx/html diff --git a/bootstrap.py b/bootstrap.py index 80d9048..0c07b9d 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 from __future__ import absolute_import, print_function, unicode_literals import os @@ -16,9 +16,9 @@ def fail(message): def has_module(module_name): try: - import imp - imp.find_module(module_name) - del imp + import implib + implib.find_module(module_name) + del implib return True except ImportError: return False @@ -69,12 +69,11 @@ pip_bin = os.path.join(env_dir, 'bin', 'pip') python_bin = os.path.join(env_dir, 'bin', 'python') virtualenv_bin = which('virtualenv', throw=False) virtualenv_exists = os.path.exists(env_dir) and os.path.isfile(python_bin) -sphinx_requirements_filepath = os.path.join( - project_dir, 'requirements.txt') +sphinx_requirements_filepath = os.path.join(project_dir, 'requirements.txt') try: - import virtualenv # NOQA + import virtualenv except ImportError: message = ( 'Virtualenv is required for this bootstrap to run.\n' @@ -85,7 +84,7 @@ except ImportError: try: - import pip # NOQA + import pip except ImportError: message = ( 'pip is required for this bootstrap to run.\n' @@ -96,14 +95,6 @@ except ImportError: def main(): - if not which('entr', throw=False): - message = ( - '\nentr(1) is used in this app as a cross platform file watcher.' - 'You can install it via your package manager on most POSIX ' - 'systems. See the site at http://entrproject.org/\n' - ) - print(message) - if not virtualenv_exists: virtualenv_bin = which('virtualenv', throw=False) @@ -119,5 +110,6 @@ def main(): if os.path.exists(os.path.join(env_dir, 'build')): os.removedirs(os.path.join(env_dir, 'build')) + if __name__ == '__main__': main() diff --git a/conf.py b/conf.py index 1a7a0c6..31410b0 100644 --- a/conf.py +++ b/conf.py @@ -86,18 +86,3 @@ texinfo_documents = [ ('index', 'confuciangentlemansclub', u'confucian gentleman\'s club', 'confuciangentlemansclub', 'Scribe.', 'Miscellaneous'), ] - -intersphinx_mapping = { - 'https://docs.python.org/2/': None, - 'sphinx': ('https://sphinx.readthedocs.io/en/latest/', None), - 'django': ( - 'https://docs.djangoproject.com/en/1.11/', - 'https://docs.djangoproject.com/en/1.11/_objects/' - ), - 'flask': ('http://flask.pocoo.org/docs/', None), - 'flask-sqlalchemy': ('http://flask-sqlalchemy.pocoo.org/2.2/', None), - 'werkzeug': ('http://werkzeug.pocoo.org/docs/0.12/', None), - 'jinja': ('http://jinja.pocoo.org/docs/dev', None), - 'sqlalchemy': ('http://docs.sqlalchemy.org/en/latest/', None), - 'uwsgi': ('https://uwsgi-docs.readthedocs.io/en/latest/', None), -} diff --git a/requirements.txt b/requirements.txt index 76a6e69..5d75587 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,6 @@ pytz==2017.3 requests==2.18.4 six==1.11.0 snowballstemmer==1.2.1 -Sphinx==1.6.6 +Sphinx sphinxcontrib-websupport==1.0.1 urllib3==1.22 -- cgit v1.2.3