diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..2f1dca39a --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/.gitignore b/.gitignore index 007c092ce..c23d8e876 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ bin/ target/ workspace/ + +# VS Code +.devcontainer +.vscode diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..8fd3f1886 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md index 964638bc9..98e186cbb 100644 --- a/README.md +++ b/README.md @@ -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