Updated app.py to make sure that images can start notebook servers
Includes an update of conftest.py file to check that the container
is running with jupyter notebook in all the builders.
MODIFY
repo2docker/app.py
repo2docker/app.py
@@ -504,7 +504,7 @@ class Repo2Docker(Application):
client = docker.from_env(version='auto')
if not self.run_cmd:
port = str(self._get_free_port())
-
+ self.port = port
run_cmd = ['jupyter', 'notebook', '--ip', '0.0.0.0',
'--port', port]
ports = {'%s/tcp' % port: port}

MODIFY
tests/conftest.py
tests/conftest.py
@@ -11,6 +11,8 @@ success.
import os
import pipes
import shlex
+import requests
+import time
import pytest
import yaml
@@ -30,7 +32,39 @@ def make_test_func(args):
def test():
app = Repo2Docker()
app.initialize(args)
+ if app.run_cmd:
+ # verify test, run it
app.start()
+ return
+ # no run_cmd given, starting notebook server
+ app.run = False
+ app.start() # This just build the image and does not run it.
+ container = app.start_container()
+ port = app.port
+ # wait a bit for the container to be ready
+ container_url = 'http://localhost:%s/api' % port
+ # give the container a chance to start
+ time.sleep(1)
+ try:
+ # try a few times to connect
+ success = False
+ for i in range(1, 4):
+ container.reload()
+ assert container.status == 'running'
+ try:
+ info = requests.get(container_url).json()
+ except Exception as e:
+ print("Error: %s" % e)
+ time.sleep(i * 3)
+ else:
+ print(info)
+ success = True
+ break
+ assert success, "Notebook never started in %s" % container
+ finally:
+ # stop the container
+ container.stop()
+ app.wait_for_container(container)
return test
@@ -68,6 +102,13 @@ class LocalRepo(pytest.File):
'./verify',
],
)
+ yield Repo2DockerTest(
+ self.fspath.basename, self,
+ args=[
+ '--appendix', 'RUN echo "appendix" > /tmp/appendix',
+ self.fspath.dirname,
+ ],
+ )
class RemoteRepoList(pytest.File):

Updated app.py to make sure that images can start notebook servers

Includes an update of conftest.py file to check that the container
is running with jupyter notebook in all the builders.