Skip to content

Commit 8400a31

Browse files
Re-organize the two docker examples into a monorepo
Also: - update them to use the "previous latest" Theia community release, v1.49.1 - move docker example using the Trace Viewer for VS Code - rename docker examples sub-folders - rename example-package.json to package.json Signed-off-by: Marc Dumais <[email protected]>
1 parent d939f62 commit 8400a31

File tree

18 files changed

+9557
-151
lines changed

18 files changed

+9557
-151
lines changed

.github/workflows/docker-example.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ jobs:
1717
matrix:
1818
os: [ubuntu-latest]
1919
node-version: [18]
20+
params:
21+
- name: "tate"
22+
resources-folder: "theia-app-theia-ext"
23+
- name: "tave"
24+
resources-folder: "theia-app-vscode-ext"
2025

2126
steps:
2227
- uses: actions/checkout@v4
@@ -26,23 +31,25 @@ jobs:
2631
with:
2732
node-version: ${{ matrix.node-version }}
2833

29-
- name: Build example-docker
34+
- name: Build example app
3035
uses: nick-invision/retry@v3
3136
with:
3237
timeout_minutes: 10
3338
retry_wait_seconds: 15
34-
max_attempts: 3
39+
max_attempts: 1
3540
retry_on: error
3641
command: |
37-
cd examples/docker
38-
docker build -t tte .
42+
cd docker
43+
docker build . --build-arg RESOURCES=${{ matrix.params.resources-folder }} -t tv-${{ matrix.params.name }} -f Dockerfile-${{ matrix.params.name }}
3944
on_retry_command: cd ../..
4045

4146
- name: Run docker image
4247
run: |
43-
docker run --init -d -p 0.0.0.0:3000:4000 tte
48+
docker run --init -d -p 0.0.0.0:3000:4000 tv-${{ matrix.params.name }}
4449
4550
- name: Test trace viewer appliance
4651
run: |
4752
yarn --ignore-scripts
48-
yarn test:browser-app
53+
cd docker
54+
yarn --cwd ${{ matrix.params.resources-folder }} test
55+

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
docker/*/gen-webpack.*
2+
docker/*/lib
3+
docker/*/src-gen
4+
node_modules/
5+
docker/*/plugins
6+

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,31 @@
1-
# trace-viewer-examples
2-
Trace viewer example applications and building blocks that can be used in or with them. Each application integrates either the Eclipse Theia trace viewer extension or the trace viewer extension for VS Code
1+
# Trace Viewer Examples
2+
3+
Trace viewer example applications and building blocks that can be used in or with them. Each application integrates either the [Eclipse Theia trace viewer extension](https://www.npmjs.com/package/theia-traceviewer) (npmjs.com) or the [Trace Viewer extension for VSCode](https://open-vsx.org/extension/eclipse-cdt/vscode-trace-extension) (open-vsx.org).
4+
5+
## Requirements
6+
7+
### General Requirements
8+
9+
Generally speaking, all trace viewer example applications rely on the Trace Server Protocol (TSP), and require a compatible _Trace Server_. ATM it's left to the user to provide the trace server, start it and potentially configure the example application to access it, if it's not on the default host/port (localhost:8080). For more details, please consult the following documentation:
10+
11+
- obtaining/using the Eclipse Trace Compass trace server: [doc](https://github.com/eclipse-cdt-cloud/vscode-trace-extension/blob/master/vscode-trace-extension/README.md#obtain-the-trace-server-eclipse-trace-compass)
12+
- using the theia trace viewer extension: [README](https://github.com/eclipse-cdt-cloud/theia-trace-extension#using-the-trace-extension)
13+
- using the trace viewer for vscode: [README](https://github.com/eclipse-cdt-cloud/vscode-trace-extension/blob/master/vscode-trace-extension/README.md)
14+
15+
### Development Requirements
16+
17+
To build Theia-based applications "natively", i.e. not in docker:
18+
19+
- see this page: [Theia Developing.md "Prerequisites"](https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisites)
20+
21+
To build the docker images you need to have Docker, or potentially a replacement such as Podman, installed and configured to be usable as a non-admin user.
22+
23+
## Examples Applications
24+
25+
### Docker examples
26+
27+
Easy to consume _trace viewer appliance_ Docker images, that you can build yourself. For more details look under folder [docker](./docker)
28+
29+
### Electron
30+
31+
(TODO) Electron-based desktop trace viewer application, that can be packaged for distribution
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM node:18.19.1-bookworm-slim as build
1+
FROM node:18.20.4-bookworm-slim AS build
2+
ARG RESOURCES
23

34
RUN apt-get update && apt-get install -y \
45
git \
@@ -11,31 +12,32 @@ RUN apt-get update && apt-get install -y \
1112
libxkbfile-dev
1213

1314
# Build the browser theia-trace-extension application
14-
COPY example-package.json /app/tte/package.json
15-
COPY webpack.config.js /app/tte/webpack.config.js
16-
WORKDIR /app/tte/
15+
COPY ${RESOURCES}/package.json /app/tv/
16+
COPY ${RESOURCES}/webpack.config.js /app/tv/
17+
COPY yarn.lock /app/tv/
18+
WORKDIR /app/tv/
1719
RUN yarn && \
18-
npx theia build --app-target=\"browser\" --mode production && \
20+
yarn build:prod && \
1921
yarn autoclean --init && \
2022
echo *.ts >> .yarnclean && \
2123
echo *.ts.map >> .yarnclean && \
2224
echo *.spec.* >> .yarnclean && \
2325
yarn --production && \
24-
yarn cache clean && \
25-
du -hs /app/tte
26+
yarn cache clean
2627

2728
FROM node:18.19.1-bookworm-slim
29+
ARG RESOURCES
2830

29-
COPY --from=build /app/tte /app/tte
31+
COPY --from=build /app/tv /app/tv
3032

3133
RUN apt-get update && apt-get install -y \
3234
libx11-6 \
3335
libxkbfile1 \
3436
libsecret-1-0 \
3537
&& rm -rf /var/lib/apt/lists/*
36-
ENV NODE_ENV production
38+
ENV NODE_ENV=production
3739

38-
WORKDIR /app/tte
39-
COPY docker-entrypoint.sh /usr/local/bin
40+
WORKDIR /app/tv
41+
COPY ${RESOURCES}/docker-entrypoint.sh /usr/local/bin
4042
EXPOSE 4000
4143
ENTRYPOINT ["docker-entrypoint.sh"]
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM node:18.19.1-bookworm-slim as build
1+
FROM node:18.20.4-bookworm-slim AS build
2+
ARG RESOURCES
23

34
RUN apt-get update && apt-get install -y \
45
git \
@@ -11,33 +12,34 @@ RUN apt-get update && apt-get install -y \
1112
libxkbfile-dev
1213

1314
# Build the browser trace-extension application
14-
COPY example-package.json /app/tte/package.json
15-
COPY webpack.config.js /app/tte/webpack.config.js
16-
WORKDIR /app/tte/
15+
COPY ${RESOURCES}/package.json /app/tv/
16+
COPY ${RESOURCES}/webpack.config.js /app/tv/
17+
COPY yarn.lock /app/tv/
18+
WORKDIR /app/tv/
1719
RUN yarn && \
1820
yarn run download:plugins && \
19-
npx theia build --app-target=\"browser\" --mode production && \
21+
yarn build:prod && \
2022
yarn autoclean --init && \
2123
echo *.ts >> .yarnclean && \
2224
echo *.ts.map >> .yarnclean && \
2325
echo *.spec.* >> .yarnclean && \
2426
echo "!@theia/test" >> .yarnclean && \
2527
yarn --production && \
26-
yarn cache clean && \
27-
du -hs /app/tte
28+
yarn cache clean
2829

2930
FROM node:18.19.1-bookworm-slim
31+
ARG RESOURCES
3032

31-
COPY --from=build /app/tte /app/tte
33+
COPY --from=build /app/tv /app/tv
3234

3335
RUN apt-get update && apt-get install -y \
3436
libx11-6 \
3537
libxkbfile1 \
3638
libsecret-1-0 \
3739
&& rm -rf /var/lib/apt/lists/*
38-
ENV NODE_ENV production
40+
ENV NODE_ENV=production
3941

40-
WORKDIR /app/tte
41-
COPY docker-entrypoint.sh /usr/local/bin
42+
WORKDIR /app/tv
43+
COPY ${RESOURCES}/docker-entrypoint.sh /usr/local/bin
4244
EXPOSE 4000
4345
ENTRYPOINT ["docker-entrypoint.sh"]

docker/README.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Docker examples
2+
3+
This folder and sub-folders contain what's necessary to build Trace Viewer example Docker images, that each contain a Trace Viewer frontend application.
4+
5+
Each application has a `DockerFile` in this folder and its resources in a sub-folder:
6+
7+
- `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].
8+
- `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+
10+
Note:
11+
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+
14+
## Quickly Build/Run the example Docker images
15+
16+
(_see section further down to learn how to manually build/run the images_)
17+
18+
For convenience and use in CI, there are `package.json scripts` to build the docker images on Linux. Note that it's not necessary to build anything in the repo first:
19+
20+
```bash
21+
$ cd <repo>/docker
22+
23+
# build all docker images
24+
$ yarn build:docker
25+
26+
27+
# build docker images individually
28+
29+
# build "tate" image: Theia app that uses
30+
# the theia trace viewer extension:
31+
$ yarn build:docker:tate
32+
# Run image:
33+
$ yarn run:docker:tate
34+
35+
36+
# build "tave" image: Theia app that uses
37+
# the vscode trace viewer extension:
38+
$ yarn build:docker:tave
39+
# Run image:
40+
$ yarn run:docker:tave
41+
42+
# Access the application at http://localhost:4000/
43+
# e.g.:
44+
$ firefox http://localhost:4000
45+
46+
```
47+
48+
## Manually Build/run the example Docker images
49+
50+
The Docker images can be build from the `<repo>/docker` folder. For each image, the resources it needs are in a sub-folder, whose name is passed as a `docker build` build argument and used to retrieve expected resourced needed during image build.
51+
52+
### Build/Run the "tate" image
53+
54+
Build the image and name it _tv-tate_ (short for `"trace viewer - theia application/theia extension"`). You may use a different name if you prefer.
55+
56+
Try adding `--network host` in case of build failures related to debian packages retrieval:
57+
58+
```bash
59+
docker build -f Dockerfile-tate -t tv-tate --build-arg RESOURCES=theia-app-theia-ext .
60+
```
61+
62+
Once the image has been built, start a container named _tv-tate-1_ from the _tv-tate_ image:
63+
64+
```bash
65+
docker run --name tv-tate-1 tv-tate
66+
```
67+
68+
Find the IP address of the _tv-tate-1_ container:
69+
70+
```bash
71+
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' tv-tate-1
72+
```
73+
74+
Connect to port `4000` of the IP identified earlier using your browser. You should be able to see the theia-trace-extension UI. If it is not visible, click on `View -> Open View... -> Trace Viewer`
75+
76+
#### Connect to a trace-server
77+
78+
Let's say you have another container running the trace-server at IP 172.17.0.2, port `8080`. You can launch the _tv-tate-1_ container and connect it to the trace-server using the following command:
79+
80+
```bash
81+
docker run --name tv-tate-1 --network="host" -e TRACE_SERVER_URL=172.17.0.2:8080/tsp/api tv-tate
82+
```
83+
84+
### Build/Run the "tave" image
85+
86+
Build the image and name it _tv-tave_ (short for `"trace viewer - theia application/vscode extension"`). You may use a different name if you prefer.
87+
88+
Try adding `--network host` in case of build failures related to debian packages retrieval.
89+
90+
```bash
91+
docker build -f Dockerfile-tave -t tv-tave --build-arg RESOURCES=theia-app-vscode-ext .
92+
```
93+
94+
Once the image has been built, start a container named _tv-tave-1_ fromthe _tave_ image:
95+
96+
```bash
97+
docker run --name tv-tave-1 --network host tv-tave
98+
```
99+
100+
Connect to `localhost:4000` your browser. You should be able to see the trace-extension UI. If it is not visible, click on `View -> Open View... -> Trace Viewer`
101+
102+
## Development
103+
104+
When the _Theia applications_ are modified/updated, e.g. to update the contained trace extension or for other reasons, it's important to build the modified app(s) outside Docker and check-in the modified `yarn.lock`. The lock file is used when building in the container, to insure a known/curated set of dependencies/versions are used. Without the lock file, unexpected 3PPs or versions of 3PPs might be pulled.
105+
106+
To build the Theia applications:
107+
108+
```bash
109+
# build both apps (dev)
110+
$ yarn && yarn build
111+
112+
# build both apps (prod version)
113+
$ yarn && yarn build:prod
114+
```
115+
116+
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.
117+
118+
119+
[npm package]: https://www.npmjs.com/package/theia-traceviewer
120+
[vsix package]: https://open-vsx.org/extension/eclipse-cdt/vscode-trace-extension

docker/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"private": true,
3+
"name": "docker-examples",
4+
"version": "0.1.0",
5+
"dependencies": {
6+
7+
},
8+
"devDependencies": {
9+
},
10+
"scripts": {
11+
"prepare": "yarn tave",
12+
"build": "yarn tate build && yarn tave build",
13+
"build:prod": "yarn tate build:prod && yarn tave build:prod",
14+
"tate": "yarn --cwd theia-app-theia-ext",
15+
"tave": "yarn --cwd theia-app-vscode-ext",
16+
"build:docker": "yarn build:docker:tate && yarn build:docker:tave",
17+
"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:tave": "docker build --no-cache --network=host . --build-arg RESOURCES=theia-app-vscode-ext -t tv-tave -f Dockerfile-tave",
19+
"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"
21+
},
22+
"engines": {
23+
},
24+
"resolutions": {
25+
"msgpackr": "^1.10.1",
26+
"**/nan": "2.18.0"
27+
},
28+
"workspaces":[
29+
"theia-app-theia-ext",
30+
"theia-app-vscode-ext"
31+
]
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Resources for the "tate" Example docker image example
2+
3+
This folder contains the resources, needed to create the docker image example, that bundles at its core a Theia-based application that uses the _Theia Trace Viewer_ front-end.
4+
5+
`package.json`: This is where the Theia application is defined
6+
`docker-entrypoint.sh`: the docker entrypoint script, that's called when starting a container based on the image
7+
`webpack.config.js`: a webpack configuration file, used when building the Theia application
8+
9+
Notes:
10+
11+
- the various `@theia` packages used in the app need to be the same version as the ones used in other Theia apps in this monorepo, such that a single version of the Theia framework is pulled by `yarn`, else there will be problems
12+
- for the same reason, the `theia-traceviewer` extension used in this Theia application needs to have its Theia version aligned with the various `@theia` packages used in the app
13+
14+
To check for this, run `yarn` in the parent folder and then `yarn why @theia/core` and confirm a single version is reported. e.g.:
15+
16+
```bash
17+
[...]
18+
=> Found "@theia/[email protected]"
19+
[...]
20+
```
File renamed without changes.

docker/theia-trace-extension/example-package.json renamed to docker/theia-app-theia-ext/package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,21 @@
1818
"@emotion/react": "^11.10.5",
1919
"@emotion/styled": "^11.10.5",
2020
"@mui/material": "^5.10.14",
21-
"@theia/core": "1.45.1",
22-
"@theia/navigator": "1.45.1",
23-
"@theia/preferences": "1.45.1",
24-
"theia-traceviewer": "0.2.0-next.20240229144356.c22cb2c.0"
21+
"@theia/core": "1.49.1",
22+
"@theia/navigator": "1.49.1",
23+
"@theia/preferences": "1.49.1",
24+
"theia-traceviewer": "0.2.7"
2525
},
2626
"devDependencies": {
27-
"@theia/cli": "1.45.1"
27+
"@theia/cli": "1.49.1"
2828
},
2929
"scripts": {
30+
"build": "npx theia build --app-target=\"browser\" --mode development",
31+
"build:prod": "npx theia build --app-target=\"browser\" --mode production",
3032
"start": "theia start",
31-
"watch": "theia build --watch"
33+
"watch": "theia build --watch",
34+
"clean": "echo 'Docker: Fake clean!!!'",
35+
"test": "yarn --cwd ../../playwright-tests ui-tests"
3236
},
3337
"engines": {
3438
"yarn": ">=1.7.0 <2",

0 commit comments

Comments
 (0)