Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import docker examples #1

Merged

Conversation

marcdumais-work
Copy link
Contributor

@marcdumais-work marcdumais-work commented Oct 24, 2024

This PR kick-starts this new repository.:

  • add some basic files required for all Eclipse Foundation projects (License, code of conduct, ...)
  • "imports" its first two trace viewer example applications:
    • the "docker example" from repo theia-trace-extension, contributed by @frallax
    • the "docker example" proposed as a PR in repo vscode-trace-extension, contributed by @frallax
  • the two docker examples were "re-organized together", under folder "docker", each with its sub-folder. The underlying Theia applications are organized as a monorepo, sharing their npm dependencies and yarn.lock. When building either one in its docker container, the yarn.lock is used, insuring that curated npm dependencies/versions are pulled, and avoiding potential bad surprises.
  • the two docker example use a Theia-based application at their core. Both have been updated to Theia 1.49.1, the previous community release (for stability). It would be desirable to keep them updated to "latest community release - 1" as new Theia community releases are published.
  • also imported the playwright test suite from repo theia-trace-extension, meant to test a theia "browser" app running the theia trace extension. In that repo, that suite is/was used to test the docker example in CI and the same was setup here.
  • there is no real tests ATM for the docker example using the vscode trace extension, other than building the docker image. One can be added later if desired/needed.

Note: when "importing" the two docker examples and the playwright test suite, care has been taken to keep important git commits that contributed to them, including preserving authorship. This makes for a slightly more messy git history in this repo here, but we believe it's a worthy trade-off. For more generic imported content, like root CONTRIBUTING file, I just copied-over and adapted, without preserving their original git history. Let me know during review if you do not agree with this.

Notes:

  • content imported from repos theia-trace-extension and vscode-trace-extension is license-compatible with the license of this repo here (all under MIT), and has been originally contributed using the Eclipse Foundation development and IP processes.
  • since this repo does not have a GitHub workflow before this PR, it's expected that no real test will be run for it. Once this PR is merged, this will change. In the meantime, I've opened a PR on my fork, using the same PR branch - there I have manually enabled actions, and so we can see what the PR's workflow results are.

@marcdumais-work marcdumais-work force-pushed the import-docker-examples branch 7 times, most recently from 91413de to 83ffe1c Compare October 25, 2024 19:35
marcdumais-work and others added 7 commits October 25, 2024 15:59
Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
Resolves #908

Signed-off-by: Francesco Robino <francesco.robino@ericsson.com>
Perform a side (minor) 'yarn upgrade' to keep the yarn.lock fully
aligned herein. This resulting yarn.lock is then based on going from
clean to having run the yarn command locally a few times.

Base this uplifted-to Theia version on community [1]'s below. Add a
clarifying step in README so the yarn commands work locally. Fix the
rebuild:browser scripting so it works with this and versus electron's.

[1] https://theia-ide.org/releases/

Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Perform a 'yarn upgrade' to keep the yarn.lock fully aligned.

Base this uplifted-to Theia version on community [1]'s below.

Fixed compilation error by making constructors of injectable classes
public.

Align to @postContruct changes of new inversify version [2]. Use Theia's
re-export dependencies for inversify according to [3]

Change electron-main location to ../src-gen/backend/ instead of
../src-gen/frontend due to breaking change described here [4]

[1] https://theia-ide.org/releases/
[2] https://github.com/eclipse-theia/theia/blob/master/doc/Migration.md#inversify-60
[3] https://github.com/eclipse-theia/theia/blob/master/packages/core/README.md#re-exports
[4] https://github.com/eclipse-theia/theia/blob/master/CHANGELOG.md#breaking_changes_1.39.0

Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>

Uplift Theia dependencies from v1.40.1 to 1.43.1

Perform a 'yarn upgrade' to keep the yarn.lock fully aligned.

Base it on Theia community release [1] below.

[1] https://theia-ide.org/releases/
Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Before this commit the docker example was not properly building.
The issue was introduced when moving from Theia 1.3x to 1.4x, where
an extra step in the build process was introduced (i.e. running "yarn"
was not enough, an extra "theia" command was needed).

After this commit:
- the docker example is building again
- the docker image generated is stable and reproducible,
  not based on "next"
- the docker image is much smaller thanks to a multistage build

Signed-off-by: Francesco Robino <francesco.robino@ericsson.com>
Build the docker example image

Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>

Update to node 18

Also update the required yarn version, that's somewhat related,
aligning it to what's used in upstream Theia.

Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
A few small changes that make the example docker image smaller and build a bit faster:

- Build the theia trace viewer app/appliance in "production" mode (vs development)
- Have yarn remove the installed "devDependencies" after the build ("yarn --production")
  - adapt docker-entrypoint.sh to start the app directly rather than through @theia/cli
- Remove redundant "theia build" triggered in "prepare" package.json scripts entry - it's
  also done in Dockerfile

Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
@marcdumais-work marcdumais-work force-pushed the import-docker-examples branch 2 times, most recently from 5fa1b63 to 75f8c5e Compare October 25, 2024 20:08
marcdumais-work and others added 3 commits October 25, 2024 16:26
… a few testcases

Create a "trace viewer app" from the generic @theia/playwright "theiaApp" and add
a "trace explorer view".  Enhance test suite with some related test cases.

Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
Some views like statistics view have features to
right-click on the entries and select time ranges,
but this feature requires some Node.js-specific
features like "process", which is missing for the
docker example.

Fixes #1066

Signed-off-by: Siwei Zhang <siwei.zhang@ericsson.com>
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 <francesco.robino@ericsson.com>
@frallax
Copy link
Contributor

frallax commented Oct 30, 2024

Quick comment. I have a few more images to contribute. One of them presents how to use the vscode-trace-extension in a vscode web application. The current naming of folders (theia-extension and vscode-extension) is a bit too vague to give a quick understanding of what the image is. For example, is "vscode-extension" the vscode-trace-extension running in a vscode app or in a theia app? Do you think would be worth to rename the folders using more details (e.g. theia-trace-ext-on-theia or theia-with-theia-trace-ext or similar)? Otherwise I can I differentiate my upcoming "vscode-trace-extension in vscode app" image?

@marcdumais-work
Copy link
Contributor Author

I have a few more images to contribute. One of them presents how to use the vscode-trace-extension in a vscode web application. The current naming of folders (theia-extension and vscode-extension) is a bit too vague to give a quick understanding of what the image is. For example, is "vscode-extension" the vscode-trace-extension running in a vscode app or in a theia app? Do you think would be worth to rename the folders using more details (e.g. theia-trace-ext-on-theia or theia-with-theia-trace-ext or similar)? Otherwise I can I differentiate my upcoming "vscode-trace-extension in vscode app" image?

@frallax Nice! thanks for having a look at the PR - I will think about it a bit and propose more meaningful app folder names in an update to this PR.

@marcdumais-work marcdumais-work force-pushed the import-docker-examples branch 4 times, most recently from e328641 to 36508a1 Compare November 6, 2024 19:42
@marcdumais-work marcdumais-work marked this pull request as ready for review November 6, 2024 19:44
Copy link
Contributor

@bhufmann bhufmann left a comment

Choose a reason for hiding this comment

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

after removing the line that copies the yarn.lock (theia-app-theia-ext) the build continues, but fails later on:

#0 761.9 ERROR in ./node_modules/@inversifyjs/core/lib/esm/index.js 6:0-86
#0 761.9 Module not found: Error: Can't resolve './metadata/models/ClassElementMetadataKind' in '/app/tte/node_modules/@inversifyjs/core/lib/esm'
#0 761.9 Did you mean 'ClassElementMetadataKind.js'?
#0 761.9 BREAKING CHANGE: The request './metadata/models/ClassElementMetadataKind' failed to resolve only because it was resolved as fully specified

README.md Outdated

### Docker examples

Easy to consume _trace viewer appliance_ Docker images, thatt you can build yourself. For more details look under folder [docker](./docker)
Copy link
Contributor

Choose a reason for hiding this comment

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

thatt -> that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

# Build the browser theia-trace-extension application
COPY ${APP_SUBFOLDER}/package.json /app/tte/
COPY ${APP_SUBFOLDER}/webpack.config.js /app/tte/
COPY yarn.lock /app/tte/
Copy link
Contributor

@bhufmann bhufmann Nov 7, 2024

Choose a reason for hiding this comment

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

This line causes an error for me when runnig the build from this directory:
ERROR [build 5/7] COPY yarn.lock

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have refactored the layout of the Docker example vs their theia applications and other resources. The Dockerfile(s ) are now in the "docker root" (<repo>/docker) and so I think it will be much clearer that the images should be built from that folder.

I have also much improved the READMEs.

Try adding `--network host` in case of build failures related to debian packages retrieval:

```bash
docker build -t tate .
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't work anymore. The build has to be done from the parent directory using the yarn command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This trick is still valid, but unfortunately did not help in that specific case. The build instructions have been migrated to the "docker" folder README and adjusted, which I think should help avoid this issue.

the _tate_ image:

```bash
docker run --name tate-1 tate
Copy link
Contributor

Choose a reason for hiding this comment

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

After building the images from the parent directory, I went to this directory and and tried this command. I get the following error message:

Unable to find image 'tate:latest' locally
docker: Error response from daemon: pull access denied for tate, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The faulty instructions have been migrated to the parent folder README and adjusted. Can you please retry?

@marcdumais-work marcdumais-work force-pushed the import-docker-examples branch 8 times, most recently from cadd930 to 8400a31 Compare November 18, 2024 18:05
@marcdumais-work
Copy link
Contributor Author

after removing the line that copies the yarn.lock (theia-app-theia-ext) the build continues, but fails later on:

#0 761.9 ERROR in ./node_modules/@inversifyjs/core/lib/esm/index.js 6:0-86
#0 761.9 Module not found: Error: Can't resolve './metadata/models/ClassElementMetadataKind' in '/app/tte/node_modules/@inversifyjs/core/lib/esm'
#0 761.9 Did you mean 'ClassElementMetadataKind.js'?
#0 761.9 BREAKING CHANGE: The request './metadata/models/ClassElementMetadataKind' failed to resolve only because it was resolved as fully specified

This was an interesting case. As long as the yarn.lock was being used, it protected the app from an issue we also saw in repo theia-trace-extension, due to pulling a newer version of inversify, that did not play nice with the build.

I think this shows one aspect of the value gained by maintaining a yarn.lock for the Docker example applications: it protects against problems pulling more recent versions of dependencies that are semantically assumed compatible.

@marcdumais-work
Copy link
Contributor Author

@bhufmann thanks for the review. I think your comments have been addressed by my last push. They have inspired me to refactor the layout of the "docker" folder and sub-folders, moving the Dockerfiles in the "docker" folder and leaving the image-specific resources in the subfolders. I think it's clearer this way, and hopefully you will agree.


```bash
docker run --name tv-tate-1 --network="host" -e TRACE_SERVER_URL=172.17.0.2:8080/tsp/api tv-tate
```
Copy link
Contributor

Choose a reason for hiding this comment

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

When I run this line after having run command in line 51 above I get the following error:

docker: Error response from daemon: Conflict. The container name "/tv-tate-1" is already in use by container "bdc7e40b3c61d60538b54e2842c34a66e9641d00b17511096d01d7db81e4782f". You have to remove (or rename) that container to be able to reuse that name.

It would be good to mention that the previous has to removed and provide users with the command for that for people that are not so familiar with docker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a section at the bottom of the readme: "Docker tips and tricks", in which I gave a few ways to deal with this error, as well as a few other tips about other things.

Since this is the first "docker run" I have also specifically added an alternative command that discards the container after the run, as an example.

@marcdumais-work marcdumais-work force-pushed the import-docker-examples branch 3 times, most recently from a44603c to 22ba680 Compare November 18, 2024 21:37
@marcdumais-work
Copy link
Contributor Author

@bhufmann I think I have addressed your last remaining review comment.

bhufmann
bhufmann previously approved these changes Nov 19, 2024
Copy link
Contributor

@bhufmann bhufmann left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for providing this.

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 <marc.dumais@ericsson.com>
Copy link
Contributor

@bhufmann bhufmann left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@marcdumais-work
Copy link
Contributor Author

Thanks for the review @bhufmann !

@marcdumais-work marcdumais-work merged commit 5b524c0 into eclipse-cdt-cloud:master Nov 19, 2024
3 checks passed
@marcdumais-work marcdumais-work deleted the import-docker-examples branch November 19, 2024 14:40
@marcdumais-work marcdumais-work changed the title [WIP] Import docker examples Import docker examples Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants