Skip to content

Commit

Permalink
Pin port for assistants in docker container (#90)
Browse files Browse the repository at this point in the history
And update workbench-service setting from "hostname" to "host" so that
it won't pick up the "hostname" env var
  • Loading branch information
markwaddle authored Oct 6, 2024
1 parent c225dd4 commit 493f478
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/prospector-assistant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- "libraries/python/semantic-workbench-api-model/**"
- "libraries/python/semantic-workbench-assistant/**"
- "libraries/python/content-safety/**"
- "tools/docker/**"
- ".github/workflows/prospector-assistant.yml"

push:
Expand All @@ -17,6 +18,7 @@ on:
- "libraries/python/semantic-workbench-api-model/**"
- "libraries/python/semantic-workbench-assistant/**"
- "libraries/python/content-safety/**"
- "tools/docker/**"
- ".github/workflows/prospector-assistant.yml"

workflow_dispatch:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/skill-assistant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- "libraries/python/context/**"
- "libraries/python/events/**"
- "libraries/python/skills/**"
- "tools/docker/**"
- ".github/workflows/skill-assistant.yml"

push:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/workbench-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ name: workbench-service continuous integration
on:
pull_request:
branches: ["main"]
paths: ["workbench-service/**", ".github/workflows/workbench-service.yml"]
paths:
- "workbench-service/**"
- "tools/docker/**"
- ".github/workflows/workbench-service.yml"

push:
branches: ["main"]
paths: ["workbench-service/**", ".github/workflows/workbench-service.yml"]
paths:
- "workbench-service/**"
- "tools/docker/**"
- ".github/workflows/workbench-service.yml"

workflow_dispatch:

Expand Down
4 changes: 3 additions & 1 deletion tools/docker/Dockerfile.assistant
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ ENV PATH=/packages/assistants/assistant/.venv/bin:$PATH

COPY ./tools/docker/docker-entrypoint.sh /scripts/docker-entrypoint.sh
RUN chmod +x /scripts/docker-entrypoint.sh
ENTRYPOINT ["/scripts/docker-entrypoint.sh"]

ENV ASSISTANT_APP=${app}
ENV ASSISTANT__HOST=0.0.0.0
ENV ASSISTANT__PORT=3000

SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/scripts/docker-entrypoint.sh"]
CMD ["start-semantic-workbench-assistant"]
6 changes: 6 additions & 0 deletions tools/makefiles/docker-assistant.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ DOCKER_BUILD_ARGS = app=$(ASSISTANT_APP) package=$(ASSISTANT_PACKAGE)
DOCKER_IMAGE_NAME = $(ASSISTANT_IMAGE_NAME)

include $(this_dir)/docker.mk


ASSISTANT__WORKBENCH_SERVICE_URL ?= http://host.docker.internal:3000

docker-run-local: docker-build
docker run --rm -it --add-host=host.docker.internal:host-gateway --env assistant__workbench_service_url=$(ASSISTANT__WORKBENCH_SERVICE_URL) $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
2 changes: 1 addition & 1 deletion workbench-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RUN chmod +x /scripts/docker-entrypoint.sh

WORKDIR /workbench-service

ENV WORKBENCH__SERVICE__HOSTNAME=0.0.0.0
ENV WORKBENCH__SERVICE__HOST=0.0.0.0

SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/scripts/docker-entrypoint.sh"]
Expand Down
2 changes: 1 addition & 1 deletion workbench-service/semantic_workbench_service/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AuthSettings(BaseSettings):

class WebServiceSettings(BaseSettings):
protocol: str = "http"
hostname: str = "127.0.0.1"
host: str = "127.0.0.1"
port: int = 3000

assistant_api_key: ApiKeySettings = ApiKeySettings()
Expand Down
6 changes: 3 additions & 3 deletions workbench-service/semantic_workbench_service/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ def main():
"--host",
dest="host",
type=str,
default=settings.service.hostname,
default=settings.service.host,
help="host IP to run service on",
)
parse_args.add_argument(
"--port", dest="port", type=int, default=settings.service.port, help="port to run service on"
)
args = parse_args.parse_args()

settings.service.hostname = args.host
settings.service.host = args.host
settings.service.port = args.port

logger.info("Starting workbench service ...")
app = create_app()
uvicorn.run(
app,
host=settings.service.hostname,
host=settings.service.host,
port=settings.service.port,
log_config={"version": 1, "disable_existing_loggers": False},
)
Expand Down

0 comments on commit 493f478

Please sign in to comment.