Skip to content

Commit

Permalink
Add multi stage Dockerfile to build Trace Compass Server
Browse files Browse the repository at this point in the history
1. The stage "packager" use the image of tracecompass
2. The stage "packager" installs the minimum package needed to compile
tracecompass.incubator
3. Then it will copy the project inside the container
4. Then it will run the command to build tracecompass.incubator
5. After the build, it will go to the next stage, and it will
install the bare minimum configuration to run the tracecompass-server.
6. Then it copies the tracecompass-server already compiled from
the previous stage into the current stage
7. Then it will run the trace-server on port 8080

[Added] Multi stage Dockerfile to build Trace Compass Server

This change therefore depends on the mainline, core TC change [1] below.

[1]https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/199945

Change-Id: I969847adab55d885d4250e947d36cb0e34953802
Signed-off-by: Ahmad Faour <ahmad.faour@polymtl.ca>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/199977
Reviewed-by: Marco Miller <marco.miller@ericsson.com>
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Marco Miller <marco.miller@ericsson.com>
  • Loading branch information
Spiritus2424 authored and marco-miller committed May 1, 2023
1 parent 1f1002f commit b053fb3
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Compiled output
**/target/
workspace/
**/bin/
*/.settings/org.sonar.ide.eclipse.core.prefs
.polyglot.build.properties
.tycho-consumer-pom.xml

# Git
.git*
!.git/

# Markdown files
*.md

# IDEs and editors
.vscode/*
.history/*
.devcontainer/

# Dockerfiles
Dockerfile*

# System files
.DS_Store
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
bin/
target/
workspace/

# VS Code
.devcontainer
.vscode
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) 2023 Polytechnique de Montréal
#
# All rights reserved. This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0 which
# accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0

ARG VARIANT=latest
FROM tracecompass:${VARIANT} as packager

ENV JAVA_MINIMAL="/opt/java-minimal"

RUN apk --no-cache add openjdk17-jdk openjdk17-jmods maven && \
# build minimal JRE
/usr/lib/jvm/java-17-openjdk/bin/jlink \
--verbose \
--add-modules \
java.base,java.sql,java.naming,java.desktop,java.management,java.security.jgss,java.instrument,jdk.unsupported \
--compress 2 --no-header-files --strip-java-debug-attributes --no-man-pages \
--output "$JAVA_MINIMAL"

COPY ./ /app/

WORKDIR /app/

RUN mvn clean install -DskipTests

FROM alpine:3.16.0

ENV JAVA_HOME=/opt/java-minimal
ENV PATH="$PATH:$JAVA_HOME/bin"

# Required dependency for Eclipse Trace Compass Server
RUN apk --no-cache add libc6-compat

COPY --from=packager "$JAVA_HOME" "$JAVA_HOME"
COPY --from=packager /app/trace-server/org.eclipse.tracecompass.incubator.trace.server.product/target/products/traceserver/linux/gtk/x86_64/trace-compass-server /usr/src/tracecompass

WORKDIR /usr/src/tracecompass
EXPOSE 8080
CMD ["./tracecompass-server"]
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,51 @@ the build system. You can set them by using `-P[profile name]` and

Mainly for use on build servers. Generates the javadoc of API classes as a
HTML website to the destination specified by `-Djavadoc-site=/absolute/path/to/destination`.

## Build Trace Compass Server image with Docker

To compile the image of Trace Compass Server with Docker, run the following command from the top level directory:

docker build -t trace-server .

The image will be tagged `trace-server`.

To run the Trace Compass Server with the image, run the following command:

docker run -p 8080:8080 trace-server

The Trace Compass Server will run on port `8080`.

## Test Trace Compass Server image

You can clone the [Tracecompass Test Traces][tracecompass-test-traces] repository.

> We cloned the repository inside the `$HOME/ws` folder on our computer.
To test the image of Trace Compass Server with Docker, you need to mount traces inside the container. We will use the kernel trace from the repository, located under `$HOME/ws/tracecompass-test-traces/ctf/src/main/resources/kernel` on our computer. Then run the following command:

docker run -p 8080:8080 -v $HOME/ws/tracecompass-test-traces/ctf/src/main/resources/kernel:/traces/kernel trace-server

The Trace Compass Server will run on port `8080` and have the traces mount at `/traces/kernel` folder inside the container.

You can check the Trace Compass Server status using the following command:

curl -X GET 'http://localhost:8080/tsp/api/health'

You can open the kernel trace (or any mounted one) inside the container using the following command:

curl -X POST 'http://localhost:8080/tsp/api/traces' --header 'Content-Type: application/json' --data-raw '{ "parameters": { "uri": "/traces/kernel" } }'

You can create an experiment with the kernel trace (or any opened trace) using the following command:

curl -X POST 'http://localhost:8080/tsp/api/experiments' --header 'Content-Type: application/json' --data-raw '{ "parameters": { "name": "Experiment Name", "traces": ["d49d04f5-9db5-3773-ace4-1594b87db661"] } }'

You can get all the experiments using the following command:

curl -X GET 'http://localhost:8080/tsp/api/experiments' --header 'Content-Type: application/json'

Refer to the [Trace Server Protocol][trace-server-protocol] for more endpoints.

[trace-server-protocol]: https://github.com/eclipse-cdt-cloud/trace-server-protocol

[tracecompass-test-traces]: https://git.eclipse.org/r/admin/repos/tracecompass/tracecompass-test-traces

0 comments on commit b053fb3

Please sign in to comment.