Skip to content

Commit d4a43a1

Browse files
[docker] add docker example with trace server and sample traces, suitable for demos
Signed-off-by: Marc Dumais <[email protected]> generalize the demo - make it reusable for both tate and tave images Signed-off-by: Marc Dumais <[email protected]>
1 parent 5b524c0 commit d4a43a1

File tree

6 files changed

+121
-5
lines changed

6 files changed

+121
-5
lines changed

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ If you think or suspect that you have discovered a new security vulnerability in
44

55
Instead, please report any potential vulnerability to the Eclipse Foundation [Security Team][security]. Make sure to provide a concise description of the issue, a CWE, and other supporting information.
66

7-
[policy]: https://www.eclipse.org/security/policy.php
7+
[policy]: https://www.eclipse.org/security/policy/
88
[security]: https://www.eclipse.org/security

docker/Dockerfile-demo

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# How to use: pass as an "app" build argument, the name of the base
2+
# trace-viewer image to extend. e.g.:
3+
# $ docker build --build-arg app=tv-tate --network=host . --build-arg RESOURCES=theia-app-demo -t tv-tate-demo -f Dockerfile-demo
4+
#
5+
# Layout of the resulting demo image:
6+
#
7+
# trace viewer application (unchanged): /app/tv
8+
# Trace Server folder: /app/trace-compass-server
9+
# Trace server executable: /app/trace-compass-server/tracecompass-server
10+
# Tutorial traces folder: : /workspaces/TraceCompassTutorialTraces/
11+
# Default workspace: /workspaces/TraceCompassTutorialTraces/
12+
13+
ARG app
14+
15+
FROM ${app}
16+
ARG RESOURCES
17+
18+
# needed by the trace server
19+
RUN apt-get update && apt-get install -y \
20+
openjdk-17-jdk \
21+
curl \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
WORKDIR /workspaces
25+
# contains scripts entries to download trace server and sample traces
26+
COPY package.json /workspaces
27+
RUN yarn download:sample-traces
28+
RUN yarn download:server && mv trace-compass-server /app/
29+
# not needed anymore
30+
RUN rm package.json
31+
32+
COPY ${RESOURCES}/docker-entrypoint-w-server.sh /usr/local/bin
33+
WORKDIR /app/tv
34+
35+
EXPOSE 4000
36+
ENTRYPOINT ["docker-entrypoint-w-server.sh"]

docker/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ Each application has a `DockerFile` in this folder and its resources in a sub-fo
66

77
- `DockerFile-tate, resources folder: theia-app-theia-ext/`: Dockerfile and resourced needed to build a Trace Viewer Appliance, using a Theia application that includes the _Theia Trace Viewer_ _(Theia) extension_, installed [from npm][npm package].
88
- `DockerFile-tave, resources folder: theia-app-vscode-ext/`: Dockerfile and resources needed to build a Trace Viewer Appliance, using a Theia application that includes the _Trace Viewer for VSCode_ _(vsix) extension_, installed [from the open vsx public registry][vsix package]
9+
- `Dockerfile-demo, resources folder: theia-app-demo/`: Dockerfile that extends one of the Theia-based docker image (tate, tave) and makes it "demo-ready" by adding the Eclipse Trace Compass trace server, a set of sample traces and configuring the traces folder as the starting workspace. See corresponding [README](theia-app-demo/README.md) for more details.
910

1011
Note:
1112

12-
- the images will contain exclusively the trace viewer front-end. If you want to run a complete _trace viewer_ application, you will need a service running the trace-server (not included here)
13+
- the `-demo` images are meant to be "up-and-running" quickly and contain a trace server and some Tutorial traces. For some quick tests or a demo, this is perfect, but maybe not suitable for general use, where you probably want to view your own traces.
14+
- the other images contain exclusively the trace viewer front-end. If you want to run a complete _trace viewer_ application, you will need a service running the trace-server (not included here)
1315
- see section "Docker tips and tricks" if you are relatively new to Docker and want to learn about some potential alternatives or refinements about some of the commands in this document.
1416

1517
## Quickly Build/Run the example Docker images
@@ -126,7 +128,7 @@ $ yarn && yarn build
126128
$ yarn && yarn build:prod
127129
```
128130

129-
If after the build, it turns-out that `yarn.lock` has been modified, the new version needs to be upstreamed as part of the PR that changed the Theia application.
131+
If after the build, it turns-out that `yarn.lock` has been modified, the new version needs to be upstreamed as part of the PR that changed the Theia application, so that the applications built as part of the images will use the same dependencies/versions.
130132

131133
## Docker tips and tricks
132134

@@ -193,4 +195,4 @@ Using "--network host" as part of "docker run [...]": This configures the Docker
193195
But be aware that this may have security implications in some contexts.
194196

195197
[npm package]: https://www.npmjs.com/package/theia-traceviewer
196-
[vsix package]: https://open-vsx.org/extension/eclipse-cdt/vscode-trace-extension
198+
[vsix package]: https://open-vsx.org/extension/eclipse-cdt/vscode-trace-extension

docker/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@
1515
"tave": "yarn --cwd theia-app-vscode-ext",
1616
"build:docker": "yarn build:docker:tate && yarn build:docker:tave",
1717
"build:docker:tate": "docker build --no-cache --network=host . --build-arg RESOURCES=theia-app-theia-ext -t tv-tate -f Dockerfile-tate",
18+
"build:docker:tate-demo": "docker build --build-arg app=tv-tate --no-cache --network=host . --build-arg RESOURCES=theia-app-demo -t tv-tate-demo -f Dockerfile-demo",
19+
"build:docker:tave-demo": "docker build --build-arg app=tv-tave --no-cache --network=host . --build-arg RESOURCES=theia-app-demo -t tv-tave-demo -f Dockerfile-demo",
1820
"build:docker:tave": "docker build --no-cache --network=host . --build-arg RESOURCES=theia-app-vscode-ext -t tv-tave -f Dockerfile-tave",
1921
"run:docker:tate": "docker run --rm --name tv-tate-1 --network host tv-tate",
20-
"run:docker:tave": "docker run --rm --name tv-tave-1 --network host tv-tave"
22+
"run:docker:tate-demo": "docker run --rm --name tv-tate-demo-1 tv-tate-demo",
23+
"run:docker:tave": "docker run --rm --name tv-tave-1 --network host tv-tave",
24+
"run:docker:tave-demo": "docker run --network host --rm --name tv-tave-demo-1 tv-tave-demo",
25+
"download:sample-traces": "curl -o TraceCompassTutorialTraces.tgz https://raw.githubusercontent.com/tuxology/tracevizlab/master/labs/TraceCompassTutorialTraces.tgz; tar -xf TraceCompassTutorialTraces.tgz; rm TraceCompassTutorialTraces.tgz",
26+
"download:server": "curl -o trace-compass-server.tar.gz https://download.eclipse.org/tracecompass.incubator/trace-server/rcp/trace-compass-server-latest-linux.gtk.x86_64.tar.gz; tar -xf trace-compass-server.tar.gz; rm trace-compass-server.tar.gz",
27+
"start:server": "./trace-compass-server/tracecompass-server"
2128
},
2229
"engines": {
2330
},

docker/theia-app-demo/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Resources for the "theia-app-demo" Example docker image
2+
3+
This folder contains the resources, needed to create a "demo" Docker image, based on one of the Theia app images. The demo image includes the necessary extras to easity perform a quick demo or immediately play with the trace viewer: the Eclipse Trace Compass Trace Server and a selection of Tutorial traces.
4+
5+
## Build the demo images
6+
7+
After connecting to either the tate or tave application using a browser, following the instructions below, the app should open with the trace server running and the workspace already selected, containing the tutorial traces, ready to use.
8+
9+
Run the following commands from the parent folder (\<repo root\>/docker):
10+
11+
```bash
12+
# e.g. make "tate" / "tave" demo image(s)
13+
14+
# pre-requisite: the base image(s) need to be already built locally.
15+
# If not, or it they are not up-to-date, start by (re)building them:
16+
yarn build:docker:tate
17+
yarn build:docker:tave
18+
19+
# make the demo image(s) that extend the base image(s)
20+
yarn build:docker:tate-demo
21+
yarn build:docker:tave-demo
22+
```
23+
24+
## Run the demo images
25+
26+
### tate-demo (isolated docker network)
27+
28+
note: since the isolated docker network is used, you may start several containers from the tate-demo image and each one will have its own, indepandant trace server.
29+
30+
Run the following commands from the parent folder (\<repo root\>/docker):
31+
32+
```bash
33+
# start the demo image
34+
yarn run:docker:tate-demo
35+
36+
# using the start script above, the image is deployed isolated
37+
# find its IP address:
38+
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' tv-tate-demo-1
39+
100.109.0.1
40+
41+
# connect to it (replace with the ip address you obtained in the
42+
# previous step):
43+
firefox 100.109.0.1:4000
44+
```
45+
46+
### tave-demo (host network)
47+
48+
The trace viewer contained in the "tave" image uses vscode webviews. For security reasons, these webviews, by default, only work with SSL (HTTPS) and some extra network setup \[*\]. There is however an exception made for running the app on the localhost network, that's considered "safe" by default. It's beyond the scope of this guide to go into these details, so we will provide instructions to run that image using the host network, which should work OOTB locally and still be safe.
49+
50+
\[*\]: for more info start here:
51+
https://github.com/eclipse-theia/theia/blob/86267992e133b3ee59508d4e2afbcfc6e384d61c/packages/plugin-ext/README.md
52+
53+
Note: because the image's trace server uses the host's network, it might interfere or be interfered-with, by a trace server running locally on the host or in another container running the same image. To avoid issues, kill any trace server running locally on the host before starting this demo image and kill the container before starting a local trace server.
54+
55+
Run the following commands from the parent folder (\<repo root\>/docker):
56+
57+
```bash
58+
# start the demo image
59+
yarn run:docker:tave-demo
60+
61+
# ***tave-demo***:
62+
# using the start script above, the image is deployed using the
63+
# docker host network.
64+
firefox localhost:4000
65+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
# start trace server
3+
/app/trace-compass-server/tracecompass-server &
4+
# @theia/cli not installed, so start the app directly.
5+
# Use Tutorial traces folder as workspace for easy access to traces
6+
node ./src-gen/backend/main.js --hostname 0.0.0.0 --port 4000 --plugins=local-dir:plugins /workspaces/TraceCompassTutorialTraces/

0 commit comments

Comments
 (0)