Skip to content

Commit

Permalink
Add rose dir to path when running driver outside a container
Browse files Browse the repository at this point in the history
Signed-off-by: yzamir <kobi.zamir@gmail.com>
  • Loading branch information
yaacov committed Sep 12, 2023
1 parent 327c5b7 commit c98bcfb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
6 changes: 4 additions & 2 deletions rose/client/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.PHONY: lint test lint-fix code-quality run build-image run-image clean

ROSE_DIR = ../..

IMAGE_NAME ?= quay.io/rose/rose-client
DRIVER_PATH ?= ./mydriver.py
DRIVER_PATH ?= $(ROSE_DIR)/examples/none.py
PORT ?= 8081

# By default, run both linting and tests
Expand All @@ -27,7 +29,7 @@ test:

run:
@echo "Running driver logic server ..."
python main.py --port $(PORT) --driver $(DRIVER_PATH)
PYTHONPATH=$(ROSE_DIR):$$PYTHONPATH python main.py --port $(PORT) --driver $(DRIVER_PATH)

build-image:
@echo "Building container image ..."
Expand Down
38 changes: 32 additions & 6 deletions rose/client/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,49 @@ This server uses a default driver logic which chooses the next action randomly.

Podman Usage
============
1. Build the Podman image:
1. Build the container image:

.. code-block:: bash
# Edit mydriver.py file.
podman build -t rose-driver .
2. Run the container:
2. Build and run a custom container image:

.. code-block:: bash
# Edit mydriver.py file, and create the best driver code,
# once mydriver.py is ready build and run the container.
# Customize the container using your driver.
# Copy a driver to current directory
cp ../../examples/none.py ./mydriver.py
# Edit ./mydriver.py file, and create the best driver code,
# once ./mydriver.py is ready build the custom container.
# Build the custom image:
# The driver ./mydriver.py will be baked into the custom container image.
podman build -t rose-driver .
podman run -it --rm --network host rose-driver --port 8081
3. Run the container using local driver python file:
# Run the custom container
# Important: ./mydriver.py must be baked into the image during build,
# see bellow for instructions on running a local driver.
podman run -it --rm --network host rose-driver
3. (Optional) To use you custom container image in an Openshift cluster you need to push it to a publich repository.

.. code-block:: bash
# Login (this example use quay.io)
podman login quay.io
# Tag the image uging your name (for example 'jhon_doe')
podman tag rose-driver quay.io/john_doe/my_rose_driver:latest
# Push the image to the public repository (use the name you like, for example 'my_rose_driver')
podman push quay.io/john_doe/my_rose_driver:latest
# Now you can deploy your custom container image into an openshift cluster
4. Run the container using local driver python file:

.. code-block:: bash
Expand Down
14 changes: 0 additions & 14 deletions rose/client/mydriver.py

This file was deleted.

0 comments on commit c98bcfb

Please sign in to comment.