Skip to content

Commit edefe33

Browse files
authored
Merge branch 'master' into helm
2 parents fe8157f + 0f92dc5 commit edefe33

File tree

10 files changed

+66
-69
lines changed

10 files changed

+66
-69
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ build
1313
dist
1414
node_modules
1515
screenshots
16+
nbviewer/git_info.json
1617
# ignore downloaded notebook sources
1718
notebook-*
1819
.eggs/

Dockerfile

Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,49 @@
11
# Define a builder image
2-
FROM debian:jessie as builder
2+
FROM python:3.7-buster as builder
33

44
ENV DEBIAN_FRONTEND=noninteractive
55
ENV LANG=C.UTF-8
6-
RUN apt-get update && \
7-
apt-get install -yq --no-install-recommends \
8-
curl \
9-
bzip2 \
10-
ca-certificates
11-
12-
ENV MINICONDA_VERSION 4.7.10
13-
ENV PATH=/opt/conda/bin:$PATH
14-
RUN cd /tmp && \
15-
curl -sSL https://repo.continuum.io/miniconda/Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh -o /tmp/miniconda.sh && \
16-
echo "1c945f2b3335c7b2b15130b1b2dc5cf4 *miniconda.sh" | md5sum -c - && \
17-
/bin/bash miniconda.sh -f -b -p /opt/conda && \
18-
rm miniconda.sh && \
19-
/opt/conda/bin/conda config --system --prepend channels conda-forge && \
20-
/opt/conda/bin/conda config --system --set auto_update_conda false && \
21-
/opt/conda/bin/conda config --system --set show_channel_urls true && \
22-
/opt/conda/bin/conda install --quiet --yes conda="${MINICONDA_VERSION%.*}.*" && \
23-
/opt/conda/bin/conda update --all --quiet --yes && \
24-
conda clean -tipsy
25-
26-
# NodeJS toolchain
27-
WORKDIR /srv/nbviewer
28-
RUN conda install nodejs git
29-
COPY ./package.json /srv/nbviewer/
30-
RUN npm install .
6+
RUN apt-get update \
7+
&& apt-get install -yq --no-install-recommends \
8+
ca-certificates \
9+
libcurl4-gnutls-dev \
10+
git \
11+
nodejs \
12+
npm
3113

3214
# Python requirements
33-
ADD ./requirements.txt /srv/nbviewer/
34-
RUN conda install --file requirements.txt
15+
COPY ./requirements-dev.txt /srv/nbviewer/
16+
COPY ./requirements.txt /srv/nbviewer/
17+
RUN python3 -mpip install -r /srv/nbviewer/requirements-dev.txt -r /srv/nbviewer/requirements.txt
3518

36-
# Add bower requirements
37-
COPY [ \
38-
"./nbviewer/static/bower.json", \
39-
"./nbviewer/static/.bowerrc", \
40-
"/srv/nbviewer/nbviewer/static/" \
41-
]
42-
43-
# Invoke bower
44-
WORKDIR /srv/nbviewer/nbviewer/static
45-
RUN ../../node_modules/.bin/bower install \
46-
--allow-root \
47-
--config.interactive=false
48-
49-
# Build CSS
5019
WORKDIR /srv/nbviewer
51-
RUN conda install invoke
52-
COPY ./nbviewer/static/less /srv/nbviewer/nbviewer/static/less/
53-
COPY ./tasks.py /srv/nbviewer/
54-
RUN invoke less
55-
56-
# Remove build-only packages so that we can copy a clean conda environment
57-
# to the runtime image. Need to leave git intact: it's a runtime dep!
58-
RUN conda remove -y nodejs invoke && \
59-
conda clean -ay && \
60-
rm -rf /opt/conda/pkgs /opt/conda/conda-meta && \
61-
rm -rf /srv/nbviewer/node_modules /srv/nbviewer/notebook-*
6220

63-
# Copy source tree in and only keep .git so that the version
64-
# web resource works properly
21+
# Copy source tree in
6522
COPY . /srv/nbviewer
23+
RUN python3 setup.py build && \
24+
python3 -mpip wheel -vv . -w /wheels
6625

6726
# Now define the runtime image
68-
FROM debian:jessie
27+
FROM python:3.7-slim-buster
28+
LABEL maintainer="Jupyter Project <[email protected]>"
29+
30+
ENV DEBIAN_FRONTEND=noninteractive
31+
ENV LANG=C.UTF-8
6932

70-
COPY --from=builder /opt/conda /opt/conda
71-
COPY --from=builder /srv/nbviewer /srv/nbviewer
33+
RUN apt-get update \
34+
&& apt-get install -yq --no-install-recommends \
35+
ca-certificates \
36+
libcurl4 \
37+
git \
38+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
7239

73-
LABEL maintainer="Jupyter Project <[email protected]>"
40+
41+
COPY --from=builder /wheels /wheels
42+
RUN python3 -mpip install --no-cache /wheels/*
7443

7544
# To change the number of threads use
7645
# docker run -d -e NBVIEWER_THREADS=4 -p 80:8080 nbviewer
7746
ENV NBVIEWER_THREADS 2
78-
ENV PATH=/opt/conda/bin:$PATH
7947
WORKDIR /srv/nbviewer
8048
EXPOSE 8080
8149
USER nobody

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
include versioneer.py
22
include nbviewer/_version.py
3-
include requirements.txt
3+
include requirements.txt
4+
include nbviewer/git_info.json

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Jupyter Notebook Viewer
22

3-
Jupyter nbviewer is the web application behind [The Jupyter Notebook Viewer](http://nbviewer.ipython.org), which is graciously hosted by [Rackspace](https://developer.rackspace.com/?nbviewer=awesome).
3+
Jupyter nbviewer is the web application behind
4+
[The Jupyter Notebook Viewer](http://nbviewer.jupyter.org),
5+
which is graciously hosted by [OVHCloud](https://ovhcloud.com).
46

57
Run this locally to get most of the features of nbviewer on your own network.
68

nbviewer/templates/faq.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ the [nbconvert documentation](https://nbconvert.readthedocs.io/) for details.
159159

160160
## Where is nbviewer.jupyter.org hosted?
161161

162-
[Rackspace](https://developer.rackspace.com/?nbviewer=awesome) graciously hosts
163-
nbviewer.jupyter.org. Thanks to Rackspace, we are able to provider a public
164-
nbviewer instance as a free service.
162+
[OVHCloud](https://ovhcloud.com) graciously hosts nbviewer.jupyter.org.
163+
Thanks to OVHCloud, we are able to provider a public nbviewer instance as a free service.
164+
165+
nbviewer was generously hosted by Rackspace until March, 2020.
165166

166167
## Can I access nbviewer.jupyter.org over https?
167168

nbviewer/templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
<div class="col-md-4">
132132
<p>
133133
Delivered by <a href="http://www.fastly.com/">Fastly</a>,
134-
Rendered by <a href="https://developer.rackspace.com/?nbviewer=awesome">Rackspace</a>
134+
Rendered by <a href="https://ovhcloud.com">OVHCloud</a>
135135
</p>
136136
<p>
137137
nbviewer GitHub <a href="https://github.com/jupyter/nbviewer">repository</a>.

nbviewer/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import cgi
1414
from contextlib import contextmanager
15+
import json
16+
import os
1517
import re
1618
from subprocess import check_output
1719
import time
@@ -30,6 +32,9 @@
3032
'access_token',
3133
]
3234

35+
HERE = os.path.dirname(__file__)
36+
GIT_INFO_JSON = os.path.join(HERE, 'git_info.json')
37+
3338

3439
class EmptyClass(object):
3540
"""
@@ -193,8 +198,11 @@ def parse_header_links(value):
193198
return links
194199

195200

196-
def git_info(path):
201+
def git_info(path, force_git=False):
197202
"""Return some git info"""
203+
if os.path.exists(GIT_INFO_JSON) and not force_git:
204+
with open(GIT_INFO_JSON, 'r') as f:
205+
return json.load(f)
198206
command = ['git', 'log', '-1', '--format=%H\n%s\n%cD']
199207
sha, msg, date = check_output(command, cwd=path).decode('utf8').splitlines()
200208
return dict(

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ invoke>=0.13.0
33
mock>=1.3.0 # python34 and older versions of mock do not play well together.
44
nose
55
requests
6-
-e .

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def sh(cmd):
2525

2626
def preflight():
2727
log.info("Building LESS")
28+
sh(['invoke', 'git-info'])
2829
sh(['npm', 'install'])
2930
sh(['invoke', 'bower'])
3031
sh(['invoke', 'less'])
@@ -50,7 +51,7 @@ def walk_subpkg(name):
5051

5152
pkg_data = {
5253
"nbviewer": (
53-
['frontpage.json'] +
54+
['frontpage.json', 'git_info.json'] +
5455
walk_subpkg('static') +
5556
walk_subpkg('templates') +
5657
walk_subpkg('providers')

tasks.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from __future__ import print_function
55

6+
import json
67
import os
78
import hashlib
89
import pipes
@@ -151,6 +152,21 @@ def sdist(ctx):
151152
ctx.run('python setup.py sdist')
152153

153154

155+
@invoke.task
156+
def git_info(ctx):
157+
sys.path.insert(0, os.path.join(APP_ROOT, "nbviewer"))
158+
try:
159+
from utils import git_info, GIT_INFO_JSON
160+
info = git_info(APP_ROOT, force_git=True)
161+
except Exception as e:
162+
print("Failed to get git info", e)
163+
return
164+
print("Writing git info to %s" % GIT_INFO_JSON)
165+
with open(GIT_INFO_JSON, "w") as f:
166+
json.dump(info, f)
167+
sys.path.pop(0)
168+
169+
154170
@invoke.task
155171
def release(ctx):
156172
bower(ctx)

0 commit comments

Comments
 (0)