Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Run ungit inside the datalab container #1047

Merged
merged 3 commits into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions containers/datalab/Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ RUN ln -s /datalab/web/static/datalab.css /datalab/nbconvert/datalab.css && \
cd /datalab/web && /tools/node/bin/npm install && \
cd / && \

# Install ungit
/tools/node/bin/npm install -g ungit@0.10.3 && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# Install the support for connecting to a kernel gateway
wget https://github.com/jupyter/kernel_gateway_demos/archive/e653b2bd3ca91ef1af2a13c397766484dcb7b76d.zip && \
unzip -qq e653b2bd3ca91ef1af2a13c397766484dcb7b76d.zip -d kernel_gateway_demos && \
Expand Down
3 changes: 3 additions & 0 deletions containers/datalab/content/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ then
openssl rand -base64 128 > /content/datalab/.config/notary_secret
fi

# Start the ungit server
ungit --port=8083 --no-launchBrowser --forcedLaunchPath=/content/datalab 1> /dev/null &

# Start the DataLab server
FOREVER_CMD="forever --minUptime 1000 --spinSleepTime 1000"
if [ -z "${DATALAB_DEBUG}" ]
Expand Down
10 changes: 9 additions & 1 deletion sources/web/datalab/reverseProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,21 @@ export function getRequestPort(request: http.ServerRequest, path: string): strin
return port;
}

/**
* Check if traffic to this port should be proxied back to the gateway
*/
function shouldProxyPort(port: String) {
// Do not proxy 8083 to gateway, it's open for ungit
return !!process.env.KG_URL && port !== '8083';
}

/**
* Handle request by sending it to the internal http endpoint.
*/
export function handleRequest(request: http.ServerRequest,
response: http.ServerResponse,
port: String) {
if (process.env.KG_URL) {
if (shouldProxyPort(port)) {
proxy.web(request, response, { target: process.env.KG_URL });
}
else {
Expand Down
5 changes: 5 additions & 0 deletions sources/web/datalab/static/appbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<span class="autosave_status"></span>
</span>
<div class="btn-toolbar pull-right">
<div class="btn-group">
<button id="ungitButton" title="Open ungit here" class="toolbar-btn">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment I heard from Nikhil: Should this button (and ungit) only be there when running on a VM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep a consistent experience for all three supported scenarios?

<span class="fa fa-code-fork"></span>
</button>
</div>
<div class="btn-group">
<button class="toolbar-btn" data-toggle="dropdown" title="Help Links">
<span class="fa fa-question-circle"></span>
Expand Down
15 changes: 15 additions & 0 deletions sources/web/datalab/static/datalab.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,21 @@ function initializePage(dialog, saveFn) {
saveFn();
window.location = '/signout?referer=' + encodeURIComponent(window.location);
});
$('#ungitButton').click(function() {
var path = location.pathname;

// Extract the current directory name
if (path.indexOf('/tree') == 0) {
path = path.substr('/tree'.length);
} else if (path.indexOf('/notebooks') == 0) {
path = path.substr('/notebooks'.length);
path = path.substr(0, path.lastIndexOf('/'));
}
path = encodeURIComponent('/content' + path);
prefix = window.location.protocol + '//' + window.location.host;

window.open(prefix + '/_proxy/8083/#/repository?path=' + path);
});
}

// More UI that relies on appbar load
Expand Down
1 change: 1 addition & 0 deletions sources/web/datalab/static/datalab.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ cat /datalab/license.txt
- socket.io [https://www.npmjs.com/package/socket.io]
- tcp-port-used [https://www.npmjs.com/package/tcp-port-used]
- ws [https://www.npmjs.com/package/ws]
- ungit [https://github.com/FredrikNoren/ungit]

## Other Packages:
- curl
Expand Down