From 451c207592fd3d9e77352febe9fe4080282eb2e3 Mon Sep 17 00:00:00 2001 From: DustyPullRequest Date: Mon, 7 Apr 2025 14:09:42 -0400 Subject: [PATCH] Added data persistance to memory server --- compose.yaml | 4 ++++ servers/memory/Dockerfile | 7 +++++-- servers/memory/compose.yaml | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index 2f4cf27..0d106e9 100644 --- a/compose.yaml +++ b/compose.yaml @@ -9,9 +9,13 @@ services: context: ./servers/memory ports: - 8082:8000 + volumes: + - memory:/app/data:rw time-server: build: context: ./servers/time ports: - 8083:8000 +volumes: + memory: diff --git a/servers/memory/Dockerfile b/servers/memory/Dockerfile index 8a89bb3..535cc6b 100644 --- a/servers/memory/Dockerfile +++ b/servers/memory/Dockerfile @@ -38,8 +38,11 @@ RUN --mount=type=cache,target=/root/.cache/pip \ --mount=type=bind,source=requirements.txt,target=requirements.txt \ python -m pip install -r requirements.txt -# Change the ownership of /app directory and its contents to appuser -RUN chown -R ${UID}:${UID} /app +# Change the ownership of /app/data directory and its contents to appuser +RUN mkdir -p /app/data && touch /app/data/memory.json && chown -R ${UID}:${UID} /app/data + +# Set a flag for the location of the database +ENV MEMORY_FILE_PATH="/app/data/memory.json" # Switch to the non-privileged user to run the application. USER appuser diff --git a/servers/memory/compose.yaml b/servers/memory/compose.yaml index 9fc4d98..848fb34 100644 --- a/servers/memory/compose.yaml +++ b/servers/memory/compose.yaml @@ -4,4 +4,9 @@ services: context: . ports: - 8000:8000 + volumes: + - memory:/app/data:rw + +volumes: + memory: