From 3d41d79078b225c20ca8b69a70e9b1ac1da0b514 Mon Sep 17 00:00:00 2001 From: sadnub Date: Mon, 30 Aug 2021 22:17:21 -0400 Subject: [PATCH] change directory for nats configuration file for DOCKER. Fix nats-api commands in dev containers --- .devcontainer/api.dockerfile | 13 +++++++++---- .devcontainer/docker-compose.yml | 19 ++----------------- api/tacticalrmm/tacticalrmm/utils.py | 2 +- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/.devcontainer/api.dockerfile b/.devcontainer/api.dockerfile index 04f2b5b0..591306d5 100644 --- a/.devcontainer/api.dockerfile +++ b/.devcontainer/api.dockerfile @@ -13,12 +13,17 @@ EXPOSE 8000 8383 8005 RUN groupadd -g 1000 tactical && \ useradd -u 1000 -g 1000 tactical -# Copy Dev python reqs -COPY ./requirements.txt / +# Copy nats-api file +COPY natsapi/bin/nats-api /usr/local/bin/ +RUN chmod +x /usr/local/bin/nats-api -# Copy Docker Entrypoint -COPY ./entrypoint.sh / +# Copy dev python reqs +COPY .devcontainer/requirements.txt / + +# Copy docker entrypoint.sh +COPY .devcontainer/entrypoint.sh / RUN chmod +x /entrypoint.sh + ENTRYPOINT ["/entrypoint.sh"] WORKDIR ${WORKSPACE_DIR}/api/tacticalrmm diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 10a57c41..a21966a9 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -6,8 +6,8 @@ services: image: api-dev restart: always build: - context: . - dockerfile: ./api.dockerfile + context: .. + dockerfile: .devcontainer/api.dockerfile command: ["tactical-api"] environment: API_PORT: ${API_PORT} @@ -127,9 +127,6 @@ services: init-dev: container_name: trmm-init-dev image: api-dev - build: - context: . - dockerfile: ./api.dockerfile restart: on-failure command: ["tactical-init-dev"] environment: @@ -156,9 +153,6 @@ services: celery-dev: container_name: trmm-celery-dev image: api-dev - build: - context: . - dockerfile: ./api.dockerfile command: ["tactical-celery-dev"] restart: always networks: @@ -174,9 +168,6 @@ services: celerybeat-dev: container_name: trmm-celerybeat-dev image: api-dev - build: - context: . - dockerfile: ./api.dockerfile command: ["tactical-celerybeat-dev"] restart: always networks: @@ -192,9 +183,6 @@ services: websockets-dev: container_name: trmm-websockets-dev image: api-dev - build: - context: . - dockerfile: ./api.dockerfile command: ["tactical-websockets-dev"] restart: always networks: @@ -234,9 +222,6 @@ services: container_name: trmm-mkdocs-dev image: api-dev restart: always - build: - context: . - dockerfile: ./api.dockerfile command: ["tactical-mkdocs-dev"] ports: - "8005:8005" diff --git a/api/tacticalrmm/tacticalrmm/utils.py b/api/tacticalrmm/tacticalrmm/utils.py index 6969e079..2839fe93 100644 --- a/api/tacticalrmm/tacticalrmm/utils.py +++ b/api/tacticalrmm/tacticalrmm/utils.py @@ -265,7 +265,7 @@ def run_nats_api_cmd(mode: str, ids: list[str] = [], timeout: int = 30) -> None: "dbname": db["NAME"], } - with tempfile.NamedTemporaryFile() as fp: + with tempfile.NamedTemporaryFile(dir="/opt/tactical/tmp" if settings.DOCKER_BUILD else None) as fp: with open(fp.name, "w") as f: json.dump(config, f)