Skip to content

Commit d939f62

Browse files
frallaxmarcdumais-work
authored andcommitted
Add docker example
Add an example showing how to create a docker image that contains a Theia-based application with the vscode-trace-extension. Signed-off-by: Francesco Robino <[email protected]>
1 parent 7e8d3b3 commit d939f62

File tree

5 files changed

+163
-0
lines changed

5 files changed

+163
-0
lines changed

examples/docker/Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM node:18.19.1-bookworm-slim as build
2+
3+
RUN apt-get update && apt-get install -y \
4+
git \
5+
python3 \
6+
make \
7+
pkg-config \
8+
libsecret-1-dev \
9+
g++ \
10+
libx11-dev \
11+
libxkbfile-dev
12+
13+
# 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/
17+
RUN yarn && \
18+
yarn run download:plugins && \
19+
npx theia build --app-target=\"browser\" --mode production && \
20+
yarn autoclean --init && \
21+
echo *.ts >> .yarnclean && \
22+
echo *.ts.map >> .yarnclean && \
23+
echo *.spec.* >> .yarnclean && \
24+
echo "!@theia/test" >> .yarnclean && \
25+
yarn --production && \
26+
yarn cache clean && \
27+
du -hs /app/tte
28+
29+
FROM node:18.19.1-bookworm-slim
30+
31+
COPY --from=build /app/tte /app/tte
32+
33+
RUN apt-get update && apt-get install -y \
34+
libx11-6 \
35+
libxkbfile1 \
36+
libsecret-1-0 \
37+
&& rm -rf /var/lib/apt/lists/*
38+
ENV NODE_ENV production
39+
40+
WORKDIR /app/tte
41+
COPY docker-entrypoint.sh /usr/local/bin
42+
EXPOSE 4000
43+
ENTRYPOINT ["docker-entrypoint.sh"]

examples/docker/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Example docker image for vscode-trace-extension
2+
3+
This folder contains an example showing how to create a docker image
4+
for vscode-trace-extension front-end.
5+
6+
Notes:
7+
8+
- the image will contain exclusively the trace-extension front-end.
9+
If you want to run a complete application, you will need a service
10+
running the trace-server (not included here);
11+
12+
- the image will be built using a specific [vsix package] of the
13+
trace-extension, and not the latest code in this repo;
14+
15+
- the *example-package.json* file is not named *package.json* because
16+
at the time this change was proposed building the trace-extension
17+
application from the source of this repo looked recursively to all
18+
package.json in the project, and we wanted to avoid pollution of the
19+
main project lockfile when building;
20+
21+
## How to build and run
22+
23+
Build the image and name it *tte*.
24+
25+
```bash
26+
docker build -t tte .
27+
```
28+
29+
Once the image has been built, start a container named *tte-1* from
30+
the *tte* image:
31+
32+
```bash
33+
docker run --name tte-1 --network host tte
34+
```
35+
36+
Connect to `localhost:4000` your browser.
37+
You should be able to see the trace-extension UI.
38+
If it is not visible, click on `View -> Open View... -> Trace Viewer`
39+
40+
[vsix package]: https://open-vsx.org/extension/eclipse-cdt/vscode-trace-extension
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
# @theia/cli not installed, so start the app directly
3+
node ./src-gen/backend/main.js --hostname 0.0.0.0 --port 4000 --plugins=local-dir:plugins
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"private": true,
3+
"name": "docker-vscode-trace-example",
4+
"version": "0.1.0",
5+
"theia": {
6+
"target": "browser",
7+
"frontend": {
8+
"config": {
9+
"applicationName": "Theia application with vscode-trace-extension",
10+
"preferences": {
11+
"editor.autoSave": "on",
12+
"trace-viewer.port": 8080
13+
}
14+
}
15+
}
16+
},
17+
"dependencies": {
18+
"@emotion/react": "^11.10.5",
19+
"@emotion/styled": "^11.10.5",
20+
"@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/plugin-ext-vscode": "1.45.1"
25+
},
26+
"devDependencies": {
27+
"@theia/cli": "1.45.1"
28+
},
29+
"scripts": {
30+
"download:plugins": "theia download:plugins --rate-limit=15 --parallel=false --ignore-errors"
31+
},
32+
"engines": {
33+
"yarn": ">=1.7.0 <2",
34+
"node": ">=16 <19"
35+
},
36+
"theiaPluginsDir": "plugins",
37+
"theiaPlugins": {
38+
"vscode-trace-extension": "https://open-vsx.org/api/eclipse-cdt/vscode-trace-extension/0.2.6/file/eclipse-cdt.vscode-trace-extension-0.2.6.vsix"
39+
},
40+
"resolutions": {
41+
"msgpackr": "^1.10.1"
42+
},
43+
"theiaPluginsExcludeIds": [
44+
"ms-vscode.js-debug-companion",
45+
"vscode.extension-editing",
46+
"vscode.git",
47+
"vscode.git-ui",
48+
"vscode.github",
49+
"vscode.github-authentication",
50+
"vscode.microsoft-authentication"
51+
]
52+
}

examples/docker/webpack.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* This file can be edited to customize webpack configuration.
3+
* To reset delete this file and rerun theia build again.
4+
*/
5+
// @ts-check
6+
const config = require('./gen-webpack.config.js');
7+
const webpack = require("webpack");
8+
9+
10+
/**
11+
* Expose bundled modules on window.theia.moduleName namespace, e.g.
12+
* window['theia']['@theia/core/lib/common/uri'].
13+
* Such syntax can be used by external code, for instance, for testing.
14+
config.module.rules.push({
15+
test: /\.js$/,
16+
loader: require.resolve('@theia/application-manager/lib/expose-loader')
17+
}); */
18+
19+
config[0].plugins.push(new webpack.DefinePlugin({
20+
'process.env': {
21+
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
22+
}
23+
}));
24+
25+
module.exports = config;

0 commit comments

Comments
 (0)