Skip to content

Commit

Permalink
add runtime volume for local docker
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Jun 25, 2024
1 parent c7cce83 commit f5a9d48
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
24 changes: 15 additions & 9 deletions src/edge_containers_cli/cmds/local_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,30 @@ def delete(self, service_name):
raise typer.Abort()
self.docker.remove(service_name)

def make_volume(self, volume: str):
shell.run_command(
f"{self.docker.docker} volume rm -f {volume}", interactive=False
)
shell.run_command(
f"{self.docker.docker} volume create {volume}", interactive=False
)

def _do_deploy(self, ioc_instance: Path, version: str, args: str):
service_name, _ = check_instance_path(ioc_instance)

image = get_instance_image_name(ioc_instance)
log.debug(f"deploying {ioc_instance} with image {image}")
config = ioc_instance / globals.CONFIG_FOLDER
service_name = ioc_instance.name
volume = f"{service_name}_config"
config_volume = f"{service_name}_config"
runtime_volume = f"{service_name}_runtime"

self.docker.remove(service_name)
shell.run_command(
f"{self.docker.docker} volume rm -f {volume}", interactive=False
)
shell.run_command(
f"{self.docker.docker} volume create {volume}", interactive=False
)
self.make_volume(config_volume)
self.make_volume(runtime_volume)

vol = f"-v {volume}:{globals.IOC_CONFIG_FOLDER}"
vol = f"-v {config_volume}:{globals.IOC_CONFIG_FOLDER}"
vol = vol + f" -v {runtime_volume}:{globals.IOC_RUNTIME_FOLDER}"
label = f"-l is_IOC=true -l version={version}"
dest = "busybox:copyto"

Expand All @@ -108,7 +114,7 @@ def _do_deploy(self, ioc_instance: Path, version: str, args: str):
shell.run_command(f"{self.docker.docker} rm -f busybox", interactive=False)
shell.run_command(
f"{self.docker.docker} container create --name busybox "
f"-v {volume}:/copyto busybox",
f"-v {config_volume}:/copyto busybox",
interactive=False,
)
for file in config.glob("*"):
Expand Down
2 changes: 2 additions & 0 deletions src/edge_containers_cli/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Context:
CONFIG_FOLDER = "config"
# location of IOC Instance configuration inside a Generic IOC container
IOC_CONFIG_FOLDER = "/epics/ioc/config/"
# location of IOC Instance configuration inside a Generic IOC container
IOC_RUNTIME_FOLDER = "/epics/runtime/"
# file name of IOC Instance ibek configuration inside a Generic IOC container
CONFIG_FILE_GLOB = "*.yaml"
# namespace name for deploying IOC instances into the local podman/docker
Expand Down
12 changes: 10 additions & 2 deletions tests/data/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ deploy_local:
rsp: bl01t-ea-test-01-config
- cmd: docker volume create bl01t-ea-test-01_config
rsp: bl01t-ea-test-01-config
- cmd: docker volume rm -f bl01t-ea-test-01_runtime
rsp: bl01t-ea-test-01-config
- cmd: docker volume create bl01t-ea-test-01_runtime
rsp: bl01t-ea-test-01-config
- cmd: docker rm -f busybox
rsp: ""
- cmd: docker container create --name busybox -v bl01t-ea-test-01_config:/copyto busybox
Expand All @@ -37,7 +41,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\/ -v bl01t-ea-test-01_runtime:/epics/runtime/ --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 @@ -53,6 +57,10 @@ deploy:
rsp: bl01t-ea-test-01-config
- cmd: docker volume create bl01t-ea-test-01_config
rsp: bl01t-ea-test-01-config
- cmd: docker volume rm -f bl01t-ea-test-01_runtime
rsp: bl01t-ea-test-01-config
- cmd: docker volume create bl01t-ea-test-01_runtime
rsp: bl01t-ea-test-01-config
- cmd: docker rm -f busybox
rsp: ""
- cmd: docker container create --name busybox -v bl01t-ea-test-01_config:/copyto busybox
Expand All @@ -64,7 +72,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/ -v bl01t-ea-test-01_runtime:/epics/runtime/ --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

0 comments on commit f5a9d48

Please sign in to comment.