Skip to content

Commit 4e71798

Browse files
committed
feat(setup): add Docker environment detection for execution command
The changes introduce an environment variable check (`IN_DOCKER`) to conditionally diisplay a different command in setup depending on whether the code is running inside a Docker container. This allows for seamless switching between local and Docker execution contexts for generating configurations.
1 parent 478d55c commit 4e71798

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ RUN --mount=type=cache,target=/root/.cache/pip \
1717
# Start the final image using a slimmer version of Python
1818
FROM python:3.12-slim
1919

20+
ENV IN_DOCKER=1
21+
2022
# Set the working directory
2123
WORKDIR /app
2224

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from rich.text import Text
33
from ruamel.yaml import YAML
44
from functions import console
5+
import os
56

67
import tempfile
78

@@ -82,5 +83,9 @@
8283

8384
console.print(Text(f"\nconfig.yaml has not been created! The created file is in {temp_file_name}", style="bold red"))
8485

86+
if os.environ.get('IN_DOCKER', False):
87+
command = 'docker run --rm -ti -v "./config.yaml:/app/config.yaml" -v "./compose:/app/compose" obeoneorg/multi-registry-cache generate'
88+
else:
89+
command = 'python3 generate.py'
8590

86-
console.print("[bold green]Now you can edit config.yaml and fine-tune parameters and when it's ok for you, just run [bold blue]'python3 generate.py'")
91+
console.print(f"[bold green]Now you can edit [bold blue]config.yaml[bold green] and fine-tune parameters and when it's ok for you, just run :\n[bold blue]{command}")

0 commit comments

Comments
 (0)