Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some local podman/docker config via environment #152

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/edge_containers_cli/cmds/k8s_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ def get_services(self, running_only: bool) -> polars.DataFrame:
has_header=False,
new_columns=["name", "running", "restarts"],
)
services_df = services_df.join(gtpo_df, on="name", how="left")
services_df = services_df.join(
gtpo_df, on="name", how="left", coalesce=True
)
services_df = services_df.with_columns(
polars.col("running").replace({"Running": True}, default=False),
polars.col("restarts").fill_null(0),
Expand All @@ -214,7 +216,7 @@ def get_services(self, running_only: bool) -> polars.DataFrame:
helm_df = polars.read_json(StringIO(str(helm_out)))
helm_df = helm_df.rename({"app_version": "version", "updated": "deployed"})
helm_df = helm_df.with_columns(polars.col("deployed").str.slice(0, 19))
services_df = services_df.join(helm_df, on="name", how="left")
services_df = services_df.join(helm_df, on="name", how="left", coalesce=True)
log.debug(services_df)

# Arrange columns
Expand Down
19 changes: 18 additions & 1 deletion src/edge_containers_cli/cmds/local_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

import json
import os
import re
import tempfile
from datetime import datetime
Expand Down Expand Up @@ -84,9 +85,25 @@ def _do_deploy(self, ioc_instance: Path, version: str, args: str):

vol = f"-v {volume}:{globals.IOC_CONFIG_FOLDER}"
label = f"-l is_IOC=true -l version={version}"
cmd = f"run -dit --net host --restart unless-stopped {label} {vol} {args}"
dest = "busybox:copyto"

# use environment to configure volumes and user id
data_folder = os.getenv("EC_LOCAL_DATA_FOLDER")
if data_folder:
vol = vol + f" -v {data_folder}:{data_folder}"
opi_folder = os.getenv("EC_LOCAL_OPI_FOLDER")
if opi_folder:
vol = vol + f" -v {opi_folder}:/epics/opi"

user_id = os.getenv("EC_LOCAL_USER_ID")
ids = f"-u {user_id}" if user_id else ""
group_id = os.getenv("EC_LOCAL_GROUP_ID")
if group_id:
cmd = f"{ids} -g {group_id}"

cmd = f"run -dit --net host --restart unless-stopped {label} {vol} {args} {ids}"
cmd = cmd.strip()

# get the config into the volume before launching the IOC container
shell.run_command(f"{self.docker.docker} rm -f busybox", interactive=False)
shell.run_command(
Expand Down
4 changes: 2 additions & 2 deletions tests/data/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ deploy_local:
rsp: ""
- cmd: docker rm -f busybox
rsp: ""
- cmd: docker run -dit --net host --restart unless-stopped -l is_IOC=true -l version=.* -v bl01t-ea-test-01_config:\/epics\/ioc\/config\/ --name bl01t-ea-test-01 ghcr.io\/epics-containers\/ioc-adsimdetector-runtime:2024.4.1
- cmd: docker run -dit --net host --restart unless-stopped -l is_IOC=true -l version=.* -v bl01t-ea-test-01_config:\/epics\/ioc\/config\/ --name bl01t-ea-test-01 ghcr.io\/epics-containers\/ioc-adsimdetector-runtime:2024.4.1
rsp: True
- cmd: docker ps -f name=bl01t-ea-test-01 --format .*
rsp: bl01t-ea-test-01
Expand All @@ -64,7 +64,7 @@ deploy:
rsp: ""
- cmd: docker rm -f busybox
rsp: ""
- cmd: docker run -dit --net host --restart unless-stopped -l is_IOC=true -l version=2.0 -v bl01t-ea-test-01_config:/epics/ioc/config/ --name bl01t-ea-test-01 ghcr.io/epics-containers/ioc-adsimdetector-runtime:2024.4.1
- cmd: docker run -dit --net host --restart unless-stopped -l is_IOC=true -l version=2.0 -v bl01t-ea-test-01_config:/epics/ioc/config/ --name bl01t-ea-test-01 ghcr.io/epics-containers/ioc-adsimdetector-runtime:2024.4.1
rsp: True
- cmd: docker ps -f name=bl01t-ea-test-01 --format .*
rsp: bl01t-ea-test-01
Expand Down