kopia lustrzana https://github.com/jupyterhub/repo2docker
Use a minimal hand-crafted Dockerfile for speed
Instead of installing the normal stack just install the notebook server and launch it to check for the launch URL being output correctly.pull/536/head
rodzic
8d2617479a
commit
27a05d455e
|
@ -5,15 +5,41 @@ import requests
|
||||||
import time
|
import time
|
||||||
from repo2docker.app import Repo2Docker
|
from repo2docker.app import Repo2Docker
|
||||||
|
|
||||||
|
|
||||||
|
# Minimal Dockerfile to make build as fast as possible
|
||||||
|
DOCKER_FILE = """
|
||||||
|
FROM python:3.7-slim
|
||||||
|
# install the notebook package
|
||||||
|
RUN pip install --no-cache --upgrade pip && \
|
||||||
|
pip install --no-cache notebook
|
||||||
|
|
||||||
|
# create user with a home directory
|
||||||
|
ARG NB_USER
|
||||||
|
ARG NB_UID
|
||||||
|
ENV USER ${NB_USER}
|
||||||
|
ENV HOME /home/${NB_USER}
|
||||||
|
|
||||||
|
RUN adduser --disabled-password \
|
||||||
|
--gecos "Default user" \
|
||||||
|
--uid ${NB_UID} \
|
||||||
|
${NB_USER}
|
||||||
|
WORKDIR ${HOME}
|
||||||
|
USER ${NB_USER}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
def test_connect_url(tmpdir):
|
def test_connect_url(tmpdir):
|
||||||
tmpdir.chdir()
|
tmpdir.chdir()
|
||||||
p = tmpdir.join("requirements.txt")
|
p = tmpdir.join("Dockerfile")
|
||||||
p.write("notebook>=5.6.0")
|
p.write(DOCKER_FILE)
|
||||||
|
|
||||||
|
# we set run=False so that we can start the container ourselves and
|
||||||
|
# get a handle to the container, used to inspect the logs
|
||||||
app = Repo2Docker(repo=str(tmpdir), run=False)
|
app = Repo2Docker(repo=str(tmpdir), run=False)
|
||||||
app.initialize()
|
app.initialize()
|
||||||
app.start() # This just build the image and does not run it.
|
app.start()
|
||||||
container = app.start_container()
|
container = app.start_container()
|
||||||
|
|
||||||
container_url = 'http://{}:{}/api'.format(app.hostname, app.port)
|
container_url = 'http://{}:{}/api'.format(app.hostname, app.port)
|
||||||
expected_url = 'http://{}:{}'.format(app.hostname, app.port)
|
expected_url = 'http://{}:{}'.format(app.hostname, app.port)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue