Update app to use envs for server info
This commit is contained in:
@@ -13,10 +13,5 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||||||
# Copy the client code into the container
|
# Copy the client code into the container
|
||||||
COPY ./app/ .
|
COPY ./app/ .
|
||||||
|
|
||||||
# Define environment variable for the server host
|
|
||||||
# This will be set by the Makefile when running the container
|
|
||||||
ENV SERVER_HOST=localhost
|
|
||||||
|
|
||||||
# Run client.py when the container launches
|
# Run client.py when the container launches
|
||||||
# We use a list form of CMD to properly handle signals
|
|
||||||
CMD ["python", "client.py"]
|
CMD ["python", "client.py"]
|
||||||
|
|||||||
3
Makefile
3
Makefile
@@ -11,5 +11,8 @@ build:
|
|||||||
# Target to run the server container using the host network
|
# Target to run the server container using the host network
|
||||||
run: build
|
run: build
|
||||||
docker run -it --rm \
|
docker run -it --rm \
|
||||||
|
-e CLIENT_API_URL=${SERVER_WS_URI} \
|
||||||
|
-e CLIENT_API_URL=${SERVER_API_URL} \
|
||||||
|
-e CLIENT_API_URL=${CLIENT_API_URL} \
|
||||||
--network=host \
|
--network=host \
|
||||||
$(CLIENT_IMAGE)
|
$(CLIENT_IMAGE)
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import websockets
|
import websockets
|
||||||
import json
|
import json
|
||||||
import uuid # To generate a unique client ID
|
import uuid
|
||||||
|
import os
|
||||||
from drb_cdb_api import DRBCDBAPI, ConfigGenerator
|
from drb_cdb_api import DRBCDBAPI, ConfigGenerator
|
||||||
from server_api import RadioAPIClient
|
from server_api import RadioAPIClient
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
# --- Client Configuration ---
|
# --- Client Configuration ---
|
||||||
SERVER_WS_URI = "ws://localhost:8765"
|
SERVER_WS_URI = os.getenv("SERVER_WS_URI", "ws://localhost:8765")
|
||||||
SERVER_API_URL = "http://localhost:5000"
|
SERVER_API_URL = os.getenv("SERVER_API_URL", "http://localhost:5000")
|
||||||
CLIENT_API_URL = "http://localhost:8001"
|
CLIENT_API_URL = os.getenv("CLIENT_API_URL", "http://localhost:8001")
|
||||||
# Generate or define a unique ID for THIS client instance
|
# Generate or define a unique ID for THIS client instance
|
||||||
# In a real app, this might come from config or a login process
|
# In a real app, this might come from config or a login process
|
||||||
CLIENT_ID = f"client-{uuid.uuid4().hex[:8]}" # TODO - Implement persistent ID
|
CLIENT_ID = f"client-{uuid.uuid4().hex[:8]}" # TODO - Implement persistent ID
|
||||||
|
|||||||
Reference in New Issue
Block a user