diff options
author | clarkzjw <[email protected]> | 2018-01-10 20:45:07 +0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2018-01-10 20:45:07 +0800 |
commit | c008c037facaf632dc9923bb2ecd4c9542c14c9d (patch) | |
tree | 05a612cc3a67f49e3d14138b2f0e062f153295e2 | |
parent | f26f6cd71cb436216ce6993ae640e89bbb26226a (diff) | |
download | blog.jinwei.me-c008c037facaf632dc9923bb2ecd4c9542c14c9d.tar.gz |
+ add Dockerfile
-rw-r--r-- | .dockerignore | 3 | ||||
-rw-r--r-- | Dockerfile | 20 | ||||
-rwxr-xr-x | bootstrap.py | 24 | ||||
-rw-r--r-- | conf.py | 15 | ||||
-rw-r--r-- | requirements.txt | 2 |
5 files changed, 30 insertions, 34 deletions
diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f794bc2 --- /dev/null +++ b/.dockerignore | |||
@@ -0,0 +1,3 @@ | |||
1 | .venv | ||
2 | .idea | ||
3 | _build | ||
@@ -1,6 +1,22 @@ | |||
1 | FROM python:3.6.0 | 1 | FROM python:3.6.0 as builder |
2 | 2 | ||
3 | LABEL maintainer=clarkzjw<[email protected]> | ||
3 | 4 | ||
5 | RUN pip install virtualenv | ||
4 | 6 | ||
5 | FROM nginx | 7 | COPY requirements.txt /app/requirements.txt |
6 | 8 | ||
9 | COPY bootstrap.py /app/bootstrap.py | ||
10 | |||
11 | RUN /app/bootstrap.py | ||
12 | |||
13 | ADD . /app | ||
14 | |||
15 | WORKDIR /app | ||
16 | |||
17 | RUN /bin/bash -c "source /app/.venv/bin/activate && make html" | ||
18 | |||
19 | |||
20 | FROM nginx:alpine | ||
21 | |||
22 | 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 @@ | |||
1 | #!/usr/bin/env python2 | 1 | #!/usr/bin/env python3 |
2 | from __future__ import absolute_import, print_function, unicode_literals | 2 | from __future__ import absolute_import, print_function, unicode_literals |
3 | 3 | ||
4 | import os | 4 | import os |
@@ -16,9 +16,9 @@ def fail(message): | |||
16 | 16 | ||
17 | def has_module(module_name): | 17 | def has_module(module_name): |
18 | try: | 18 | try: |
19 | import imp | 19 | import implib |
20 | imp.find_module(module_name) | 20 | implib.find_module(module_name) |
21 | del imp | 21 | del implib |
22 | return True | 22 | return True |
23 | except ImportError: | 23 | except ImportError: |
24 | return False | 24 | return False |
@@ -69,12 +69,11 @@ pip_bin = os.path.join(env_dir, 'bin', 'pip') | |||
69 | python_bin = os.path.join(env_dir, 'bin', 'python') | 69 | python_bin = os.path.join(env_dir, 'bin', 'python') |
70 | virtualenv_bin = which('virtualenv', throw=False) | 70 | virtualenv_bin = which('virtualenv', throw=False) |
71 | virtualenv_exists = os.path.exists(env_dir) and os.path.isfile(python_bin) | 71 | virtualenv_exists = os.path.exists(env_dir) and os.path.isfile(python_bin) |
72 | sphinx_requirements_filepath = os.path.join( | 72 | sphinx_requirements_filepath = os.path.join(project_dir, 'requirements.txt') |
73 | project_dir, 'requirements.txt') | ||
74 | 73 | ||
75 | 74 | ||
76 | try: | 75 | try: |
77 | import virtualenv # NOQA | 76 | import virtualenv |
78 | except ImportError: | 77 | except ImportError: |
79 | message = ( | 78 | message = ( |
80 | 'Virtualenv is required for this bootstrap to run.\n' | 79 | 'Virtualenv is required for this bootstrap to run.\n' |
@@ -85,7 +84,7 @@ except ImportError: | |||
85 | 84 | ||
86 | 85 | ||
87 | try: | 86 | try: |
88 | import pip # NOQA | 87 | import pip |
89 | except ImportError: | 88 | except ImportError: |
90 | message = ( | 89 | message = ( |
91 | 'pip is required for this bootstrap to run.\n' | 90 | 'pip is required for this bootstrap to run.\n' |
@@ -96,14 +95,6 @@ except ImportError: | |||
96 | 95 | ||
97 | 96 | ||
98 | def main(): | 97 | def main(): |
99 | if not which('entr', throw=False): | ||
100 | message = ( | ||
101 | '\nentr(1) is used in this app as a cross platform file watcher.' | ||
102 | 'You can install it via your package manager on most POSIX ' | ||
103 | 'systems. See the site at http://entrproject.org/\n' | ||
104 | ) | ||
105 | print(message) | ||
106 | |||
107 | if not virtualenv_exists: | 98 | if not virtualenv_exists: |
108 | virtualenv_bin = which('virtualenv', throw=False) | 99 | virtualenv_bin = which('virtualenv', throw=False) |
109 | 100 | ||
@@ -119,5 +110,6 @@ def main(): | |||
119 | if os.path.exists(os.path.join(env_dir, 'build')): | 110 | if os.path.exists(os.path.join(env_dir, 'build')): |
120 | os.removedirs(os.path.join(env_dir, 'build')) | 111 | os.removedirs(os.path.join(env_dir, 'build')) |
121 | 112 | ||
113 | |||
122 | if __name__ == '__main__': | 114 | if __name__ == '__main__': |
123 | main() | 115 | main() |
@@ -86,18 +86,3 @@ texinfo_documents = [ | |||
86 | ('index', 'confuciangentlemansclub', u'confucian gentleman\'s club', 'confuciangentlemansclub', 'Scribe.', | 86 | ('index', 'confuciangentlemansclub', u'confucian gentleman\'s club', 'confuciangentlemansclub', 'Scribe.', |
87 | 'Miscellaneous'), | 87 | 'Miscellaneous'), |
88 | ] | 88 | ] |
89 | |||
90 | intersphinx_mapping = { | ||
91 | 'https://docs.python.org/2/': None, | ||
92 | 'sphinx': ('https://sphinx.readthedocs.io/en/latest/', None), | ||
93 | 'django': ( | ||
94 | 'https://docs.djangoproject.com/en/1.11/', | ||
95 | 'https://docs.djangoproject.com/en/1.11/_objects/' | ||
96 | ), | ||
97 | 'flask': ('http://flask.pocoo.org/docs/', None), | ||
98 | 'flask-sqlalchemy': ('http://flask-sqlalchemy.pocoo.org/2.2/', None), | ||
99 | 'werkzeug': ('http://werkzeug.pocoo.org/docs/0.12/', None), | ||
100 | 'jinja': ('http://jinja.pocoo.org/docs/dev', None), | ||
101 | 'sqlalchemy': ('http://docs.sqlalchemy.org/en/latest/', None), | ||
102 | 'uwsgi': ('https://uwsgi-docs.readthedocs.io/en/latest/', None), | ||
103 | } | ||
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 | |||
13 | requests==2.18.4 | 13 | requests==2.18.4 |
14 | six==1.11.0 | 14 | six==1.11.0 |
15 | snowballstemmer==1.2.1 | 15 | snowballstemmer==1.2.1 |
16 | Sphinx==1.6.6 | 16 | Sphinx |
17 | sphinxcontrib-websupport==1.0.1 | 17 | sphinxcontrib-websupport==1.0.1 |
18 | urllib3==1.22 | 18 | urllib3==1.22 |