Skip to content

Commit d6bdd72

Browse files
183-create-dockerfile (#185)
* 183 add dockerfile * 183 remove dockerfile * 183 add dockerfile * 183 update dockerfile * 183 add GA workflow to build and push docker image * 183 update readme * 183 slight fix to readme * 183 add PYTHONUNBUFFERED to dockerfile * 183 ignore warnings in main.py remove from dockerfile * 183 change in line with comments * 183 testing building container on push to branch * 183 revert workflow to only build docker on main
1 parent ed6cebf commit d6bdd72

File tree

4 files changed

+112
-1
lines changed

4 files changed

+112
-1
lines changed

.github/workflows/build-push.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build and Push Docker Image
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- 'main'
7+
tags:
8+
- 'v*'
9+
10+
jobs:
11+
build-and-push:
12+
if: |
13+
github.repository == 'xtuml/otel2puml'
14+
&& github.actor != 'dependabot[bot]'
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Login to GitHub Container Registry
21+
uses: docker/login-action@v3
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Docker meta
28+
id: meta
29+
uses: docker/metadata-action@v5
30+
with:
31+
images: ghcr.io/xtuml/otel2puml
32+
33+
- name: Build and push
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
push: true
38+
tags: ${{ steps.meta.outputs.tags }}
39+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM python:3.11-bullseye
2+
3+
# Setup folders
4+
RUN mkdir /otel2puml_app && mkdir /otel2puml_app/tel2puml
5+
6+
WORKDIR /otel2puml_app
7+
8+
# Install system dependencies needed for cvxopt
9+
RUN apt-get update && apt-get install -y \
10+
liblapack-dev \
11+
libopenblas-dev \
12+
libsuitesparse-dev \
13+
libglpk-dev \
14+
&& apt-get clean
15+
16+
# Set environment variables for cvxopt build
17+
ENV CPPFLAGS="-I/usr/include/suitesparse"
18+
ENV CVXOPT_BUILD_GLPK=1
19+
ENV PYTHONUNBUFFERED=1
20+
21+
# Caches packages installed by pip
22+
COPY requirements.txt .
23+
RUN pip install --no-cache-dir -r requirements.txt
24+
25+
COPY ./tel2puml/ /otel2puml_app/tel2puml/
26+
COPY ./scripts/install_repositories.sh /otel2puml_app/
27+
28+
# Create a non-root user and give ownership of the app folder
29+
RUN useradd -m otel2pumluser && chown -R otel2pumluser /otel2puml_app
30+
31+
# Switch to the non-root user
32+
USER otel2pumluser
33+
34+
# Install external dependencies
35+
RUN chmod +x /otel2puml_app/install_repositories.sh
36+
RUN /otel2puml_app/install_repositories.sh
37+
38+
EXPOSE 8800
39+
40+
ENTRYPOINT [ "python", "-m" , "tel2puml"]

README.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ This project converts [OpenTelemetry (OTel)](https://opentelemetry.io/) data int
77
<ol>
88
<li><a href="#why-use-this-tool">Why Use This Tool?</a></li>
99
<li><a href="#features">Features</a></li>
10-
<li><a href="#quick-start">Quick Start</a></li>
10+
<li><a href="#quick-start">Quick Start</a>
11+
<ol>
12+
<li><a href="#using-docker-image">Using Docker Image</a></li>
13+
</ol>
14+
</li>
1115
<li><a href="#example-input">Example Input</a></li>
1216
<li><a href="#example-output">Example Output</a></li>
1317
<li><a href="#installation">Installation</a>
@@ -109,6 +113,31 @@ python -m tel2puml pv2puml example_above.json -jn "output_diagram"
109113

110114
![](docs/images/example_sequence_for_readme.svg)
111115

116+
## Using Docker Image
117+
118+
You can run otel2puml using the provided [Docker image](https://github.com/orgs/xtuml/packages?repo_name=otel2puml). This is especially useful if you want to run the tool in an isolated environment without manually managing dependencies. Here’s how to do it:
119+
120+
Example Command:
121+
```bash
122+
docker run \
123+
-v /path/to/job_json_files:/job_json_files \
124+
-v /path/to/config.yaml:/config.yaml \
125+
-v /path/to/puml_output:/puml_output \
126+
ghcr.io/xtuml/otel2puml:<version> \
127+
-o /puml_output otel2puml -c /config.yaml
128+
```
129+
130+
Explanation:
131+
132+
* `-v /path/to/job_json_files:/job_json_files`: Mounts a local folder containing your OTel data in JSON format to the Docker container's /job_json_files directory.
133+
* `-v /path/to/config.yaml:/config.yaml`: Mounts the configuration file for `otel2puml` to the Docker container's /config.yaml.
134+
* `-v /path/to/puml_output:/puml_output`: Mounts a local folder where the output PlantUML diagrams will be saved.
135+
* `ghcr.io/xtuml/otel2puml`:latest: Specifies the Docker image to run.
136+
* `-o /puml_output`: Tells `otel2puml` where to save the generated PlantUML files inside the container (linked to the local `puml_output` folder).
137+
* `otel2puml -c /config.yaml`: Runs the `otel2puml` command using the provided configuration file.
138+
139+
Replace `/path/to/` with the actual paths on your local machine.
140+
112141
## Installation
113142

114143
There are two ways to set up this project: manual installation or using a devcontainer (recommended).

tel2puml/__main__.py

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import os
2222
import argparse
2323
import yaml
24+
import warnings
2425
from typing import Any, Literal
2526

2627
from .otel_to_puml import otel_to_puml
@@ -219,6 +220,8 @@ def generate_component_options(
219220

220221

221222
if __name__ == "__main__":
223+
warnings.filterwarnings("ignore")
224+
222225
args: argparse.Namespace = parser.parse_args()
223226
args_dict = vars(args)
224227
otel_pv_options, pv_puml_options = generate_component_options(

0 commit comments

Comments
 (0)