Skip to content

Commit

Permalink
build: Have docker scripts for starting up the deephaven-plugins repo…
Browse files Browse the repository at this point in the history
… with the latest (#143)

- Docker scripts to automatically start up containers to build all of
the JS/python, start up the deephaven-core container, install all the
plugins appropriately, and serve them up
- Use by running `npm run docker`, then going to http://localhost:10000
- Useful to test latest deephaven-plugins without having to
build/configure deephaven-core locally (@dsmmcken)
- Will also be useful when adding e2e tests to this repo, as CI can use
the docker script to start up a box before executing the e2e tests
(@ethanalvizo)
- Regenerated the package-lock.json. Was getting errors with it in the
docker container for some reason, seems to be somewhat corrupted.
  • Loading branch information
mofojed authored Dec 12, 2023
1 parent 12802d4 commit 40edd32
Show file tree
Hide file tree
Showing 10 changed files with 21,566 additions and 7,859 deletions.
44 changes: 44 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# dependencies
**/node_modules/

# testing
/coverage
jest*
__mocks__/
.github/

# venvs
**/.venv/

# production
**/build/
**/dist/
**/*.egg-info/

# misc
.git/
.vscode/
.DS_Store
**/.env*.local
.project
.settings/
.eslintcache
.stylelintcache
lerna-debug.log
Lerna-Profile-*.json

npm-debug.log*

**/tsconfig.tsbuildinfo
test-results/
playwright-report/
playwright/.cache/
**/CHANGELOG.md

# Ignore Dockerfile as well, since we don't need to copy that into the snapshot container
**/Dockerfile
.dockerignore
**/.gitignore

# Tests are copied to the docker container, as it modifies them
tests/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ tsconfig.tsbuildinfo

# Ignore the test reports
junit.xml

# Allow for local overrides of docker-compose.yml. https://docs.docker.com/compose/multiple-compose-files/merge/
docker-compose.override.yml
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# syntax=docker/dockerfile:1
# Dockerfile for starting up a deephaven-server with these latest plugins built and installed
# Expects to be run from the root of the deephaven-plugins repo
# First lets build and install the JS plugins
FROM node:18 AS base
WORKDIR /work/

# Update packages list and install python python
RUN set -eux; \
apt-get update; \
apt-get install python3-pip --yes;

# This is a workaround for copying all package.json files w/ directory structure
# without needing to list every file as a COPY command
# The copy --from=copy-plugins command will be a cache hit if the package.json files didn't change
FROM alpine AS copy-plugins
WORKDIR /work/
COPY plugins /tmp/deephaven-plugins
COPY package.json package-lock.json requirements.txt ./
# cd first so the cp doesn't include /tmp/deephaven-plugins in the paths
RUN cd /tmp/deephaven-plugins && cp --parents ./*/src/js/package.json /work/ && cp --parents ./*/setup.* /work/

FROM base as build
WORKDIR /work/
COPY --from=copy-plugins /work/ .

# Install the python requirements
RUN pip3 install -r requirements.txt --break-system-packages

# Install the npm packages
RUN npm ci

COPY babel.config.js lerna.json nx.json tsconfig.json ./

# Copy the deephaven-plugins source files to the docker image
# We do this last because the source files are the most likely to change
# This requires the Dockerfile to be built in the context of the root of the deephaven-plugins repository
# https://stackoverflow.com/a/34300129
COPY plugins plugins

# Build the JS
RUN npm run build

# Now build the Python bundles
RUN find ./plugins -maxdepth 1 -mindepth 1 -type d -exec python3 -m build --wheel {} \;

FROM ghcr.io/deephaven/server:edge
COPY --link --from=build /work/ /opt/deephaven/config/plugins/
RUN pip install /opt/deephaven/config/plugins/plugins/*/dist/*.whl

COPY --link docker/config/deephaven.prop /opt/deephaven/config/deephaven.prop

# We copy our data directory in from the data container in case we're publishing the image
# However, you can mount a volume to override this in the docker-compose.override.yml
COPY --link docker/data /data
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,19 @@ START_OPTS="-Ddeephaven.jsPlugins.@deephaven/js-plugin-matplotlib=<deephaven-plu
```

The Deephaven IDE can then be opened at http://localhost:10000/ide/, with your plugins ready to use.

### Running with Docker container

Instead of running deephaven-core from source and building all plugins yourself, you can run a docker container that automatically builds the plugins and installs them in an instance of deephaven-core, then serving it up at http://localhost:10000. JS Plugins are specified in [./docker/config/deephaven.prop](./docker/config/deephaven.prop) as to which ones are loaded. Run `npm run docker` to start up the docker container, or just run `docker compose up --build` if you do not have `npm` installed. It will open at port 10000 by default, and use the demo data from [./docker/data](./docker/data) as the data folder.
If you wish to change the port it opens on, you can specify the `DEEPHAVEN_PORT` environment variable. For example, to open on port 11000, you would run `DEEPHAVEN_PORT=11000 npm run docker`.
If you wish to customize what data is used for the docker container, you can create a [docker-compose.override.yml file](https://docs.docker.com/compose/multiple-compose-files/merge/) to override the default values. For example, if you want to use `/path/to/mydata/` as the data folder instead of the default, you would add a `volumes` property to your docker-compose.override.yml:

```yml
version: '3'

services:
deephaven-plugins:
volumes:
# Specifying a data volume here will override the default data folder, and you will not be able to access the default data files (such as the demo data)
- /path/to/mydata/:/data
```
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3'

services:
deephaven-plugins:
build:
dockerfile: ./Dockerfile
pull: true
ports:
- '${DEEPHAVEN_PORT:-10000}:10000'
10 changes: 10 additions & 0 deletions docker/config/deephaven.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
includefiles=dh-defaults.prop

deephaven.console.type=python

# Add all plugins that you want installed here
deephaven.jsPlugins.@deephaven/js-plugin-ui=/opt/deephaven/config/plugins/plugins/ui/src/js
deephaven.jsPlugins.@deephaven/js-plugin-plotly-express=/opt/deephaven/config/plugins/plugins/plotly-express/src/js

# Anonymous authentication so we don't need to put in a password
AuthHandlers=io.deephaven.auth.AnonymousAuthenticationHandler
1 change: 1 addition & 0 deletions docker/data/storage/layouts/demo-layout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"filterSets":[],"layoutConfig":[{"type":"row","height":100,"isClosable":true,"isFocusOnShow":true,"reorderEnabled":true,"title":"","content":[{"type":"stack","isClosable":true,"isFocusOnShow":true,"reorderEnabled":true,"title":"","width":47.87172011661808,"activeItemIndex":0,"content":[{"type":"react-component","component":"ConsolePanel","title":"Console","isClosable":false,"id":"EwmgpXQqE","props":{"metadata":{},"panelState":{"consoleSettings":{},"itemIds":[]}},"componentName":"lm-react-component","isFocusOnShow":true,"reorderEnabled":true,"componentState":null},{"type":"react-component","component":"LogPanel","title":"Log","isClosable":false,"id":"l9Ll30LIS8","props":{"metadata":{}},"componentName":"lm-react-component","isFocusOnShow":true,"reorderEnabled":true,"componentState":null}]},{"type":"stack","width":52.12827988338192,"isClosable":true,"isFocusOnShow":true,"reorderEnabled":true,"title":"","activeItemIndex":2,"content":[{"type":"react-component","component":"CommandHistoryPanel","title":"Command History","isClosable":false,"id":"qfsNtUkwNG","props":{"metadata":{},"panelState":{}},"componentName":"lm-react-component","isFocusOnShow":true,"reorderEnabled":true,"componentState":null},{"type":"react-component","component":"FileExplorerPanel","title":"File Explorer","isClosable":false,"id":"x0ISsm_Crj","props":{"metadata":{}},"componentName":"lm-react-component","isFocusOnShow":true,"reorderEnabled":true,"componentState":null},{"type":"react-component","component":"NotebookPanel","isFocusOnShow":false,"props":{"metadata":{"id":"KfJJtrr0G"},"panelState":{"settings":{"language":""},"fileMetadata":{"id":"/DEMO.md","itemName":"/DEMO.md"},"isPreview":true}},"title":"DEMO.md","id":"KfJJtrr0G","componentName":"lm-react-component","isClosable":true,"reorderEnabled":true,"componentState":null}]}]}],"links":[],"version":2}
Loading

0 comments on commit 40edd32

Please sign in to comment.