diff --git a/docker/Dockerfile b/docker/Dockerfile index 72e3dbc4ac17f269c6ac33b9078842a2717e0012..606b939c91e83cacbf12f7f874eda56ca05853c1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,8 @@ FROM python:alpine3.17 +WORKDIR /app + COPY requirements.txt requirements.txt RUN pip install -r requirements.txt -COPY . . ENTRYPOINT [ "python" ] \ No newline at end of file diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 8e282abdaeb9c5a39471abd8c6fa14cc789b1a58..a76b1f7325892caa7b11dc3d8189a683ccf32853 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -19,7 +19,10 @@ services: - rabbitmq__local environment: - MQ_HOST=rmq + volumes: + - ../:/app command: "soar_bus.py" + container_name: soar_bus soar_api: build: @@ -35,5 +38,6 @@ services: environment: - MQ_HOST=rmq volumes: - - ${DATA_DIR}/data:${DATA_DIR}/data - command: "api.py" \ No newline at end of file + - ../:/app + command: "api.py" + container_name: soar_api \ No newline at end of file diff --git a/endpoints/auth_resource.py b/endpoints/auth_resource.py index ef1bbf90304a48da2c35397027fba4a0171d55ef..6429a202e16b1e0018ac278f723c1e8ea5bc7cfe 100644 --- a/endpoints/auth_resource.py +++ b/endpoints/auth_resource.py @@ -10,7 +10,7 @@ class AuthResource(Resource): def __init__(self): self.token = TokenModel() - with open("/data/clients.json", "r") as clients_file: + with open("./data/clients.json", "r") as clients_file: self.clients = json.load(clients_file) def auth(self, request): diff --git a/endpoints/clients.py b/endpoints/clients.py index 7698b8b880c6253a0607d9aef6ef16ef0dd088c4..659080bcf98fc823417cdd99963edd16af370bdf 100644 --- a/endpoints/clients.py +++ b/endpoints/clients.py @@ -13,7 +13,7 @@ class ClientSchema(Schema): class ClientsFile: - file = "/data/clients.json" + file = "./data/clients.json" mtime = 0 clients = {} parser = None diff --git a/endpoints/token.py b/endpoints/token.py index 9448bf8b7a2b6b3f1426cb9c4a942f3146c307b9..077ce5a81f66da6fcaa299f667e529749059980c 100644 --- a/endpoints/token.py +++ b/endpoints/token.py @@ -19,7 +19,7 @@ class Token(Resource): self.schema = TokenQuerySchema() self.model = TokenModel() data_dir = os.getenv("DATA_DIR", "/data") - with open(data_dir + "/clients.json", "r") as clients_file: + with open("./data/clients.json", "r") as clients_file: self.clients = json.load(clients_file) def get(self): diff --git a/run-compose.sh b/run-compose.sh index a5b16a0b2b81b1d99fa5e9e8005d08a295fc4b28..6b8bfad9e933e47f7ff62492707c92a2f2b006ff 100755 --- a/run-compose.sh +++ b/run-compose.sh @@ -3,8 +3,26 @@ set -a source .env +usage() { + echo "usage: ./run-compose.sh [<rebuild>]" + echo " rebuild - will force docker-compose to rebuild the images before spinning them up." +} + if [[ -z "${DATA_DIR}" ]]; then DATA_DIR=$(pwd) fi -docker-compose -f docker/docker-compose.yaml up --build \ No newline at end of file +while [ -n "$1" ]; do + case $1 in + rebuild) + EXTRA_ARGS="--build" + ;; + *) + usage + exit 0 + ;; + esac + shift +done + +docker-compose -f docker/docker-compose.yaml up $EXTRA_ARGS \ No newline at end of file