Skip to content

Commit

Permalink
Dockerfile and entrypoint script for improved structure and usability
Browse files Browse the repository at this point in the history
  • Loading branch information
FloSch62 committed Jan 18, 2025
1 parent c9951a4 commit 1b3cd70
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
15 changes: 6 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ FROM python:3.11-slim
# Install build tools and required libraries
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
python3-dev \
curl \
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -18,18 +17,16 @@ ENV COLORTERM=truecolor
# Set up working directory
WORKDIR /app

COPY pyproject.toml ./
COPY drawio2clab.py ./
COPY clab2drawio.py ./
COPY pyproject.toml README.md ./
COPY uv.lock ./
COPY entrypoint.sh ./
COPY styles/ ./styles/
COPY core/ ./core/
COPY cli/ ./cli/
COPY clab_io_draw/ ./clab_io_draw/

# Install dependencies using uv
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=cache,target=/root/.cache/uv \
uv pip install --system -r pyproject.toml
--mount=type=cache,target=/root/.cache/uv

RUN uv pip install --system .

# Make the entrypoint script executable
RUN chmod +x /app/entrypoint.sh
Expand Down
1 change: 0 additions & 1 deletion clab_io_draw/clab2drawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ def main(

print("Saved file to:", output_file)


def cli():
"""Entry point for the command line interface."""
args = parse_arguments()
Expand Down
15 changes: 7 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Examples:
Convert .drawio to .yaml: docker run -v "\$(pwd)":/data ghcr.io/srl-labs/clab-io-draw -i input.drawio -o output.yaml
Convert .yaml to .drawio: docker run -v "\$(pwd)":/data ghcr.io/srl-labs/clab-io-draw -i input.yaml -o output.drawio
clab2drawio.py help:
$(python -u "/app/clab2drawio.py" -h)
clab2drawio help:
$(clab2drawio -h)
drawio2clab.py help:
$(python -u "/app/drawio2clab.py" -h)
drawio2clab help:
$(drawio2clab -h)
EOF
}

Expand All @@ -36,7 +36,6 @@ if [ $# -eq 0 ] || [[ " $@ " =~ " -h " ]] || [[ " $@ " =~ " --help " ]]; then
exit 0
fi

script_name=""
input_file=""
prev_arg=""

Expand All @@ -52,10 +51,10 @@ done
if [ ! -z "$input_file" ]; then
case $(get_extension "$input_file") in
yml|yaml)
script_name="clab2drawio.py"
script_name="clab2drawio"
;;
drawio)
script_name="drawio2clab.py"
script_name="drawio2clab"
;;
*)
echo "Unsupported file type: $input_file"
Expand All @@ -68,4 +67,4 @@ else
fi

# Execute the determined script with all passed arguments
python "/app/${script_name}" "$@"
$script_name "$@"
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ dependencies = [
"textual==1.0.0",
]

[tool.setuptools.packages.find]
include = ["clab_io_draw*"]
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"


[tool.setuptools.package-data]
clab_io_draw = ["styles/*.yaml"]

[project.scripts]
clab2drawio = "clab_io_draw.clab2drawio:cli"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1b3cd70

Please sign in to comment.